public static ResourceDefinition getElytronKeyManagersResourceDefinition ( ) { final AttributeDefinition [ ] attributes = new AttributeDefinition [ ] { LEGACY_JSSE_CONFIG } ; final AbstractAddStepHandler addHandler = new BasicAddHandler < KeyManager > ( attributes , KEY_MANAGER_RUNTIME_CAPABILITY ) { @ Override protected BasicService . ValueSupplier < KeyManager > getValueSupplier ( ServiceBuilder < KeyManager > 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 KeyManager [ ] keyManagers = jsseDomain . getKeyManagers ( ) ; if ( keyManagers == null ) { throw SecurityLogger . ROOT_LOGGER . unableToLocateComponentInJSSEDomain ( "KeyManager" , legacyJSSEConfig ) ; } for ( KeyManager keyManager : keyManagers ) { if ( keyManager instanceof X509ExtendedKeyManager ) { return keyManager ; } } throw SecurityLogger . ROOT_LOGGER . expectedManagerTypeNotFound ( "KeyManager" , X509ExtendedKeyManager . class . getSimpleName ( ) , legacyJSSEConfig ) ; } ; } } ; return new BasicResourceDefinition ( Constants . ELYTRON_KEY_MANAGER , addHandler , attributes , KEY_MANAGER_RUNTIME_CAPABILITY ) ; }
Defines a resource that represents Elytron - compatible key managers that can be exported by a JSSE - enabled domain in the legacy security subsystem .