Search in sources :

Example 1 with CredentialNotFoundException

use of javax.security.auth.login.CredentialNotFoundException in project tomee by apache.

the class TomcatSecurityService method login.

public UUID login(final String realmName, final String username, final String password) throws LoginException {
    final Realm realm = findRealm(realmName);
    if (realm == null) {
        throw new LoginException("No Tomcat realm available");
    }
    final Principal principal = realm.authenticate(username, password);
    if (principal == null) {
        throw new CredentialNotFoundException(username);
    }
    final Subject subject = createSubject(realm, principal);
    return registerSubject(subject);
}
Also used : LoginException(javax.security.auth.login.LoginException) Realm(org.apache.catalina.Realm) CredentialNotFoundException(javax.security.auth.login.CredentialNotFoundException) GenericPrincipal(org.apache.catalina.realm.GenericPrincipal) CallerPrincipal(org.apache.openejb.spi.CallerPrincipal) Principal(java.security.Principal) Subject(javax.security.auth.Subject)

Aggregations

Principal (java.security.Principal)1 Subject (javax.security.auth.Subject)1 CredentialNotFoundException (javax.security.auth.login.CredentialNotFoundException)1 LoginException (javax.security.auth.login.LoginException)1 Realm (org.apache.catalina.Realm)1 GenericPrincipal (org.apache.catalina.realm.GenericPrincipal)1 CallerPrincipal (org.apache.openejb.spi.CallerPrincipal)1