Search in sources :

Example 6 with EncryptContext

use of org.apache.servicecomb.it.edge.encrypt.EncryptContext in project incubator-servicecomb-java-chassis by apache.

the class DecodeBodyFilter method afterReceiveRequest.

@Override
public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
    EncryptContext encryptContext = (EncryptContext) invocation.getHandlerContext().get(EdgeConst.ENCRYPT_CONTEXT);
    if (encryptContext == null) {
        return null;
    }
    Hcr hcr = encryptContext.getHcr();
    String encodedBody = requestEx.getParameter("body");
    if (encodedBody == null) {
        return null;
    }
    encodedBody = encodedBody.substring(hcr.getBodyKey().length());
    try {
        Map<String, String[]> decodedBody = RestObjectMapperFactory.getRestObjectMapper().readValue(encodedBody, bodyType);
        requestEx.getParameterMap().putAll(decodedBody);
    } catch (Throwable e) {
        // should be a meaning exception response
        return Response.producerFailResp(e);
    }
    return null;
}
Also used : Hcr(org.apache.servicecomb.it.authentication.encrypt.Hcr) EncryptContext(org.apache.servicecomb.it.edge.encrypt.EncryptContext)

Example 7 with EncryptContext

use of org.apache.servicecomb.it.edge.encrypt.EncryptContext in project incubator-servicecomb-java-chassis by apache.

the class UserIdFilter method afterReceiveRequest.

@Override
public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
    EncryptContext encryptContext = (EncryptContext) invocation.getHandlerContext().get(EdgeConst.ENCRYPT_CONTEXT);
    if (encryptContext == null) {
        return null;
    }
    String userId = encryptContext.getUserId();
    if (userId != null) {
        requestEx.setParameter("userId", userId);
    }
    return null;
}
Also used : EncryptContext(org.apache.servicecomb.it.edge.encrypt.EncryptContext)

Example 8 with EncryptContext

use of org.apache.servicecomb.it.edge.encrypt.EncryptContext in project java-chassis by ServiceComb.

the class DecodeBodyFilter method afterReceiveRequest.

@Override
public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
    EncryptContext encryptContext = (EncryptContext) invocation.getHandlerContext().get(EdgeConst.ENCRYPT_CONTEXT);
    if (encryptContext == null) {
        return null;
    }
    Hcr hcr = encryptContext.getHcr();
    String encodedBody = requestEx.getParameter("body");
    if (encodedBody == null) {
        return null;
    }
    encodedBody = encodedBody.substring(hcr.getBodyKey().length());
    try {
        Map<String, String[]> decodedBody = RestObjectMapperFactory.getRestObjectMapper().readValue(encodedBody, bodyType);
        requestEx.getParameterMap().putAll(decodedBody);
    } catch (Throwable e) {
        // should be a meaning exception response
        return Response.producerFailResp(e);
    }
    return null;
}
Also used : Hcr(org.apache.servicecomb.it.authentication.encrypt.Hcr) EncryptContext(org.apache.servicecomb.it.edge.encrypt.EncryptContext)

Aggregations

EncryptContext (org.apache.servicecomb.it.edge.encrypt.EncryptContext)8 Hcr (org.apache.servicecomb.it.authentication.encrypt.Hcr)6 Hasher (com.google.common.hash.Hasher)4 Buffer (io.vertx.core.buffer.Buffer)2