use of fish.payara.security.annotations.FileIdentityStoreDefinition 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;
}));
});
}
Aggregations