@Inject
private Instance<OpenIdProviderBean> opBean;
public void handleIncomingMessage(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws InvalidRequestException
{
ParameterList parameterList = new ParameterList(httpRequest.getParameterMap());
String mode = parameterList.getParameterValue("openid.mode");
Message associationResponse;
if ("associate".equals(mode))
{
associationResponse = openIdServerManager.get().associationResponse(parameterList);
writeMessageToResponse(associationResponse, httpResponse);
}
else if ("checkid_setup".equals(mode) || "checkid_immediate".equals(mode))
{
dialogueManager.beginDialogue();
String claimedIdentifier = parameterList.getParameterValue("openid.claimed_id");
String opLocalIdentifier = parameterList.getParameterValue("openid.identity");
openIdProviderRequest.get().setParameterList(parameterList);
openIdProviderRequest.get().setClaimedIdentifier(claimedIdentifier);
MessageExtension ext = null;
try
{
AuthRequest authReq = AuthRequest.createAuthRequest(parameterList, openIdServerManager.get().getRealmVerifier());
if (authReq.hasExtension(AxMessage.OPENID_NS_AX))
{
ext = authReq.getExtension(AxMessage.OPENID_NS_AX);
}
}
catch (MessageException e)
{
throw new RuntimeException(e);
}
if (ext instanceof FetchRequest)
{
FetchRequest fetchRequest = (FetchRequest) ext;
List<OpenIdRequestedAttribute> requestedAttributes = new LinkedList<OpenIdRequestedAttribute>();
handleAttributeRequests(fetchRequest, requestedAttributes, false);
handleAttributeRequests(fetchRequest, requestedAttributes, true);
openIdProviderRequest.get().setRequestedAttributes(requestedAttributes);
openIdProviderRequest.get().setFetchRequest(fetchRequest);
}
if (claimedIdentifier != null && opLocalIdentifier != null)
{
boolean immediate = "checkid_immediate".equals(mode);
String realm = parameterList.getParameterValue("openid.realm");
if (realm == null)
{
realm = parameterList.getParameterValue("openid.return_to");
}
if (opLocalIdentifier.equals(AuthRequest.SELECT_ID))
{
openIdProviderSpi.get().authenticate(realm, null, immediate, responseHandler.createResponseHolder(httpResponse));