String userSelectedClaimedId = (String) userData.get(0);
Boolean authenticatedAndApproved = (Boolean) userData.get(1);
String email = (String) userData.get(2);
// --- process an authentication request ---
AuthRequest authReq =
AuthRequest.createAuthRequest(request, manager.getRealmVerifier());
String opLocalId = null;
// if the user chose a different claimed_id than the one in request
if (userSelectedClaimedId != null &&
userSelectedClaimedId.equals(authReq.getClaimed()))
{
//opLocalId = lookupLocalId(userSelectedClaimedId);
}
response = manager.authResponse(request,
opLocalId,
userSelectedClaimedId,
authenticatedAndApproved.booleanValue(),
false); // Sign after we added extensions.
if (response instanceof DirectError)
return directResponse(httpResp, response.keyValueFormEncoding());
else
{
if (authReq.hasExtension(AxMessage.OPENID_NS_AX))
{
MessageExtension ext = authReq.getExtension(AxMessage.OPENID_NS_AX);
if (ext instanceof FetchRequest)
{
FetchRequest fetchReq = (FetchRequest) ext;
Map required = fetchReq.getAttributes(true);
//Map optional = fetchReq.getAttributes(false);
if (required.containsKey("email"))
{
Map userDataExt = new HashMap();
//userDataExt.put("email", userData.get(3));
FetchResponse fetchResp =
FetchResponse.createFetchResponse(fetchReq, userDataExt);
// (alternatively) manually add attribute values
fetchResp.addAttribute("email",
"http://schema.openid.net/contact/email", email);
response.addExtension(fetchResp);
}
}
else //if (ext instanceof StoreRequest)
{
throw new UnsupportedOperationException("TODO");
}
}
if (authReq.hasExtension(SRegMessage.OPENID_NS_SREG))
{
MessageExtension ext = authReq.getExtension(SRegMessage.OPENID_NS_SREG);
if (ext instanceof SRegRequest)
{
SRegRequest sregReq = (SRegRequest) ext;
List required = sregReq.getAttributes(true);
//List optional = sregReq.getAttributes(false);