use of org.ovirt.engine.core.sso.utils.Credentials in project ovirt-engine by oVirt.
the class InteractiveChangePasswdServlet method getUserCredentials.
private Credentials getUserCredentials(HttpServletRequest request) throws AuthenticationException {
try {
String username = SsoUtils.getFormParameter(request, USERNAME);
String credentials = SsoUtils.getFormParameter(request, CREDENTIALS);
String credentialsNew1 = SsoUtils.getFormParameter(request, CREDENTIALS_NEW1);
String credentialsNew2 = SsoUtils.getFormParameter(request, CREDENTIALS_NEW2);
String profile = SsoUtils.getFormParameter(request, PROFILE);
return StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(credentials) && StringUtils.isNotEmpty(credentialsNew1) && StringUtils.isNotEmpty(credentialsNew2) && StringUtils.isNotEmpty(profile) ? new Credentials(username, credentials, credentialsNew1, credentialsNew2, profile) : null;
} catch (Exception ex) {
throw new AuthenticationException(ssoContext.getLocalizationUtils().localize(SsoConstants.APP_ERROR_UNABLE_TO_EXTRACT_CREDENTIALS, (Locale) request.getAttribute(SsoConstants.LOCALE)), ex);
}
}
use of org.ovirt.engine.core.sso.utils.Credentials in project ovirt-engine by oVirt.
the class OAuthTokenServlet method issueTokenForPasswd.
protected void issueTokenForPasswd(HttpServletRequest request, HttpServletResponse response, String scope) throws Exception {
log.debug("Entered issueTokenForPasswd");
Credentials credentials = null;
try {
credentials = getCredentials(request);
SsoSession ssoSession = handleIssueTokenForPasswd(request, scope, credentials);
log.debug("Sending json response");
SsoUtils.sendJsonData(response, buildResponse(ssoSession));
} catch (AuthenticationException ex) {
String profile = "N/A";
if (credentials != null) {
profile = credentials.getProfile() == null ? "N/A" : credentials.getProfile();
}
throw new AuthenticationException(String.format(ssoContext.getLocalizationUtils().localize(SsoConstants.APP_ERROR_CANNOT_AUTHENTICATE_USER_IN_DOMAIN, (Locale) request.getAttribute(SsoConstants.LOCALE)), credentials == null ? "N/A" : credentials.getUsername(), profile, ex.getMessage()));
}
}
use of org.ovirt.engine.core.sso.utils.Credentials in project ovirt-engine by oVirt.
the class InteractiveAuthServlet method getUserCredentials.
private Credentials getUserCredentials(HttpServletRequest request) throws Exception {
String username = SsoUtils.getFormParameter(request, USERNAME);
String password = SsoUtils.getFormParameter(request, PASSWORD);
String profile = SsoUtils.getFormParameter(request, PROFILE);
Credentials credentials;
// we extract the credentials from the credentials saved to sso session.
if (username == null || password == null || profile == null) {
credentials = SsoUtils.getSsoSession(request).getTempCredentials();
} else {
credentials = new Credentials(username, password, profile, ssoContext.getSsoProfiles().contains(profile));
}
return credentials;
}
use of org.ovirt.engine.core.sso.utils.Credentials in project ovirt-engine by oVirt.
the class OpenIdTokenServlet method issueTokenForPasswd.
protected void issueTokenForPasswd(HttpServletRequest request, HttpServletResponse response, String scope) throws Exception {
log.debug("Entered issueTokenForPasswd");
Credentials credentials = null;
try {
String[] clientIdAndSecret = SsoUtils.getClientIdClientSecret(request);
SsoUtils.validateClientRequest(request, clientIdAndSecret[0], clientIdAndSecret[1], scope, null);
String clientId = clientIdAndSecret[0];
String clientSecret = clientIdAndSecret[1];
credentials = getCredentials(request);
SsoSession ssoSession = handleIssueTokenForPasswd(request, scope, credentials);
log.debug("Sending json response");
SsoUtils.sendJsonData(response, buildResponse(request, ssoSession, clientId, clientSecret));
} catch (AuthenticationException ex) {
String profile = "N/A";
if (credentials != null) {
profile = credentials.getProfile() == null ? "N/A" : credentials.getProfile();
}
throw new AuthenticationException(String.format(ssoContext.getLocalizationUtils().localize(SsoConstants.APP_ERROR_CANNOT_AUTHENTICATE_USER_IN_DOMAIN, (Locale) request.getAttribute(SsoConstants.LOCALE)), credentials == null ? "N/A" : credentials.getUsername(), profile, ex.getMessage()));
}
}
Aggregations