我想将我的Saml应用程序与AWS集成起来,但不幸的是,我的Saml代码接受了它的输入,如下所示。我需要发送HttpServletRequest和HttpServletResponse作为我的java处理程序的输入。因此,它需要request和response作为输入,但我的lambda处理程序只将输入作为JSON或java,而我对如何继续操作感到困惑。
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
//validation
//output
return authentication;
}发布于 2018-02-23 09:21:33
AWS团队创建了一个无服务器包装器,用于公开请求和响应对象。这应该允许您执行您的need.In处理程序,您可以实现一个新接口,并且它们的底层功能会将请求和响应作为AwsProxyRequest和AwsProxyResponse返回给您,后者应该是HttpServletRequest和HttpServletResponse的子级。
码
public class StreamLambdaHandler implements RequestStreamHandler {
private SpringLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
private Logger log = LoggerFactory.getLogger(StreamLambdaHandler.class);
@Override
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
throws IOException {
if (handler == null) {
try {
handler = SpringLambdaContainerHandler.getAwsProxyHandler(PetStoreSpringAppConfig.class);
} catch (ContainerInitializationException e) {
log.error("Cannot initialize Spring container", e);
outputStream.close();
throw new RuntimeException(e);
}
}
AwsProxyRequest request = LambdaContainerHandler.getObjectMapper().readValue(inputStream, AwsProxyRequest.class);
AwsProxyResponse resp = handler.proxy(request, context);
LambdaContainerHandler.getObjectMapper().writeValue(outputStream, resp);
// just in case it wasn't closed by the mapper
outputStream.close();
}
}源-> https://github.com/awslabs/aws-serverless-java-container
https://stackoverflow.com/questions/48930140
复制相似问题