use of com.sun.identity.authentication.spi.AuthLoginException in project OpenAM by OpenRock.
the class Cert method getTokenFromSubjectAltExt.
private void getTokenFromSubjectAltExt(X509Certificate cert) throws AuthLoginException {
try {
X509CertImpl certImpl = new X509CertImpl(cert.getEncoded());
X509CertInfo cinfo = new X509CertInfo(certImpl.getTBSCertificate());
CertificateExtensions exts = (CertificateExtensions) cinfo.get(X509CertInfo.EXTENSIONS);
SubjectAlternativeNameExtension altNameExt = (SubjectAlternativeNameExtension) exts.get(SubjectAlternativeNameExtension.NAME);
if (altNameExt != null) {
GeneralNames names = (GeneralNames) altNameExt.get(SubjectAlternativeNameExtension.SUBJECT_NAME);
GeneralName generalname = null;
ObjectIdentifier upnoid = new ObjectIdentifier(UPNOID);
Iterator itr = (Iterator) names.iterator();
while ((userTokenId == null) && itr.hasNext()) {
generalname = (GeneralName) itr.next();
if (generalname != null) {
if (amAuthCert_subjectAltExtMapper.equalsIgnoreCase("UPN") && (generalname.getType() == GeneralNameInterface.NAME_ANY)) {
OtherName othername = (OtherName) generalname.getName();
if (upnoid.equals((Object) (othername.getOID()))) {
byte[] nval = othername.getNameValue();
DerValue derValue = new DerValue(nval);
userTokenId = derValue.getData().getUTF8String();
}
} else if (amAuthCert_subjectAltExtMapper.equalsIgnoreCase("RFC822Name") && (generalname.getType() == GeneralNameInterface.NAME_RFC822)) {
RFC822Name email = (RFC822Name) generalname.getName();
userTokenId = email.getName();
}
}
}
}
} catch (Exception e) {
debug.error("Certificate - " + "Error in getTokenFromSubjectAltExt = ", e);
throw new AuthLoginException(amAuthCert, "CertNoReg", null);
}
}
use of com.sun.identity.authentication.spi.AuthLoginException in project OpenAM by OpenRock.
the class Cert method doJCERevocationValidation.
private int doJCERevocationValidation(X509Certificate[] allCerts) throws AuthLoginException {
int ret = ISAuthConstants.LOGIN_IGNORE;
try {
Vector crls = new Vector();
for (X509Certificate cert : allCerts) {
X509CRL crl = AMCRLStore.getCRL(ldapParam, cert, amAuthCert_chkAttributesCRL);
if (crl != null) {
crls.add(crl);
}
}
if (debug.messageEnabled()) {
debug.message("Cert.doRevocationValidation: crls size = " + crls.size());
if (crls.size() > 0) {
debug.message("CRL = " + crls.toString());
}
}
AMCertPath certpath = new AMCertPath(crls);
if (!certpath.verify(allCerts, crlEnabled, ocspEnabled)) {
debug.error("CertPath:verify failed.");
return ret;
} else {
if (debug.messageEnabled()) {
debug.message("CertPath:verify success.");
}
}
ret = ISAuthConstants.LOGIN_SUCCEED;
} catch (Exception e) {
debug.error("Cert.doRevocationValidation: verify failed.", e);
}
return ret;
}
use of com.sun.identity.authentication.spi.AuthLoginException in project OpenAM by OpenRock.
the class SystemAppTokenProvider method getAppSSOToken.
/**
* Returns Application single sign on token.
*
* @return application single sign on token.
*/
public SSOToken getAppSSOToken() {
SSOToken ssoToken = null;
try {
AuthContext authContext = new AuthContext("/");
authContext.login(AuthContext.IndexType.MODULE_INSTANCE, MODULE_APPLICATION);
if (authContext.hasMoreRequirements()) {
Callback[] callbacks = authContext.getRequirements();
if (callbacks != null) {
addLoginCallbackMessage(callbacks, appUserName, appPassword);
authContext.submitRequirements(callbacks);
}
}
if (authContext.getStatus() == AuthContext.Status.SUCCESS) {
ssoToken = authContext.getSSOToken();
}
} catch (AuthLoginException ale) {
AdminTokenAction.debug.error("SystemAppTokenProvider.getAppSSOToken()", ale);
} catch (UnsupportedCallbackException usce) {
AdminTokenAction.debug.error("SystemAppTokenProvider.getAppSSOToken()", usce);
} catch (Exception e) {
AdminTokenAction.debug.error("SystemAppTokenProvider.getAppSSOToken()", e);
}
return ssoToken;
}
use of com.sun.identity.authentication.spi.AuthLoginException in project OpenAM by OpenRock.
the class AuthenticationServiceV1Test method shouldReturnErrorMessageWithoutTemplate.
@Test
public void shouldReturnErrorMessageWithoutTemplate() throws IOException {
// given
Request httpRequest = new Request();
AuthLoginException ale = new AuthLoginException("amAuth", "119", null);
RestAuthException exception = new RestAuthException(401, ale);
// when
String message = authServiceV1.getLocalizedMessage(httpRequest, exception);
// then
assertThat(message).isEqualTo("Invalid Auth Level.");
}
use of com.sun.identity.authentication.spi.AuthLoginException in project OpenAM by OpenRock.
the class AuthenticationServiceV1Test method shouldReturnFrenchErrorMessageFromException.
@Test
public void shouldReturnFrenchErrorMessageFromException() throws IOException {
// given
Request httpRequest = new Request();
AuthLoginException exception = new AuthLoginException("amAuth", "120", null);
httpRequest.getHeaders().put("Accept-Language", "fr-fr");
// when
String message = authServiceV1.getLocalizedMessage(httpRequest, exception);
// then
assertThat(message).isEqualTo("L’authentification sur module n’est pas autorisée.");
}
Aggregations