}
// we assume that the user typed an identifier for an IdP, not for a user
IdpIdentifier openId = new IdpIdentifier(req.getParameter("openid"));
AuthRequestHelper helper = consumerHelper.getAuthRequestHelper(
openId, returnToUrl.toString());
helper.requestUxIcon(true);
if (accessor != null) {
log.debug("Requesting OAuth scope : " +
(String) accessor.getProperty("scope"));
helper.requestOauthAuthorization(accessor.consumer.consumerKey,
(String) accessor.getProperty("scope"));
}
if (YES_STRING.equals(req.getParameter("email"))) {
log.debug("Requesting AX email");
helper.requestAxAttribute(Step2.AxSchema.EMAIL, true);
}
if (YES_STRING.equals(req.getParameter("country"))) {
log.debug("Requesting AX country");
helper.requestAxAttribute(Step2.AxSchema.COUNTRY, true);
}
if (YES_STRING.equals(req.getParameter("language"))) {
log.debug("Requesting AX country");
helper.requestAxAttribute(Step2.AxSchema.LANGUAGE, true);
}
if (YES_STRING.equals(req.getParameter("firstName"))) {
log.debug("Requesting AX country");
helper.requestAxAttribute(Step2.AxSchema.FIRST_NAME, true);
}
if (YES_STRING.equals(req.getParameter("lastName"))) {
log.debug("Requesting AX country");
helper.requestAxAttribute(Step2.AxSchema.LAST_NAME, true);
}
HttpSession session = req.getSession();
AuthRequest authReq = null;
try {
authReq = helper.generateRequest();
authReq.setRealm(realm);
// add PAPE, if requested
if (YES_STRING.equals(req.getParameter("reauth"))) {
log.debug("Requesting PAPE reauth");
PapeRequest pape = PapeRequest.createPapeRequest();
pape.setMaxAuthAge(1);
authReq.addExtension(pape);
}
session.setAttribute("discovered", helper.getDiscoveryInformation());
} catch (DiscoveryException e) {
StringBuffer errorMessage =
new StringBuffer("Could not discover OpenID endpoint.");
errorMessage.append("\n\n").append("Check if URL is valid: ");
errorMessage.append(openId).append("\n\n");