Java Code Examples for org.jboss.as.controller.OperationContext#getServiceTarget()
The following examples show how to use
org.jboss.as.controller.OperationContext#getServiceTarget() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemotingHttpUpgradeService.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installServices(final OperationContext context, final String remotingConnectorName, final String httpConnectorName, final ServiceName endpointName, final OptionMap connectorPropertiesOptionMap, final String securityRealm, final String saslAuthenticationFactory) { final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName serviceName = UPGRADE_SERVICE_NAME.append(remotingConnectorName); final ServiceBuilder<?> sb = serviceTarget.addService(serviceName); final Consumer<RemotingHttpUpgradeService> serviceConsumer = sb.provides(serviceName); final Supplier<ChannelUpgradeHandler> urSupplier = sb.requires(HTTP_UPGRADE_REGISTRY.append(httpConnectorName)); final Supplier<ListenerRegistry> lrSupplier = sb.requires(RemotingServices.HTTP_LISTENER_REGISTRY); final Supplier<Endpoint> eSupplier = sb.requires(endpointName); final Supplier<org.jboss.as.domain.management.SecurityRealm> srSupplier = securityRealm != null ? sb.requires(org.jboss.as.domain.management.SecurityRealm.ServiceUtil.createServiceName(securityRealm)) : null; final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? sb.requires(context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactory, SaslAuthenticationFactory.class)) : null; sb.setInstance(new RemotingHttpUpgradeService(serviceConsumer, urSupplier, lrSupplier, eSupplier, srSupplier, safSupplier, httpConnectorName, endpointName.getSimpleName(), connectorPropertiesOptionMap)); sb.setInitialMode(ServiceController.Mode.PASSIVE); sb.install(); }
Example 2
Source File: SecureServerDefinition.java From keycloak with Apache License 2.0 | 6 votes |
static void installCapability(OperationContext context, ModelNode operation) throws OperationFailedException { PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); String factoryName = pathAddress.getLastElement().getValue(); ServiceName serviceName = context.getCapabilityServiceName(HTTP_SERVER_AUTHENTICATION_CAPABILITY, factoryName, HttpServerAuthenticationMechanismFactory.class); boolean publicClient = SecureServerDefinition.PUBLIC_CLIENT.resolveModelAttribute(context, operation).asBoolean(false); if (!publicClient) { throw new OperationFailedException("Only public clients are allowed to have their configuration exposed through the management interface"); } KeycloakHttpAuthenticationFactoryService service = new KeycloakHttpAuthenticationFactoryService(factoryName); ServiceTarget serviceTarget = context.getServiceTarget(); InjectedValue<ExtensibleHttpManagement> injectedValue = new InjectedValue<>(); serviceTarget.addService(serviceName.append("http-management-context"), createHttpManagementConfigContextService(factoryName, injectedValue)) .addDependency(context.getCapabilityServiceName(HTTP_MANAGEMENT_HTTP_EXTENSIBLE_CAPABILITY, ExtensibleHttpManagement.class), ExtensibleHttpManagement.class, injectedValue).setInitialMode(Mode.ACTIVE).install(); serviceTarget.addService(serviceName, service).setInitialMode(Mode.ACTIVE).install(); }
Example 3
Source File: LdapRealmDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); String address = context.getCurrentAddressValue(); ServiceName mainServiceName = MODIFIABLE_SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName(); ServiceName aliasServiceName = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(address).getCapabilityServiceName(); final LdapSecurityRealmBuilder builder = LdapSecurityRealmBuilder.builder(); if (DIRECT_VERIFICATION.resolveModelAttribute(context, model).asBoolean()) { boolean allowBlankPassword = ALLOW_BLANK_PASSWORD.resolveModelAttribute(context, model).asBoolean(); builder.addDirectEvidenceVerification(allowBlankPassword); } TrivialService<SecurityRealm> ldapRealmService = new TrivialService<>(builder::build); ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(mainServiceName, ldapRealmService) .addAliases(aliasServiceName); commonDependencies(serviceBuilder); configureIdentityMapping(context, model, builder); configureDirContext(context, model, builder, serviceBuilder); serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install(); }
Example 4
Source File: AggregateComponentDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<?> instanceRuntimeCapability = runtimeCapability.fromBaseCapability(context.getCurrentAddressValue()); ServiceName componentName = instanceRuntimeCapability.getCapabilityServiceName(aggregationType); AggregateComponentService<T> aggregateComponentService = new AggregateComponentService<T>(aggregationType, aggregator); ServiceBuilder<T> serviceBuilder = serviceTarget.addService(componentName, aggregateComponentService); List<String> aggregates = aggregateReferences.unwrap(context, model); String baseCapabilityName = runtimeCapability.getName(); for (String current : aggregates) { String runtimeCapabilityName = RuntimeCapability.buildDynamicCapabilityName(baseCapabilityName, current); ServiceName realmServiceName = context.getCapabilityServiceName(runtimeCapabilityName, aggregationType); serviceBuilder.addDependency(realmServiceName, aggregationType, aggregateComponentService.newInjector()); } commonDependencies(serviceBuilder, true, dependOnProviderRegistration) .setInitialMode(Mode.LAZY) .install(); }
Example 5
Source File: RoleDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = ROLE_DECODER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName roleDecoderName = runtimeCapability.getCapabilityServiceName(RoleDecoder.class); final String attribute = ATTRIBUTE.resolveModelAttribute(context, model).asString(); TrivialService<RoleDecoder> roleDecoderService = new TrivialService<RoleDecoder>(() -> RoleDecoder.simple(attribute)); ServiceBuilder<RoleDecoder> roleDecoderBuilderBuilder = serviceTarget.addService(roleDecoderName, roleDecoderService); commonDependencies(roleDecoderBuilderBuilder) .setInitialMode(Mode.LAZY) .install(); }
Example 6
Source File: RoleDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = ROLE_DECODER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName roleDecoderName = runtimeCapability.getCapabilityServiceName(RoleDecoder.class); final String sourceAddress = SOURCE_ADDRESS.resolveModelAttribute(context, model).asStringOrNull(); final String pattern = PATTERN.resolveModelAttribute(context, model).asStringOrNull(); final List<String> roles = ROLES.unwrap(context, model); TrivialService<RoleDecoder> roleDecoderService; // one of 'source-address' or 'pattern' must be specified if (sourceAddress != null) { roleDecoderService = new TrivialService<>(() -> new SourceAddressRoleDecoder(sourceAddress, Roles.fromSet(new HashSet<>(roles)))); } else { roleDecoderService = new TrivialService<>(() -> new SourceAddressRoleDecoder(Pattern.compile(pattern), Roles.fromSet(new HashSet<>(roles)))); } ServiceBuilder<RoleDecoder> roleDecoderBuilderBuilder = serviceTarget.addService(roleDecoderName, roleDecoderService); commonDependencies(roleDecoderBuilderBuilder) .setInitialMode(Mode.LAZY) .install(); }
Example 7
Source File: ConnectorAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
void launchServices(OperationContext context, String connectorName, ModelNode fullModel) throws OperationFailedException { OptionMap optionMap = ConnectorUtils.getFullOptions(context, fullModel); final ServiceTarget target = context.getServiceTarget(); final String socketName = ConnectorResource.SOCKET_BINDING.resolveModelAttribute(context, fullModel).asString(); final ServiceName socketBindingName = context.getCapabilityServiceName(ConnectorResource.SOCKET_CAPABILITY_NAME, socketName, SocketBinding.class); ModelNode securityRealmModel = ConnectorResource.SECURITY_REALM.resolveModelAttribute(context, fullModel); final ServiceName securityRealmName = securityRealmModel.isDefined() ? SecurityRealm.ServiceUtil.createServiceName(securityRealmModel.asString()) : null; ModelNode saslAuthenticationFactoryModel = ConnectorResource.SASL_AUTHENTICATION_FACTORY.resolveModelAttribute(context, fullModel); final ServiceName saslAuthenticationFactoryName = saslAuthenticationFactoryModel.isDefined() ? context.getCapabilityServiceName(SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactoryModel.asString(), SaslAuthenticationFactory.class) : null; ModelNode sslContextModel = ConnectorResource.SSL_CONTEXT.resolveModelAttribute(context, fullModel); final ServiceName sslContextName = sslContextModel.isDefined() ? context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContextModel.asString(), SSLContext.class) : null; final ServiceName sbmName = context.getCapabilityServiceName(SOCKET_BINDING_MANAGER_CAPABILTIY, SocketBindingManager.class); RemotingServices.installConnectorServicesForSocketBinding(target, RemotingServices.SUBSYSTEM_ENDPOINT, connectorName, socketBindingName, optionMap, securityRealmName, saslAuthenticationFactoryName, sslContextName, sbmName); }
Example 8
Source File: CustomContextExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ServiceTarget target = context.getServiceTarget(); CustomContextService service = new CustomContextService(context.getProcessType().isServer()); target.addService(CustomContextService.SERVICE_NAME, service) .addDependency(context.getCapabilityServiceName(REQUIRED_CAP, ExtensibleHttpManagement.class), ExtensibleHttpManagement.class, service.getHttpManagementInjector()) .install(); }
Example 9
Source File: CachingRealmDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName realmName = runtimeCapability.getCapabilityServiceName(SecurityRealm.class); String cacheableRealm = REALM_NAME.resolveModelAttribute(context, model).asString(); int maxEntries = MAXIMUM_ENTRIES.resolveModelAttribute(context, model).asInt(); long maxAge = MAXIMUM_AGE.resolveModelAttribute(context, model).asInt(); InjectedValue<SecurityRealm> cacheableRealmValue = new InjectedValue<>(); ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(realmName, createService(cacheableRealm, maxEntries, maxAge, cacheableRealmValue)); addRealmDependency(context, serviceBuilder, cacheableRealm, cacheableRealmValue); commonDependencies(serviceBuilder).setInitialMode(Mode.ACTIVE).install(); }
Example 10
Source File: CertificateAuthorityAccountDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); String certificateAuthorityName = CERTIFICATE_AUTHORITY.resolveModelAttribute(context, model).asString(); final String alias = ALIAS.resolveModelAttribute(context, model).asString(); final String keyStoreName = KEY_STORE.resolveModelAttribute(context, model).asString(); ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier = null; if (CREDENTIAL_REFERENCE.resolveModelAttribute(context, operation).isDefined()) { credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, CREDENTIAL_REFERENCE, operation, null); } final List<ModelNode> contactUrls = CONTACT_URLS.resolveModelAttribute(context, model).asListOrEmpty(); final List<String> contactUrlsList = new ArrayList<>(contactUrls.size()); for (ModelNode contactUrl : contactUrls) { contactUrlsList.add(contactUrl.asString()); } AcmeAccountService acmeAccountService = new AcmeAccountService(certificateAuthorityName, contactUrlsList, alias, keyStoreName); ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> certificateAuthorityAccountRuntimeCapability = CERTIFICATE_AUTHORITY_ACCOUNT_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName acmeAccountServiceName = certificateAuthorityAccountRuntimeCapability.getCapabilityServiceName(AcmeAccount.class); ServiceBuilder<AcmeAccount> acmeAccountServiceBuilder = serviceTarget.addService(acmeAccountServiceName, acmeAccountService).setInitialMode(ServiceController.Mode.ACTIVE); acmeAccountService.getCredentialSourceSupplierInjector().inject(credentialSourceSupplier); String keyStoreCapabilityName = RuntimeCapability.buildDynamicCapabilityName(KEY_STORE_CAPABILITY, keyStoreName); acmeAccountServiceBuilder.addDependency(context.getCapabilityServiceName(keyStoreCapabilityName, KeyStore.class), KeyStore.class, acmeAccountService.getKeyStoreInjector()); if (certificateAuthorityName.equalsIgnoreCase(CertificateAuthority.LETS_ENCRYPT.getName())) { commonRequirements(acmeAccountServiceBuilder).install(); } else { acmeAccountServiceBuilder.requires(CERTIFICATE_AUTHORITY_RUNTIME_CAPABILITY.getCapabilityServiceName(certificateAuthorityName)); commonRequirements(acmeAccountServiceBuilder).install(); } }
Example 11
Source File: NativeManagementAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected List<ServiceName> installServices(OperationContext context, NativeInterfaceCommonPolicy commonPolicy, ModelNode model) throws OperationFailedException { final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName endpointName = ManagementRemotingServices.MANAGEMENT_ENDPOINT; final String hostName = WildFlySecurityManager.getPropertyPrivileged(ServerEnvironment.NODE_NAME, null); NativeManagementServices.installManagementWorkerService(serviceTarget, context.getServiceRegistry(false)); NativeManagementServices.installRemotingServicesIfNotInstalled(serviceTarget, hostName, context.getServiceRegistry(false)); final String bindingName = SOCKET_BINDING.resolveModelAttribute(context, model).asString(); ServiceName socketBindingServiceName = context.getCapabilityServiceName(SOCKET_BINDING_CAPABILITY_NAME, bindingName, SocketBinding.class); String securityRealm = commonPolicy.getSecurityRealm(); String saslAuthenticationFactory = commonPolicy.getSaslAuthenticationFactory(); if (saslAuthenticationFactory == null && securityRealm == null) { ServerLogger.ROOT_LOGGER.nativeManagementInterfaceIsUnsecured(); } ServiceName securityRealmName = securityRealm != null ? SecurityRealm.ServiceUtil.createServiceName(securityRealm) : null; ServiceName saslAuthenticationFactoryName = saslAuthenticationFactory != null ? context.getCapabilityServiceName( SASL_AUTHENTICATION_FACTORY_CAPABILITY, saslAuthenticationFactory, SaslAuthenticationFactory.class) : null; String sslContext = commonPolicy.getSSLContext(); ServiceName sslContextName = sslContext != null ? context.getCapabilityServiceName(SSL_CONTEXT_CAPABILITY, sslContext, SSLContext.class) : null; final ServiceName sbmName = context.getCapabilityServiceName("org.wildfly.management.socket-binding-manager", SocketBindingManager.class); ManagementRemotingServices.installConnectorServicesForSocketBinding(serviceTarget, endpointName, ManagementRemotingServices.MANAGEMENT_CONNECTOR, socketBindingServiceName, commonPolicy.getConnectorOptions(), securityRealmName, saslAuthenticationFactoryName, sslContextName, sbmName); return Arrays.asList(REMOTING_BASE.append("server", MANAGEMENT_CONNECTOR), socketBindingServiceName); }
Example 12
Source File: SaslServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceDefinition getProviderSaslServerFactoryDefinition() { AbstractAddStepHandler add = new SaslServerAddHandler(PROVIDERS) { @Override protected ServiceBuilder<SaslServerFactory> installService(OperationContext context, ServiceName saslServerFactoryName, ModelNode model) throws OperationFailedException { String providers = PROVIDERS.resolveModelAttribute(context, model).asStringOrNull(); final InjectedValue<Provider[]> providerInjector = new InjectedValue<Provider[]>(); final Supplier<Provider[]> providerSupplier = providers != null ? (providerInjector::getValue) : (Security::getProviders); TrivialService<SaslServerFactory> saslServiceFactoryService = new TrivialService<SaslServerFactory>(() -> new SecurityProviderSaslServerFactory(providerSupplier)); ServiceTarget serviceTarget = context.getServiceTarget(); ServiceBuilder<SaslServerFactory> serviceBuilder = serviceTarget.addService(saslServerFactoryName, saslServiceFactoryService); if (providers != null) { serviceBuilder.addDependency(context.getCapabilityServiceName(RuntimeCapability.buildDynamicCapabilityName(PROVIDERS_CAPABILITY, providers), Provider[].class), Provider[].class, providerInjector); } return serviceBuilder; } }; return wrap(new SaslServerResourceDefinition(ElytronDescriptionConstants.PROVIDER_SASL_SERVER_FACTORY, add, PROVIDERS), SaslServerDefinitions::getSaslServerAvailableMechanisms); }
Example 13
Source File: ThreadFactoryAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { ModelNode priorityModelNode = PoolAttributeDefinitions.PRIORITY.resolveModelAttribute(context, model); ModelNode groupNameModelNode = PoolAttributeDefinitions.GROUP_NAME.resolveModelAttribute(context, model); ModelNode threadNamePatternModelNode = PoolAttributeDefinitions.THREAD_NAME_PATTERN.resolveModelAttribute(context, model); final String threadNamePattern = threadNamePatternModelNode.isDefined() ? threadNamePatternModelNode.asString() : null; final Integer priority = priorityModelNode.isDefined() ? priorityModelNode.asInt() : null; final String groupName = groupNameModelNode.isDefined() ? groupNameModelNode.asString() : null; final String name = context.getCurrentAddressValue(); final ServiceTarget target = context.getServiceTarget(); final ThreadFactoryService service = new ThreadFactoryService(); service.setNamePattern(threadNamePattern); service.setPriority(priority); service.setThreadGroupName(groupName); if (cap != null) { target.addService(cap.getCapabilityServiceName(context.getCurrentAddress()), service) .addAliases(ThreadsServices.threadFactoryName(name)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); } else { target.addService(ThreadsServices.threadFactoryName(name), service) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); } }
Example 14
Source File: LdapConnectionAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String name = address.getLastElement().getValue(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceName ldapConMgrName = LdapConnectionManagerService.ServiceUtil.createServiceName(name); final ServiceBuilder<?> sb = serviceTarget.addService(ldapConMgrName); final Consumer<LdapConnectionManager> lcmConsumer = sb.provides(ldapConMgrName); final ModelNode securityRealm = SECURITY_REALM.resolveModelAttribute(context, model); Supplier<SSLContext> fullSSLContextSupplier = null; Supplier<SSLContext> trustSSLContextSupplier = null; if (securityRealm.isDefined()) { String realmName = securityRealm.asString(); fullSSLContextSupplier = SSLContextService.ServiceUtil.requires(sb, SecurityRealm.ServiceUtil.createServiceName(realmName), false); trustSSLContextSupplier = SSLContextService.ServiceUtil.requires(sb, SecurityRealm.ServiceUtil.createServiceName(realmName), true); } ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier = null; if (LdapConnectionResourceDefinition.SEARCH_CREDENTIAL_REFERENCE.resolveModelAttribute(context, model).isDefined()) { credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, LdapConnectionResourceDefinition.SEARCH_CREDENTIAL_REFERENCE, model, sb); } final LdapConnectionManagerService connectionManagerService = new LdapConnectionManagerService( lcmConsumer, fullSSLContextSupplier, trustSSLContextSupplier, credentialSourceSupplier, name, connectionManagerRegistry); updateRuntime(context, model, connectionManagerService); sb.setInstance(connectionManagerService); sb.install(); }
Example 15
Source File: PrincipalDecoderDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { RuntimeCapability<Void> decoderRuntimeCapability = PRINCIPAL_DECODER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName decoderName = decoderRuntimeCapability.getCapabilityServiceName(PrincipalDecoder.class); ServiceTarget serviceTarget = context.getServiceTarget(); TrivialService<PrincipalDecoder> principalDecoderService = new TrivialService<PrincipalDecoder>(); ServiceBuilder<PrincipalDecoder> decoderBuilder = serviceTarget.addService(decoderName, principalDecoderService); principalDecoderService.setValueSupplier(getValueSupplier(decoderBuilder, context, model)); commonDependencies(decoderBuilder) .setInitialMode(Mode.LAZY) .install(); final InjectedValue<PrincipalDecoder> injectedDecoder = new InjectedValue<>(); TrivialService<PrincipalTransformer> transformerService = new TrivialService<>(() -> PrincipalTransformer.from(injectedDecoder.getValue().asPrincipalRewriter())); RuntimeCapability<Void> transformerRuntimeCapability = PRINCIPAL_TRANSFORMER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName transformerName = transformerRuntimeCapability.getCapabilityServiceName(PrincipalTransformer.class); serviceTarget.addService(transformerName, transformerService) .addDependency(decoderName, PrincipalDecoder.class, injectedDecoder) .setInitialMode(Mode.LAZY) .install(); }
Example 16
Source File: SaslServerDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected ServiceBuilder<SaslServerFactory> installService(OperationContext context, ServiceName saslServerFactoryName, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); TrivialService<SaslServerFactory> saslServerFactoryService = new TrivialService<SaslServerFactory>(getValueSupplier(context, model)); return serviceTarget.addService(saslServerFactoryName, saslServerFactoryService); }
Example 17
Source File: KeyStoreDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); String providers = PROVIDERS.resolveModelAttribute(context, model).asStringOrNull(); String providerName = PROVIDER_NAME.resolveModelAttribute(context, model).asStringOrNull(); String type = TYPE.resolveModelAttribute(context, model).asStringOrNull(); String path = PATH.resolveModelAttribute(context, model).asStringOrNull(); String relativeTo = null; boolean required; String aliasFilter = ALIAS_FILTER.resolveModelAttribute(context, model).asStringOrNull(); final KeyStoreService keyStoreService; if (path != null) { relativeTo = RELATIVE_TO.resolveModelAttribute(context, model).asStringOrNull(); required = REQUIRED.resolveModelAttribute(context, model).asBoolean(); keyStoreService = KeyStoreService.createFileBasedKeyStoreService(providerName, type, relativeTo, path, required, aliasFilter); } else { if (type == null) { throw ROOT_LOGGER.filelessKeyStoreMissingType(); } keyStoreService = KeyStoreService.createFileLessKeyStoreService(providerName, type, aliasFilter); } ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(KeyStore.class); ServiceBuilder<KeyStore> serviceBuilder = serviceTarget.addService(serviceName, keyStoreService).setInitialMode(Mode.ACTIVE); serviceBuilder.addDependency(PathManagerService.SERVICE_NAME, PathManager.class, keyStoreService.getPathManagerInjector()); if (relativeTo != null) { serviceBuilder.requires(pathName(relativeTo)); } if (providers != null) { String providersCapabilityName = RuntimeCapability.buildDynamicCapabilityName(PROVIDERS_CAPABILITY, providers); ServiceName providerLoaderServiceName = context.getCapabilityServiceName(providersCapabilityName, Provider[].class); serviceBuilder.addDependency(providerLoaderServiceName, Provider[].class, keyStoreService.getProvidersInjector()); } keyStoreService.getCredentialSourceSupplierInjector() .inject(CredentialReference.getCredentialSourceSupplier(context, KeyStoreDefinition.CREDENTIAL_REFERENCE, model, serviceBuilder)); commonDependencies(serviceBuilder).install(); }
Example 18
Source File: FilteringKeyStoreDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException { ModelNode model = resource.getModel(); String sourceKeyStoreName = KEY_STORE.resolveModelAttribute(context, model).asStringOrNull(); String aliasFilter = ALIAS_FILTER.resolveModelAttribute(context, model).asStringOrNull(); String sourceKeyStoreCapability = RuntimeCapability.buildDynamicCapabilityName(KEY_STORE_CAPABILITY, sourceKeyStoreName); ServiceName sourceKeyStoreServiceName = context.getCapabilityServiceName(sourceKeyStoreCapability, KeyStore.class); final InjectedValue<KeyStore> keyStore = new InjectedValue<>(); FilteringKeyStoreService filteringKeyStoreService = new FilteringKeyStoreService(keyStore, aliasFilter); ServiceTarget serviceTarget = context.getServiceTarget(); RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(KeyStore.class); ServiceBuilder<KeyStore> serviceBuilder = serviceTarget.addService(serviceName, filteringKeyStoreService).setInitialMode(ServiceController.Mode.ACTIVE); FILTERING_KEY_STORE_UTIL.addInjection(serviceBuilder, keyStore, sourceKeyStoreServiceName); commonDependencies(serviceBuilder).install(); }
Example 19
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
static ResourceDefinition getLogicalRoleMapperDefinition() { AttributeDefinition[] attributes = new AttributeDefinition[] { LOGICAL_OPERATION, LEFT, RIGHT }; AbstractAddStepHandler add = new RoleMapperAddHandler(attributes) { /* (non-Javadoc) * @see org.wildfly.extension.elytron.RoleMapperDefinitions.RoleMapperAddHandler#installService(org.jboss.as.controller.OperationContext, org.jboss.msc.service.ServiceName, org.jboss.dmr.ModelNode) */ @Override protected ServiceBuilder<RoleMapper> installService(OperationContext context, ServiceName roleMapperName, ModelNode model) throws OperationFailedException { final InjectedValue<RoleMapper> leftRoleMapperInjector = new InjectedValue<RoleMapper>(); final InjectedValue<RoleMapper> rightRoleMapperInjector = new InjectedValue<RoleMapper>(); LogicalOperation operation = LogicalOperation.valueOf(LogicalOperation.class, LOGICAL_OPERATION.resolveModelAttribute(context, model).asString().toUpperCase(Locale.ENGLISH)); TrivialService<RoleMapper> roleMapperService = new TrivialService<RoleMapper>(() -> operation.create(leftRoleMapperInjector.getValue(), rightRoleMapperInjector.getValue())); ServiceTarget serviceTarget = context.getServiceTarget(); ServiceBuilder<RoleMapper> serviceBuilder = serviceTarget.addService(roleMapperName, roleMapperService); String leftName = LEFT.resolveModelAttribute(context, model).asStringOrNull(); if (leftName != null) { serviceBuilder.addDependency(context.getCapabilityServiceName( RuntimeCapability.buildDynamicCapabilityName(ROLE_MAPPER_CAPABILITY, leftName), RoleMapper.class), RoleMapper.class, leftRoleMapperInjector); } else { leftRoleMapperInjector.inject(RoleMapper.IDENTITY_ROLE_MAPPER); } String rightName = RIGHT.resolveModelAttribute(context, model).asStringOrNull(); if (rightName != null) { serviceBuilder.addDependency(context.getCapabilityServiceName( RuntimeCapability.buildDynamicCapabilityName(ROLE_MAPPER_CAPABILITY, rightName), RoleMapper.class), RoleMapper.class, rightRoleMapperInjector); } else { rightRoleMapperInjector.inject(RoleMapper.IDENTITY_ROLE_MAPPER); } return serviceBuilder; } }; return new RoleMapperResourceDefinition(ElytronDescriptionConstants.LOGICAL_ROLE_MAPPER, add, attributes); }
Example 20
Source File: RoleMapperDefinitions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected ServiceBuilder<RoleMapper> installService(OperationContext context, ServiceName roleMapperName, ModelNode model) throws OperationFailedException { ServiceTarget serviceTarget = context.getServiceTarget(); TrivialService<RoleMapper> roleMapperService = new TrivialService<RoleMapper>(getValueSupplier(context, model)); return serviceTarget.addService(roleMapperName, roleMapperService); }