Search in sources :

Example 1 with CertificateCredential

use of fish.payara.security.api.CertificateCredential in project Payara by payara.

the class CertificateRealmIdentityStore method validate.

public static CredentialValidationResult validate(CertificateCredential credential, String realmName) {
    try {
        Subject subject = login(credential, realmName);
        Set<String> groups = subject.getPrincipals(Group.class).stream().map(g -> g.getName()).collect(toSet());
        return new CredentialValidationResult(credential.getPrincipal(), groups);
    } catch (LoginException ex) {
        return INVALID_RESULT;
    }
}
Also used : X509Certificate(java.security.cert.X509Certificate) Properties(java.util.Properties) NOT_VALIDATED_RESULT(javax.security.enterprise.identitystore.CredentialValidationResult.NOT_VALIDATED_RESULT) LoginException(com.sun.enterprise.security.auth.login.common.LoginException) Set(java.util.Set) Typed(javax.enterprise.inject.Typed) IdentityStore(javax.security.enterprise.identitystore.IdentityStore) Group(org.glassfish.security.common.Group) ClientCertificateLoginModule(com.sun.enterprise.security.auth.login.ClientCertificateLoginModule) CertificateRealmIdentityStoreConfiguration(fish.payara.security.realm.config.CertificateRealmIdentityStoreConfiguration) CertificateIdentityStoreDefinition(fish.payara.security.annotations.CertificateIdentityStoreDefinition) Subject(javax.security.auth.Subject) Realm(com.sun.enterprise.security.auth.realm.Realm) CredentialValidationResult(javax.security.enterprise.identitystore.CredentialValidationResult) INVALID_RESULT(javax.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT) Arrays.asList(java.util.Arrays.asList) ASSIGN_GROUPS(fish.payara.security.realm.RealmUtil.ASSIGN_GROUPS) Credential(javax.security.enterprise.credential.Credential) WebAndEjbToJaasBridge(com.sun.enterprise.security.auth.WebAndEjbToJaasBridge) CertificateCredential(fish.payara.security.api.CertificateCredential) CertificateRealm(com.sun.enterprise.security.auth.realm.certificate.CertificateRealm) Collectors.toSet(java.util.stream.Collectors.toSet) RealmUtil(fish.payara.security.realm.RealmUtil) Group(org.glassfish.security.common.Group) CredentialValidationResult(javax.security.enterprise.identitystore.CredentialValidationResult) LoginException(com.sun.enterprise.security.auth.login.common.LoginException) Subject(javax.security.auth.Subject)

Aggregations

WebAndEjbToJaasBridge (com.sun.enterprise.security.auth.WebAndEjbToJaasBridge)1 ClientCertificateLoginModule (com.sun.enterprise.security.auth.login.ClientCertificateLoginModule)1 LoginException (com.sun.enterprise.security.auth.login.common.LoginException)1 Realm (com.sun.enterprise.security.auth.realm.Realm)1 CertificateRealm (com.sun.enterprise.security.auth.realm.certificate.CertificateRealm)1 CertificateIdentityStoreDefinition (fish.payara.security.annotations.CertificateIdentityStoreDefinition)1 CertificateCredential (fish.payara.security.api.CertificateCredential)1 RealmUtil (fish.payara.security.realm.RealmUtil)1 ASSIGN_GROUPS (fish.payara.security.realm.RealmUtil.ASSIGN_GROUPS)1 CertificateRealmIdentityStoreConfiguration (fish.payara.security.realm.config.CertificateRealmIdentityStoreConfiguration)1 X509Certificate (java.security.cert.X509Certificate)1 Arrays.asList (java.util.Arrays.asList)1 Properties (java.util.Properties)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Typed (javax.enterprise.inject.Typed)1 Subject (javax.security.auth.Subject)1 Credential (javax.security.enterprise.credential.Credential)1 CredentialValidationResult (javax.security.enterprise.identitystore.CredentialValidationResult)1 INVALID_RESULT (javax.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT)1