use of org.wildfly.security.auth.server.SecurityRealm in project wildfly by wildfly.
the class ElytronIntegrationResourceDefinitions method getElytronRealmResourceDefinition.
/**
* Defines a resource that represents an Elytron-compatible realm that can be exported by the legacy security subsystem.
* The constructed {@code SecurityRealm} wraps a legacy {@code SecurityDomainContext} and delegates authentication
* decisions to that context.
*
* To export the realm the resource uses a {@code BasicAddHandler} implementation that registers the security-realm
* capability and implements a {@code org.jboss.as.security.elytron.BasicService.ValueSupplier} that uses the injected
* {@code SecurityDomainContext} to create and return an instance of {@code SecurityDomainContextRealm}.
*/
public static ResourceDefinition getElytronRealmResourceDefinition() {
final AttributeDefinition[] attributes = new AttributeDefinition[] { LEGACY_JAAS_CONFIG };
final AbstractAddStepHandler addHandler = new BasicAddHandler<SecurityRealm>(attributes, SECURITY_REALM_RUNTIME_CAPABILITY) {
@Override
protected BasicService.ValueSupplier<SecurityRealm> getValueSupplier(ServiceBuilder<SecurityRealm> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException {
final String legacyJAASConfig = asStringIfDefined(context, LEGACY_JAAS_CONFIG, model);
final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>();
if (legacyJAASConfig != null) {
serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJAASConfig), SecurityDomainContext.class, securityDomainContextInjector);
}
return () -> {
final SecurityDomainContext domainContext = securityDomainContextInjector.getValue();
return new SecurityDomainContextRealm(domainContext);
};
}
};
return new BasicResourceDefinition(Constants.ELYTRON_REALM, addHandler, attributes, SECURITY_REALM_RUNTIME_CAPABILITY);
}
Aggregations