HttpSession session = request.getSession();
LoggedUserInfoAdminStub stub;
String loggedinUser = null;
if (backendServerURL == null) {
throw new AuthenticationException("Server not initialized properly.");
}
try {
stub = getLoggedUserInfoAdminStub(backendServerURL, session);
ServiceClient client = stub._getServiceClient();
// In side this method - Authenticators should complete the authentication with the
// back-end service Or - it should set the required authentication headers, there are
// required in future service calls. Also each Authenticator should know how to handle
// the Remember Me logic.
loggedinUser = doAuthentication(credentials, rememberMe, client, request);
if (isAdminCookieSet()) {
// If the UI Authenticator takes the responsibility of setting the Admin Cookie,it
// has to set the value in the session with the key
// ServerConstants.ADMIN_SERVICE_AUTH_TOKEN.
client.getServiceContext().setProperty(HTTPConstants.COOKIE_STRING,
session.getAttribute(ServerConstants.ADMIN_SERVICE_AUTH_TOKEN));
}
// By now, user is authenticated or proper authentication headers been set. This call
// set retrieve user authorization information from the back-end.
setUserAuthorizationInfo(stub, session);
if (!isAdminCookieSet()) {
// If authentication successful set the cookie.
// Authenticators them selves have not set the cookie.
setAdminCookie(session, client, null);
}
// Process remember me data in reply
if (rememberMe) {
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext;
Map transportHeaders;
inMessageContext = operationContext
.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
transportHeaders = (Map) inMessageContext
.getProperty(MessageContext.TRANSPORT_HEADERS);
handleRememberMe(transportHeaders, request);
}
onSuccessAdminLogin(request, loggedinUser);
} catch (RemoteException e) {
throw new AuthenticationException(e.getMessage(), e);
} catch (Exception e) {
throw new AuthenticationException(
"Exception occurred while accessing user authorization info", e);
}
}