Search in sources :

Example 1 with FileRealmIdentityStore

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

the class RealmExtension method findFileIdentityStoreDefinitions.

/**
 * Find the
 * {@link FileIdentityStoreDefinition} & {@link FileIdentityStoreDefinitions}
 * annotation.
 *
 * @param <T>
 * @param eventIn
 * @param beanManager
 */
private <T> void findFileIdentityStoreDefinitions(BeanManager beanManager, ProcessBean<T> event, Class<?> beanClass) {
    // get the identity store from the annotation (if it exists)
    Optional<FileIdentityStoreDefinition> optionalStore = getAnnotation(beanManager, event.getAnnotated(), FileIdentityStoreDefinition.class);
    optionalStore.ifPresent(definition -> {
        validateDefinition(definition.value(), FileRealmIdentityStore.REALM_CLASS, definition.jaasContext());
        logActivatedIdentityStore(FileRealmIdentityStore.class, beanClass);
        FileRealmIdentityStoreConfiguration configuration = FileRealmIdentityStoreConfiguration.from(definition);
        Properties props = new Properties();
        props.put("file", configuration.getFile());
        props.put(JAAS_CONTEXT, configuration.getJaasContext());
        createRealm(configuration, FileRealmIdentityStore.REALM_CLASS, FileRealmIdentityStore.REALM_LOGIN_MODULE_CLASS, props);
        identityStoreBeans.add(new CdiProducer<IdentityStore>().scope(ApplicationScoped.class).beanClass(IdentityStore.class).types(Object.class, IdentityStore.class).addToId(FileRealmIdentityStore.class).create(e -> {
            FileRealmIdentityStore mechanism = CDI.current().select(FileRealmIdentityStore.class).get();
            mechanism.init(configuration);
            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) FileIdentityStoreDefinition(fish.payara.security.annotations.FileIdentityStoreDefinition) FileRealmIdentityStoreConfiguration(fish.payara.security.realm.config.FileRealmIdentityStoreConfiguration) CdiProducer(org.glassfish.soteria.cdi.CdiProducer) Properties(java.util.Properties) 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) FileRealmIdentityStore(fish.payara.security.realm.identitystores.FileRealmIdentityStore)

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