use of org.openid4java.message.pape.PapeRequest in project gerrit by GerritCodeReview.
the class OpenIdServiceImpl method discover.
@SuppressWarnings("unchecked")
DiscoveryResult discover(HttpServletRequest req, String openidIdentifier, SignInMode mode, boolean remember, String returnToken) {
final State state;
state = init(req, openidIdentifier, mode, remember, returnToken);
if (state == null) {
return new DiscoveryResult(DiscoveryResult.Status.NO_PROVIDER);
}
final AuthRequest aReq;
try {
aReq = manager.authenticate(state.discovered, state.retTo.toString());
logger.atFine().log("OpenID: openid-realm=%s", state.contextUrl);
aReq.setRealm(state.contextUrl);
if (requestRegistration(aReq)) {
final SRegRequest sregReq = SRegRequest.createFetchRequest();
sregReq.addAttribute("fullname", true);
sregReq.addAttribute("email", true);
aReq.addExtension(sregReq);
final FetchRequest fetch = FetchRequest.createFetchRequest();
fetch.addAttribute("FirstName", SCHEMA_FIRSTNAME, true);
fetch.addAttribute("LastName", SCHEMA_LASTNAME, true);
fetch.addAttribute("Email", SCHEMA_EMAIL, true);
aReq.addExtension(fetch);
}
if (0 <= papeMaxAuthAge) {
final PapeRequest pape = PapeRequest.createPapeRequest();
pape.setMaxAuthAge(papeMaxAuthAge);
aReq.addExtension(pape);
}
} catch (MessageException | ConsumerException e) {
logger.atSevere().withCause(e).log("Cannot create OpenID redirect for %s", openidIdentifier);
return new DiscoveryResult(DiscoveryResult.Status.ERROR);
}
return new DiscoveryResult(aReq.getDestinationUrl(false), aReq.getParameterMap());
}
Aggregations