}
public void processIncomingMessage(ParameterList parameterList, String queryString, HttpServletResponse httpResponse) {
try {
// retrieve the previously stored discovery information
DiscoveryInformation discovered = openIdRequest.getDiscoveryInformation();
if (discovered == null) {
throw new IllegalStateException("No discovery information found in OpenID request");
}
// extract the receiving URL from the HTTP request
StringBuffer receivingURL = new StringBuffer(relyingPartyBean.get().getServiceURL(OpenIdService.OPEN_ID_SERVICE));
if (queryString != null && queryString.length() > 0)
receivingURL.append("?").append(queryString);
// verify the response; ConsumerManager needs to be the same
// (static) instance used to place the authentication request
VerificationResult verification = openIdConsumerManager.verify(
receivingURL.toString(), parameterList, discovered);
// examine the verification result and extract the verified identifier
Identifier identifier = verification.getVerifiedId();
if (identifier != null) {
AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
Map<String, List<String>> attributeValues = null;
if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
@SuppressWarnings("unchecked")
Map<String, List<String>> attrValues = fetchResp.getAttributes();
attributeValues = attrValues;
}
OpenIdPrincipal principal = createPrincipal(identifier.getIdentifier(),
discovered.getOPEndpoint(), attributeValues);
openIdRelyingPartySpi.get().loginSucceeded(principal,
responseHandler.createResponseHolder(httpResponse));
} else {
openIdRelyingPartySpi.get().loginFailed(verification.getStatusMsg(),