当前位置: 首页>>代码示例>>Java>>正文


Java MACInput类代码示例

本文整理汇总了Java中org.alfresco.encryption.MACUtils.MACInput的典型用法代码示例。如果您正苦于以下问题:Java MACInput类的具体用法?Java MACInput怎么用?Java MACInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MACInput类属于org.alfresco.encryption.MACUtils包,在下文中一共展示了MACInput类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: authenticateResponse

import org.alfresco.encryption.MACUtils.MACInput; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean authenticateResponse(HttpMethod method, String remoteIP, byte[] decryptedBody)
{
    try
    {
        byte[] expectedMAC = getResponseMac(method);
        Long timestamp = getResponseTimestamp(method);
        if(timestamp == null)
        {
            return false;
        }
        remoteIP = IPUtils.getRealIPAddress(remoteIP);
        return authenticate(expectedMAC, new MACInput(decryptedBody, timestamp.longValue(), remoteIP));
    }
    catch(Exception e)
    {
        throw new RuntimeException("Unable to authenticate HTTP response", e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:23,代码来源:DefaultEncryptionUtils.java

示例2: authenticate

import org.alfresco.encryption.MACUtils.MACInput; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean authenticate(HttpServletRequest req, byte[] decryptedBody)
{
    try
    {
        byte[] expectedMAC = getMac(req);
        Long timestamp = getTimestamp(req);
        if(timestamp == null)
        {
            return false;
        }
        String ipAddress = IPUtils.getRealIPAddress(req.getRemoteAddr());
        return authenticate(expectedMAC, new MACInput(decryptedBody, timestamp.longValue(), ipAddress));
    }
    catch(Exception e)
    {
        throw new AlfrescoRuntimeException("Unable to authenticate HTTP request", e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:23,代码来源:DefaultEncryptionUtils.java

示例3: setRequestAuthentication

import org.alfresco.encryption.MACUtils.MACInput; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setRequestAuthentication(HttpMethod method, byte[] message) throws IOException
{
    long requestTimestamp = System.currentTimeMillis();

    // add MAC header
    byte[] mac = macUtils.generateMAC(KeyProvider.ALIAS_SOLR, new MACInput(message, requestTimestamp, getLocalIPAddress()));

    if(logger.isDebugEnabled())
    {
        logger.debug("Setting MAC " + Arrays.toString(mac) + " on HTTP request " + method.getPath());
        logger.debug("Setting timestamp " + requestTimestamp + " on HTTP request " + method.getPath());
    }
    
    setRequestMac(method, mac);

    // prevent replays
    setRequestTimestamp(method, requestTimestamp);
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:23,代码来源:DefaultEncryptionUtils.java

示例4: setResponseAuthentication

import org.alfresco.encryption.MACUtils.MACInput; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setResponseAuthentication(HttpServletRequest httpRequest, HttpServletResponse httpResponse,
        byte[] responseBody, AlgorithmParameters params) throws IOException
{
    long responseTimestamp = System.currentTimeMillis();
    byte[] mac = macUtils.generateMAC(KeyProvider.ALIAS_SOLR,
            new MACInput(responseBody, responseTimestamp, getLocalIPAddress()));

    if(logger.isDebugEnabled())
    {
        logger.debug("Setting MAC " + Arrays.toString(mac) + " on HTTP response to request " + httpRequest.getRequestURI());
        logger.debug("Setting timestamp " + responseTimestamp + " on HTTP response to request " + httpRequest.getRequestURI());
    }

    setAlgorithmParameters(httpResponse, params);
    setMac(httpResponse, mac);

    // prevent replays
    setTimestamp(httpResponse, responseTimestamp);
}
 
开发者ID:Alfresco,项目名称:alfresco-core,代码行数:24,代码来源:DefaultEncryptionUtils.java

示例5: setRequestAuthentication

import org.alfresco.encryption.MACUtils.MACInput; //导入依赖的package包/类
@Override
public void setRequestAuthentication(HttpMethod method, byte[] message) throws IOException
{
    if (method instanceof PostMethod)
    {
        // encrypt body
        Pair<byte[], AlgorithmParameters> encrypted = encryptor.encrypt(KeyProvider.ALIAS_SOLR, null, message);
        setRequestAlgorithmParameters(method, encrypted.getSecond());

        ((PostMethod) method).setRequestEntity(new ByteArrayRequestEntity(encrypted.getFirst(), "application/octet-stream"));
    }

    long requestTimestamp = System.currentTimeMillis();

    // add MAC header
    byte[] mac = macUtils.generateMAC(KeyProvider.ALIAS_SOLR, new MACInput(message, requestTimestamp, getLocalIPAddress()));

    if (logger.isDebugEnabled())
    {
        logger.debug("Setting MAC " + mac + " on HTTP request " + method.getPath());
        logger.debug("Setting timestamp " + requestTimestamp + " on HTTP request " + method.getPath());
    }

    if (overrideMAC)
    {
        mac[0] += (byte) 1;
    }
    setRequestMac(method, mac);

    if (overrideTimestamp)
    {
        requestTimestamp += 60000;
    }
    // prevent replays
    setRequestTimestamp(method, requestTimestamp);
}
 
开发者ID:Alfresco,项目名称:alfresco-solrclient,代码行数:37,代码来源:SOLRAPIClientTest.java


注:本文中的org.alfresco.encryption.MACUtils.MACInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。