security/subsystem/src/main/java/org/jboss/as/security/elytron/ElytronIntegrationResourceDefinitions.java
public static ResourceDefinition getElytronTrustManagersResourceDefinition() {
        final AttributeDefinition[] attributes = new AttributeDefinition[] {LEGACY_JSSE_CONFIG};
        final AbstractAddStepHandler addHandler = new BasicAddHandler<TrustManager>(attributes, TRUST_MANAGER_RUNTIME_CAPABILITY) {

            @Override
            protected BasicService.ValueSupplier<TrustManager> getValueSupplier(ServiceBuilder<TrustManager> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException {
                final String legacyJSSEConfig = asStringIfDefined(context, LEGACY_JSSE_CONFIG, model);
                final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>();
                if (legacyJSSEConfig != null) {
                    serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJSSEConfig), SecurityDomainContext.class, securityDomainContextInjector);
                }

                return () -> {
                    final SecurityDomainContext domainContext = securityDomainContextInjector.getValue();
                    final JSSESecurityDomain jsseDomain = domainContext.getJSSE();
                    if (jsseDomain == null) {
                        throw SecurityLogger.ROOT_LOGGER.unableToLocateJSSEConfig(legacyJSSEConfig);
                    }
                    final TrustManager[] trustManagers = jsseDomain.getTrustManagers();
                    if (trustManagers == null) {
                        throw SecurityLogger.ROOT_LOGGER.unableToLocateComponentInJSSEDomain("TrustManager", legacyJSSEConfig);
                    }
                    for (TrustManager trustManager : trustManagers) {
                        if (trustManager instanceof X509ExtendedTrustManager)
                            return trustManager;
                    }
                    throw SecurityLogger.ROOT_LOGGER.expectedManagerTypeNotFound("TrustManager", X509ExtendedTrustManager.class.getSimpleName(), legacyJSSEConfig);
                };
            }
        };

        return new BasicResourceDefinition(Constants.ELYTRON_TRUST_MANAGER, addHandler, attributes, TRUST_MANAGER_RUNTIME_CAPABILITY);
    }
public static ResourceDefinition getElytronTrustManagersResourceDefinition() {
        final AttributeDefinition[] attributes = new AttributeDefinition[] {LEGACY_JSSE_CONFIG};
        final AbstractAddStepHandler addHandler = new BasicAddHandler<TrustManager>(attributes, TRUST_MANAGER_RUNTIME_CAPABILITY) {

            @Override
            protected BasicService.ValueSupplier<TrustManager> getValueSupplier(ServiceBuilder<TrustManager> serviceBuilder, OperationContext context, ModelNode model) throws OperationFailedException {
                final String legacyJSSEConfig = asStringIfDefined(context, LEGACY_JSSE_CONFIG, model);
                final InjectedValue<SecurityDomainContext> securityDomainContextInjector = new InjectedValue<>();
                if (legacyJSSEConfig != null) {
                    serviceBuilder.addDependency(SecurityDomainService.SERVICE_NAME.append(legacyJSSEConfig), SecurityDomainContext.class, securityDomainContextInjector);
                }

                return () -> {
                    final SecurityDomainContext domainContext = securityDomainContextInjector.getValue();
                    final JSSESecurityDomain jsseDomain = domainContext.getJSSE();
                    if (jsseDomain == null) {
                        throw SecurityLogger.ROOT_LOGGER.unableToLocateJSSEConfig(legacyJSSEConfig);
                    }
                    final TrustManager[] trustManagers = jsseDomain.getTrustManagers();
                    if (trustManagers == null) {
                        throw SecurityLogger.ROOT_LOGGER.unableToLocateComponentInJSSEDomain("TrustManager", legacyJSSEConfig);
                    }
                    for (TrustManager trustManager : trustManagers) {
                        if (trustManager instanceof X509ExtendedTrustManager)
                            return trustManager;
                    }
                    throw SecurityLogger.ROOT_LOGGER.expectedManagerTypeNotFound("TrustManager", X509ExtendedTrustManager.class.getSimpleName(), legacyJSSEConfig);
                };
            }
        };

        return new BasicResourceDefinition(Constants.ELYTRON_TRUST_MANAGER, addHandler, attributes, TRUST_MANAGER_RUNTIME_CAPABILITY);
    }
public static ResourceDefinition getElytronTrustManagersResourceDefinition ( ) { final AttributeDefinition [ ] attributes = new AttributeDefinition [ ] { LEGACY_JSSE_CONFIG } ; final AbstractAddStepHandler addHandler = new BasicAddHandler < TrustManager > ( attributes , TRUST_MANAGER_RUNTIME_CAPABILITY ) { @ Override protected BasicService . ValueSupplier < TrustManager > getValueSupplier ( ServiceBuilder < TrustManager > serviceBuilder , OperationContext context , ModelNode model ) throws OperationFailedException { final String legacyJSSEConfig = asStringIfDefined ( context , LEGACY_JSSE_CONFIG , model ) ; final InjectedValue < SecurityDomainContext > securityDomainContextInjector = new InjectedValue <> ( ) ; if ( legacyJSSEConfig != null ) { serviceBuilder . addDependency ( SecurityDomainService . SERVICE_NAME . append ( legacyJSSEConfig ) , SecurityDomainContext . class , securityDomainContextInjector ) ; } return ( ) -> { final SecurityDomainContext domainContext = securityDomainContextInjector . getValue ( ) ; final JSSESecurityDomain jsseDomain = domainContext . getJSSE ( ) ; if ( jsseDomain == null ) { throw SecurityLogger . ROOT_LOGGER . unableToLocateJSSEConfig ( legacyJSSEConfig ) ; } final TrustManager [ ] trustManagers = jsseDomain . getTrustManagers ( ) ; if ( trustManagers == null ) { throw SecurityLogger . ROOT_LOGGER . unableToLocateComponentInJSSEDomain ( "TrustManager" , legacyJSSEConfig ) ; } for ( TrustManager trustManager : trustManagers ) { if ( trustManager instanceof X509ExtendedTrustManager ) return trustManager ; } throw SecurityLogger . ROOT_LOGGER . expectedManagerTypeNotFound ( "TrustManager" , X509ExtendedTrustManager . class . getSimpleName ( ) , legacyJSSEConfig ) ; } ; } } ; return new BasicResourceDefinition ( Constants . ELYTRON_TRUST_MANAGER , addHandler , attributes , TRUST_MANAGER_RUNTIME_CAPABILITY ) ; }
Defines a resource that represents Elytron-compatible trust managers that can be exported by a JSSE-enabled domain
in the legacy security subsystem.

To export the trust managers the resource uses a {@code BasicAddHandler} implementation that registers the elytron
trust-managers capability and implements a {@code org.jboss.as.security.elytron.BasicService.ValueSupplier} that uses
the injected {@code SecurityDomainContext} to obtain a {@code JSSESecurityDomain}. If such domain is found, its
configured trust manager array is obtained and returned.

The {@code ValueSupplier} implementation throws an exception if the referenced legacy domain is not a JSSE-enabled
domain or if the domain doesn't contain a trust store configuration that can be used to build the trust managers.

NOTE: The {@code PicketBox} implementation of a {@code JSSESecurityDomain} returns a reference to the key store if
a trust store was not configured. This means that the trust managers that it builds will use the configured key store
instead of throwing an exception to alert about a missing trust store configuration. So extra care must be taken
to ensure that the exported trust managers are being built using the correct trust stores.
Defines a resource that represents Elytron - compatible trust managers that can be exported by a JSSE - enabled domain in the legacy security subsystem .