use of org.forgerock.openam.core.rest.authn.core.AuthIndexType in project OpenAM by OpenRock.
the class RestAuthenticationHandler method authenticate.
/**
* Handles either the creation or retrieval of the Login Process, dependent on if the request is a new
* authentication request or a continuation of one.
*
* @param request The HttpServletRequest.
* @param response The HttpServletResponse.
* @param postBody The post body of the request.
* @param authIndexType The authentication index type.
* @param indexValue The authentication index value.
* @param sessionUpgradeSSOTokenId The SSO Token Id of the user's current session, null if not performing a session
* upgrade.
* @return The Response of the authentication request.
*/
private JsonValue authenticate(HttpServletRequest request, HttpServletResponse response, JsonValue postBody, String authIndexType, String indexValue, String sessionUpgradeSSOTokenId) throws RestAuthException {
LoginProcess loginProcess = null;
try {
AuthIndexType indexType = getAuthIndexType(authIndexType);
String authId = null;
String sessionId = null;
if (postBody != null) {
authId = getAuthId(postBody);
if (authId != null) {
SignedJwt jwt = authIdHelper.reconstructAuthId(authId);
sessionId = getSessionId(jwt);
indexType = getAuthIndexType(jwt);
indexValue = getAuthIndexValue(jwt);
String realmDN = getRealmDomainName(jwt);
AuditRequestContext.putProperty(SESSION_ID, sessionId);
authIdHelper.verifyAuthId(realmDN, authId);
}
}
LoginConfiguration loginConfiguration = new LoginConfiguration().httpRequest(request).httpResponse(response).indexType(indexType).indexValue(indexValue).sessionId(sessionId).forceAuth(request.getParameter(AuthUtils.FORCE_AUTH)).sessionUpgrade(sessionUpgradeSSOTokenId);
loginProcess = loginAuthenticator.getLoginProcess(loginConfiguration);
return processAuthentication(request, response, postBody, authId, loginProcess, loginConfiguration);
} catch (RestAuthException e) {
if (loginProcess != null) {
String failureUrl = urlValidator.getRedirectUrl(loginProcess.getAuthContext().getOrgDN(), loginProcess.getFailureURL(), null);
e.setFailureUrl(failureUrl);
}
throw e;
} catch (L10NMessageImpl e) {
throw new RestAuthException(amAuthErrorCodeResponseStatusMapping.getAuthLoginExceptionResponseStatus(e.getErrorCode()), e);
} catch (JsonException e) {
throw new RestAuthException(ResourceException.INTERNAL_ERROR, e);
} catch (SignatureException e) {
throw new RestAuthException(ResourceException.INTERNAL_ERROR, e);
} catch (AuthLoginException e) {
throw new RestAuthException(amAuthErrorCodeResponseStatusMapping.getAuthLoginExceptionResponseStatus(e.getErrorCode()), e);
} catch (JwsSigningException jse) {
DEBUG.error("JwsSigningException", jse);
throw new RestAuthException(ResourceException.INTERNAL_ERROR, "JwsSigningException, " + jse.getMessage());
}
}
use of org.forgerock.openam.core.rest.authn.core.AuthIndexType in project OpenAM by OpenRock.
the class RestAuthenticationHandler method getAuthIndexType.
private AuthIndexType getAuthIndexType(SignedJwt jwt) throws RestAuthException {
AuthIndexType indexType;
String authIndexTypeString = jwt.getClaimsSet().getClaim("authIndexType", String.class);
indexType = getAuthIndexType(authIndexTypeString);
return indexType;
}
Aggregations