Search in sources :

Example 1 with RealmIdentityStore

use of fish.payara.security.realm.identitystores.RealmIdentityStore in project Payara by payara.

the class RealmExtension method findRealmIdentityStoreDefinitions.

/**
 * Find the
 * {@link RealmIdentityStoreDefinition} & {@link RealmIdentityStoreDefinitions}
 * annotation.
 *
 * @param <T>
 * @param eventIn
 * @param beanManager
 */
private <T> void findRealmIdentityStoreDefinitions(BeanManager beanManager, ProcessBean<T> event, Class<?> beanClass) {
    // get the identity store from the annotation (if it exists)
    Optional<RealmIdentityStoreDefinition> optionalStore = getAnnotation(beanManager, event.getAnnotated(), RealmIdentityStoreDefinition.class);
    optionalStore.ifPresent(definition -> {
        validateDefinition(definition);
        logActivatedIdentityStore(RealmIdentityStore.class, beanClass);
        identityStoreBeans.add(new CdiProducer<IdentityStore>().scope(ApplicationScoped.class).beanClass(IdentityStore.class).types(Object.class, IdentityStore.class).addToId(RealmIdentityStore.class + "-" + definition.value()).create(e -> {
            RealmIdentityStore mechanism = CDI.current().select(RealmIdentityStore.class).get();
            mechanism.setConfiguration(definition);
            return mechanism;
        }));
    });
    // get the identity store from the annotation (if it exists)
    Optional<RealmIdentityStoreDefinitions> optionalStores = getAnnotation(beanManager, event.getAnnotated(), RealmIdentityStoreDefinitions.class);
    optionalStores.ifPresent(definitions -> {
        for (RealmIdentityStoreDefinition definition : definitions.value()) {
            validateDefinition(definition);
            logActivatedIdentityStore(RealmIdentityStore.class, beanClass);
            identityStoreBeans.add(new CdiProducer<IdentityStore>().scope(ApplicationScoped.class).beanClass(IdentityStore.class).types(Object.class, IdentityStore.class).addToId(RealmIdentityStore.class + "-" + definition.value()).create(e -> {
                RealmIdentityStore mechanism = CDI.current().select(RealmIdentityStore.class).get();
                mechanism.setConfiguration(definition);
                return mechanism;
            }));
        }
    });
}
Also used : AfterBeanDiscovery(javax.enterprise.inject.spi.AfterBeanDiscovery) RealmConfiguration(fish.payara.security.realm.config.RealmConfiguration) ProcessBean(javax.enterprise.inject.spi.ProcessBean) FileRealmIdentityStore(fish.payara.security.realm.identitystores.FileRealmIdentityStore) SolarisRealmIdentityStore(fish.payara.security.realm.identitystores.SolarisRealmIdentityStore) SolarisIdentityStoreDefinition(fish.payara.security.annotations.SolarisIdentityStoreDefinition) BeforeBeanDiscovery(javax.enterprise.inject.spi.BeforeBeanDiscovery) Observes(javax.enterprise.event.Observes) PamRealmIdentityStoreConfiguration(fish.payara.security.realm.config.PamRealmIdentityStoreConfiguration) JAAS_CONTEXT(fish.payara.security.realm.RealmUtil.JAAS_CONTEXT) RealmIdentityStoreDefinitions(fish.payara.security.annotations.RealmIdentityStoreDefinitions) Extension(javax.enterprise.inject.spi.Extension) Set(java.util.Set) CDI(javax.enterprise.inject.spi.CDI) Logger(java.util.logging.Logger) SolarisRealmIdentityStoreConfiguration(fish.payara.security.realm.config.SolarisRealmIdentityStoreConfiguration) List(java.util.List) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Pattern(java.util.regex.Pattern) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) PamRealmIdentityStore(fish.payara.security.realm.identitystores.PamRealmIdentityStore) Bean(javax.enterprise.inject.spi.Bean) RealmIdentityStoreDefinition(fish.payara.security.annotations.RealmIdentityStoreDefinition) RealmIdentityStore(fish.payara.security.realm.identitystores.RealmIdentityStore) FileIdentityStoreDefinition(fish.payara.security.annotations.FileIdentityStoreDefinition) Globals(org.glassfish.internal.api.Globals) FileRealmIdentityStoreConfiguration(fish.payara.security.realm.config.FileRealmIdentityStoreConfiguration) INFO(java.util.logging.Level.INFO) IdentityStore(javax.security.enterprise.identitystore.IdentityStore) CdiProducer(org.glassfish.soteria.cdi.CdiProducer) CertificateIdentityStoreDefinition(fish.payara.security.annotations.CertificateIdentityStoreDefinition) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CertificateAuthenticationMechanism(fish.payara.security.realm.mechanisms.CertificateAuthenticationMechanism) AuthRealm(com.sun.enterprise.config.serverbeans.AuthRealm) NoSuchRealmException(com.sun.enterprise.security.auth.realm.NoSuchRealmException) StringUtils(com.sun.enterprise.util.StringUtils) ASSIGN_GROUPS(fish.payara.security.realm.RealmUtil.ASSIGN_GROUPS) HttpAuthenticationMechanism(javax.security.enterprise.authentication.mechanism.http.HttpAuthenticationMechanism) SecurityService(com.sun.enterprise.config.serverbeans.SecurityService) CertificateAuthenticationMechanismDefinition(fish.payara.security.annotations.CertificateAuthenticationMechanismDefinition) Properties(java.util.Properties) CertificateRealmIdentityStoreConfiguration(fish.payara.security.realm.config.CertificateRealmIdentityStoreConfiguration) Realm(com.sun.enterprise.security.auth.realm.Realm) CertificateRealmIdentityStore(fish.payara.security.realm.identitystores.CertificateRealmIdentityStore) PamIdentityStoreDefinition(fish.payara.security.annotations.PamIdentityStoreDefinition) CdiUtils.getAnnotation(org.glassfish.soteria.cdi.CdiUtils.getAnnotation) BeanManager(javax.enterprise.inject.spi.BeanManager) RealmUtil(fish.payara.security.realm.RealmUtil) FileRealmIdentityStore(fish.payara.security.realm.identitystores.FileRealmIdentityStore) SolarisRealmIdentityStore(fish.payara.security.realm.identitystores.SolarisRealmIdentityStore) PamRealmIdentityStore(fish.payara.security.realm.identitystores.PamRealmIdentityStore) RealmIdentityStore(fish.payara.security.realm.identitystores.RealmIdentityStore) CertificateRealmIdentityStore(fish.payara.security.realm.identitystores.CertificateRealmIdentityStore) RealmIdentityStoreDefinition(fish.payara.security.annotations.RealmIdentityStoreDefinition) CdiProducer(org.glassfish.soteria.cdi.CdiProducer) RealmIdentityStoreDefinitions(fish.payara.security.annotations.RealmIdentityStoreDefinitions) ApplicationScoped(javax.enterprise.context.ApplicationScoped) FileRealmIdentityStore(fish.payara.security.realm.identitystores.FileRealmIdentityStore) SolarisRealmIdentityStore(fish.payara.security.realm.identitystores.SolarisRealmIdentityStore) PamRealmIdentityStore(fish.payara.security.realm.identitystores.PamRealmIdentityStore) RealmIdentityStore(fish.payara.security.realm.identitystores.RealmIdentityStore) IdentityStore(javax.security.enterprise.identitystore.IdentityStore) CertificateRealmIdentityStore(fish.payara.security.realm.identitystores.CertificateRealmIdentityStore)

Aggregations

AuthRealm (com.sun.enterprise.config.serverbeans.AuthRealm)1 SecurityService (com.sun.enterprise.config.serverbeans.SecurityService)1 NoSuchRealmException (com.sun.enterprise.security.auth.realm.NoSuchRealmException)1 Realm (com.sun.enterprise.security.auth.realm.Realm)1 StringUtils (com.sun.enterprise.util.StringUtils)1 CertificateAuthenticationMechanismDefinition (fish.payara.security.annotations.CertificateAuthenticationMechanismDefinition)1 CertificateIdentityStoreDefinition (fish.payara.security.annotations.CertificateIdentityStoreDefinition)1 FileIdentityStoreDefinition (fish.payara.security.annotations.FileIdentityStoreDefinition)1 PamIdentityStoreDefinition (fish.payara.security.annotations.PamIdentityStoreDefinition)1 RealmIdentityStoreDefinition (fish.payara.security.annotations.RealmIdentityStoreDefinition)1 RealmIdentityStoreDefinitions (fish.payara.security.annotations.RealmIdentityStoreDefinitions)1 SolarisIdentityStoreDefinition (fish.payara.security.annotations.SolarisIdentityStoreDefinition)1 RealmUtil (fish.payara.security.realm.RealmUtil)1 ASSIGN_GROUPS (fish.payara.security.realm.RealmUtil.ASSIGN_GROUPS)1 JAAS_CONTEXT (fish.payara.security.realm.RealmUtil.JAAS_CONTEXT)1 CertificateRealmIdentityStoreConfiguration (fish.payara.security.realm.config.CertificateRealmIdentityStoreConfiguration)1 FileRealmIdentityStoreConfiguration (fish.payara.security.realm.config.FileRealmIdentityStoreConfiguration)1 PamRealmIdentityStoreConfiguration (fish.payara.security.realm.config.PamRealmIdentityStoreConfiguration)1 RealmConfiguration (fish.payara.security.realm.config.RealmConfiguration)1 SolarisRealmIdentityStoreConfiguration (fish.payara.security.realm.config.SolarisRealmIdentityStoreConfiguration)1