security/subsystem/src/main/java/org/jboss/as/security/elytron/ElytronIntegrationResourceDefinitions.java
public static ResourceDefinition getElytronRealmResourceDefinition() {

        final AttributeDefinition[] attributes = new AttributeDefinition[] {LEGACY_JAAS_CONFIG, APPLY_ROLE_MAPPERS};
        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 boolean applyRoleMappers = APPLY_ROLE_MAPPERS.resolveModelAttribute(context, model).asBoolean();
                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, applyRoleMappers);
                };
            }
        };

        return new BasicResourceDefinition(Constants.ELYTRON_REALM, addHandler, attributes, SECURITY_REALM_RUNTIME_CAPABILITY);
    }
public static ResourceDefinition getElytronRealmResourceDefinition() {

        final AttributeDefinition[] attributes = new AttributeDefinition[] {LEGACY_JAAS_CONFIG, APPLY_ROLE_MAPPERS};
        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 boolean applyRoleMappers = APPLY_ROLE_MAPPERS.resolveModelAttribute(context, model).asBoolean();
                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, applyRoleMappers);
                };
            }
        };

        return new BasicResourceDefinition(Constants.ELYTRON_REALM, addHandler, attributes, SECURITY_REALM_RUNTIME_CAPABILITY);
    }
public static ResourceDefinition getElytronRealmResourceDefinition ( ) { final AttributeDefinition [ ] attributes = new AttributeDefinition [ ] { LEGACY_JAAS_CONFIG , APPLY_ROLE_MAPPERS } ; 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 boolean applyRoleMappers = APPLY_ROLE_MAPPERS . resolveModelAttribute ( context , model ) . asBoolean ( ) ; 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 , applyRoleMappers ) ; } ; } } ; return new BasicResourceDefinition ( Constants . ELYTRON_REALM , addHandler , attributes , SECURITY_REALM_RUNTIME_CAPABILITY ) ; }
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}.
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 .