Java Code Examples for org.jboss.msc.service.ServiceBuilder#provides()
The following examples show how to use
org.jboss.msc.service.ServiceBuilder#provides() .
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: VirtualSecurityDomainProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.getParent() != null || !isVirtualDomainRequired(deploymentUnit)) { return; // Only interested in installation if this is really the root deployment. } ServiceName virtualDomainName = virtualDomainName(deploymentUnit); ServiceTarget serviceTarget = phaseContext.getServiceTarget(); ServiceBuilder<?> serviceBuilder = serviceTarget.addService(virtualDomainName); final SecurityDomain virtualDomain = SecurityDomain.builder().build(); final Consumer<SecurityDomain> consumer = serviceBuilder.provides(virtualDomainName); serviceBuilder.setInstance(Service.newInstance(consumer, virtualDomain)); serviceBuilder.setInitialMode(Mode.ON_DEMAND); serviceBuilder.install(); }
Example 2
Source File: GenericOutboundConnectionAdd.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
void installRuntimeService(final OperationContext context, final ModelNode operation, final ModelNode fullModel) throws OperationFailedException { final PathAddress pathAddress = PathAddress.pathAddress(operation.require(OP_ADDR)); final String connectionName = pathAddress.getLastElement().getValue(); // Get the destination URI final URI uri = getDestinationURI(context, operation); // create the service final ServiceName serviceName = OUTBOUND_CONNECTION_CAPABILITY.getCapabilityServiceName(connectionName); // also add an alias service name to easily distinguish between a generic, remote and local type of connection services final ServiceName aliasServiceName = GenericOutboundConnectionService.GENERIC_OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName); final ServiceName deprecatedServiceName = AbstractOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName); final ServiceBuilder<?> builder = context.getServiceTarget().addService(serviceName); final Consumer<GenericOutboundConnectionService> serviceConsumer = builder.provides(deprecatedServiceName, aliasServiceName); builder.setInstance(new GenericOutboundConnectionService(serviceConsumer, uri)); builder.requires(RemotingServices.SUBSYSTEM_ENDPOINT); builder.install(); }
Example 3
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Supplier<CallbackHandlerService> addLocalService(OperationContext context, ModelNode local, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { ServiceName localServiceName = LocalCallbackHandlerService.ServiceUtil.createServiceName(realmName); ModelNode node = LocalAuthenticationResourceDefinition.DEFAULT_USER.resolveModelAttribute(context, local); String defaultUser = node.isDefined() ? node.asString() : null; node = LocalAuthenticationResourceDefinition.ALLOWED_USERS.resolveModelAttribute(context, local); String allowedUsers = node.isDefined() ? node.asString() : null; node = LocalAuthenticationResourceDefinition.SKIP_GROUP_LOADING.resolveModelAttribute(context, local); boolean skipGroupLoading = node.asBoolean(); final ServiceBuilder<?> builder = serviceTarget.addService(localServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(localServiceName); builder.setInstance(new LocalCallbackHandlerService(chsConsumer, defaultUser, allowedUsers, skipGroupLoading)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, localServiceName); }
Example 4
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Supplier<CallbackHandlerService> addPlugInAuthenticationService(OperationContext context, ModelNode model, String realmName, String registryName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName plugInServiceName = PlugInAuthenticationCallbackHandler.ServiceUtil.createServiceName(realmName); final String pluginName = PlugInAuthorizationResourceDefinition.NAME.resolveModelAttribute(context, model).asString(); final Map<String, String> properties = resolveProperties(context, model); final String mechanismName = PlugInAuthenticationResourceDefinition.MECHANISM.resolveModelAttribute(context, model).asString(); final AuthMechanism mechanism = AuthMechanism.valueOf(mechanismName); final ServiceBuilder<?> plugInBuilder = serviceTarget.addService(plugInServiceName); final Consumer<CallbackHandlerService> chsConsumer = plugInBuilder.provides(plugInServiceName); final Supplier<PlugInLoaderService> pilSupplier = PlugInLoaderService.ServiceUtil.requires(plugInBuilder, realmName); plugInBuilder.setInstance(new PlugInAuthenticationCallbackHandler(chsConsumer, pilSupplier, registryName, pluginName, properties, mechanism)); plugInBuilder.setInitialMode(ON_DEMAND); plugInBuilder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, plugInServiceName); }
Example 5
Source File: ManagementRemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Set up the services to create a channel listener and operation handler service. * @param serviceTarget the service target to install the services into * @param endpointName the endpoint name to install the services into * @param channelName the name of the channel * @param executorServiceName service name of the executor service to use in the operation handler service * @param scheduledExecutorServiceName service name of the scheduled executor service to use in the operation handler service */ public static void installManagementChannelServices( final ServiceTarget serviceTarget, final ServiceName endpointName, final ModelControllerOperationHandlerFactory operationHandlerServiceFactory, final ServiceName modelControllerName, final String channelName, final ServiceName executorServiceName, final ServiceName scheduledExecutorServiceName) { final OptionMap options = OptionMap.EMPTY; final ServiceName operationHandlerName = endpointName.append(channelName).append(ModelControllerClientOperationHandlerFactoryService.OPERATION_HANDLER_NAME_SUFFIX); final ServiceBuilder<?> builder = serviceTarget.addService(operationHandlerName); final Consumer<AbstractModelControllerOperationHandlerFactoryService> serviceConsumer = builder.provides(operationHandlerName); final Supplier<ModelController> mcSupplier = builder.requires(modelControllerName); final Supplier<ExecutorService> eSupplier = builder.requires(executorServiceName); final Supplier<ScheduledExecutorService> seSupplier = builder.requires(scheduledExecutorServiceName); builder.setInstance(operationHandlerServiceFactory.newInstance(serviceConsumer, mcSupplier, eSupplier, seSupplier)); builder.install(); installManagementChannelOpenListenerService(serviceTarget, endpointName, channelName, operationHandlerName, options, false); }
Example 6
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Supplier<SubjectSupplementalService> addPropertiesAuthorizationService(OperationContext context, ModelNode properties, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName propsServiceName = PropertiesSubjectSupplemental.ServiceUtil.createServiceName(realmName); final String path = PropertiesAuthorizationResourceDefinition.PATH.resolveModelAttribute(context, properties).asString(); final ModelNode relativeToNode = PropertiesAuthorizationResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, properties); final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null; final ServiceBuilder<?> builder = serviceTarget.addService(propsServiceName); final Consumer<SubjectSupplementalService> sssConsumer = builder.provides(propsServiceName); Supplier<PathManager> pmSupplier = null; if (relativeTo != null) { pmSupplier = builder.requires(context.getCapabilityServiceName(PATH_MANAGER_CAPABILITY, PathManager.class)); builder.requires(pathName(relativeTo)); } builder.setInstance(new PropertiesSubjectSupplemental(sssConsumer, pmSupplier, realmName, path, relativeTo)); builder.setInitialMode(ON_DEMAND); builder.install(); return SubjectSupplementalService.ServiceUtil.requires(realmBuilder, propsServiceName); }
Example 7
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private Supplier<CallbackHandlerFactory> addSecretService(OperationContext context, ModelNode secret, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName secretServiceName = SecretIdentityService.ServiceUtil.createServiceName(realmName); final ModelNode resolvedValueNode = SecretServerIdentityResourceDefinition.VALUE.resolveModelAttribute(context, secret); boolean base64 = secret.get(SecretServerIdentityResourceDefinition.VALUE.getName()).getType() != ModelType.EXPRESSION; final ServiceBuilder<?> builder = serviceTarget.addService(secretServiceName); final Consumer<CallbackHandlerFactory> chfConsumer = builder.provides(secretServiceName); ExceptionSupplier<CredentialSource, Exception> credentialSourceSupplier = null; if (secret.hasDefined(CredentialReference.CREDENTIAL_REFERENCE)) { String keySuffix = SERVER_IDENTITY + KEY_DELIMITER + SECRET; credentialSourceSupplier = CredentialReference.getCredentialSourceSupplier(context, SecretServerIdentityResourceDefinition.CREDENTIAL_REFERENCE, secret, builder, keySuffix); } SecretIdentityService sis; if (secret.hasDefined(CredentialReference.CREDENTIAL_REFERENCE)) { sis = new SecretIdentityService(chfConsumer, credentialSourceSupplier, resolvedValueNode.asString(), false); } else { sis = new SecretIdentityService(chfConsumer, credentialSourceSupplier, resolvedValueNode.asString(), base64); } builder.setInstance(sis); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerFactory.ServiceUtil.requires(realmBuilder, secretServiceName); }
Example 8
Source File: ManagedExplodedContentServitor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ServiceController<?> addService(final ServiceTarget serviceTarget, final ServiceName serviceName, final String managementName, final byte[] hash) { final ServiceBuilder<?> sb = serviceTarget.addService(serviceName); final Consumer<VirtualFile> vfConsumer = sb.provides(serviceName); final Supplier<ContentRepository> crSupplier = sb.requires(ContentRepository.SERVICE_NAME); final Supplier<ServerEnvironment> seSupplier = sb.requires(ServerEnvironmentService.SERVICE_NAME); final Supplier<ExecutorService> esSupplier = requireServerExecutor(sb); sb.setInstance(new ManagedExplodedContentServitor(managementName, hash, vfConsumer, crSupplier, seSupplier, esSupplier)); return sb.install(); }
Example 9
Source File: SecurityRealmServiceUtilTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Tests that SecurityRealm.ServiceUtil's dependency injection works regardless of what * ServiceTarget API was used for creating the target ServiceBuilder. */ @SuppressWarnings("deprecation") @Test public void testDifferentServiceBuilderTypes() { ServiceTarget serviceTarget = container.subTarget(); final Supplier<String> tmpDirSupplier = () -> tmpDir.toAbsolutePath().toString(); final ServiceName realmServiceName = SecurityRealm.ServiceUtil.createServiceName(TESTNAME); final ServiceBuilder<?> realmBuilder = serviceTarget.addService(realmServiceName); final Consumer<SecurityRealm> securityRealmConsumer = realmBuilder.provides(realmServiceName, SecurityRealm.ServiceUtil.createLegacyServiceName(TESTNAME)); final SecurityRealmService securityRealmService = new SecurityRealmService(securityRealmConsumer, null, null, null, null, tmpDirSupplier, new HashSet(), TESTNAME, false); realmBuilder.setInstance(securityRealmService); final ServiceController<?> realmController = realmBuilder.install(); TestService legacy = new TestService(); ServiceBuilder legacyBuilder = serviceTarget.addService(ServiceName.of("LEGACY"), legacy); SecurityRealm.ServiceUtil.addDependency(legacyBuilder, legacy.injector, TESTNAME); ServiceController<?> legacyController = legacyBuilder.install(); TestService current = new TestService(); ServiceBuilder currentBuilder = serviceTarget.addService(ServiceName.of("CURRENT")); SecurityRealm.ServiceUtil.addDependency(currentBuilder, current.injector, TESTNAME); currentBuilder.setInstance(current); ServiceController<?> currentController = currentBuilder.install(); try { container.awaitStability(60, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); Assert.fail("Interrupted"); } Assert.assertEquals(ServiceController.State.UP, realmController.getState()); Assert.assertEquals(ServiceController.State.UP, legacyController.getState()); Assert.assertEquals(ServiceController.State.UP, currentController.getState()); Assert.assertSame(securityRealmService, legacy.getValue()); Assert.assertSame(securityRealmService, current.getValue()); }
Example 10
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 11
Source File: DomainManagedServerCallbackHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void install(final ServiceTarget serviceTarget) { final ServiceBuilder<?> builder = serviceTarget.addService(DomainManagedServerCallbackHandler.SERVICE_NAME); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(DomainManagedServerCallbackHandler.SERVICE_NAME); builder.setInstance(new DomainManagedServerCallbackHandler(chsConsumer)); builder.setInitialMode(ON_DEMAND); builder.install(); }
Example 12
Source File: ConsoleAvailabilityService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void addService(ServiceTarget serviceTarget, LogAdminConsole logMessageAction) { ServiceName serviceName = CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName(); ServiceBuilder<?> sb = serviceTarget.addService(serviceName); Consumer<ConsoleAvailability> caConsumer = sb.provides(serviceName); Supplier<ProcessStateNotifier> psnSupplier = sb.requires(ControlledProcessStateService.INTERNAL_SERVICE_NAME); ConsoleAvailabilityService consoleAvailabilityService = new ConsoleAvailabilityService(caConsumer, psnSupplier, logMessageAction); sb.setInstance(consoleAvailabilityService); sb.install(); }
Example 13
Source File: RelativePathService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Installs a path service. * * @param name the name to use for the service * @param path the relative portion of the path * @param possiblyAbsolute {@code true} if {@code path} may be an {@link #isAbsoluteUnixOrWindowsPath(String) absolute path} * and should be {@link AbsolutePathService installed as such} if it is, with any * {@code relativeTo} parameter ignored * @param relativeTo the name of the path that {@code path} may be relative to * @param serviceTarget the {@link ServiceTarget} to use to install the service * @return the ServiceController for the path service */ public static ServiceController<?> addService(final ServiceName name, final String path, boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) { if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) { return AbsolutePathService.addService(name, path, serviceTarget); } final ServiceBuilder<?> builder = serviceTarget.addService(name); final Consumer<String> pathConsumer = builder.provides(name); final Supplier<String> injectedPath = builder.requires(pathNameOf(relativeTo)); builder.setInstance(new RelativePathService(path, pathConsumer, injectedPath)); return builder.install(); }
Example 14
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addLdapService(OperationContext context, ModelNode ldap, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder, boolean shareConnection) throws OperationFailedException { ServiceName ldapServiceName = UserLdapCallbackHandler.ServiceUtil.createServiceName(realmName); final String baseDn = LdapAuthenticationResourceDefinition.BASE_DN.resolveModelAttribute(context, ldap).asString(); ModelNode node = LdapAuthenticationResourceDefinition.USERNAME_FILTER.resolveModelAttribute(context, ldap); final String usernameAttribute = node.isDefined() ? node.asString() : null; node = LdapAuthenticationResourceDefinition.ADVANCED_FILTER.resolveModelAttribute(context, ldap); final String advancedFilter = node.isDefined() ? node.asString() : null; node = LdapAuthenticationResourceDefinition.USERNAME_LOAD.resolveModelAttribute(context, ldap); final String usernameLoad = node.isDefined() ? node.asString() : null; final boolean recursive = LdapAuthenticationResourceDefinition.RECURSIVE.resolveModelAttribute(context, ldap).asBoolean(); final boolean allowEmptyPasswords = LdapAuthenticationResourceDefinition.ALLOW_EMPTY_PASSWORDS.resolveModelAttribute(context, ldap).asBoolean(); final String userDn = LdapAuthenticationResourceDefinition.USER_DN.resolveModelAttribute(context, ldap).asString(); final LdapSearcher<LdapEntry, String> userSearcher; if (usernameAttribute != null) { userSearcher = LdapUserSearcherFactory.createForUsernameFilter(baseDn, recursive, userDn, usernameAttribute, usernameLoad); } else { userSearcher = LdapUserSearcherFactory.createForAdvancedFilter(baseDn, recursive, userDn, advancedFilter, usernameLoad); } final ServiceName userSearcherCacheName = LdapSearcherCache.ServiceUtil.createServiceName(true, true, realmName); final ServiceBuilder<?> userSearchCacheBuilder = serviceTarget.addService(userSearcherCacheName); final Consumer<LdapSearcherCache<LdapEntry, String>> lscConsumer = userSearchCacheBuilder.provides(userSearcherCacheName); userSearchCacheBuilder.setInstance(createCacheService(lscConsumer, context, userSearcher, ldap.get(CACHE))); userSearchCacheBuilder.setInitialMode(ON_DEMAND); userSearchCacheBuilder.install(); final ServiceBuilder<?> builder = serviceTarget.addService(ldapServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(ldapServiceName); final String connectionManager = LdapAuthenticationResourceDefinition.CONNECTION.resolveModelAttribute(context, ldap).asString(); final Supplier<LdapConnectionManager> lcmSupplier = LdapConnectionManagerService.ServiceUtil.requires(builder, connectionManager); final Supplier<LdapSearcherCache<LdapEntry, String>> uscSupplier = LdapSearcherCache.ServiceUtil.requires(builder, true, true, realmName); builder.setInstance(new UserLdapCallbackHandler(chsConsumer, lcmSupplier, uscSupplier, allowEmptyPasswords, shareConnection)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, ldapServiceName); }
Example 15
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addJaasService(OperationContext context, ModelNode jaas, String realmName, ServiceTarget serviceTarget, boolean injectServerManager, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName jaasServiceName = JaasCallbackHandler.ServiceUtil.createServiceName(realmName); final String name = JaasAuthenticationResourceDefinition.NAME.resolveModelAttribute(context, jaas).asString(); final boolean assignGroups = JaasAuthenticationResourceDefinition.ASSIGN_GROUPS.resolveModelAttribute(context, jaas).asBoolean(); final ServiceBuilder<?> builder = serviceTarget.addService(jaasServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(jaasServiceName); final Supplier<ServerSecurityManager> smSupplier = injectServerManager ? builder.requires(ServiceName.JBOSS.append("security", "simple-security-manager")) : null; builder.setInstance(new JaasCallbackHandler(chsConsumer, smSupplier, realmName, name, assignGroups)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, jaasServiceName); }
Example 16
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addKerberosService(OperationContext context, ModelNode kerberos, String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) throws OperationFailedException { final ServiceName kerberosServiceName = KerberosCallbackHandler.ServiceUtil.createServiceName(realmName); final boolean removeRealm = KerberosAuthenticationResourceDefinition.REMOVE_REALM.resolveModelAttribute(context, kerberos).asBoolean(); final ServiceBuilder<?> builder = serviceTarget.addService(kerberosServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(kerberosServiceName); builder.setInstance(new KerberosCallbackHandler(chsConsumer, removeRealm)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, kerberosServiceName); }
Example 17
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void installRemotingManagementEndpoint(final ServiceTarget serviceTarget, final ServiceName endpointName, final String hostName, final EndpointService.EndpointType type, final OptionMap options) { final ServiceBuilder<?> builder = serviceTarget.addService(endpointName); final Consumer<Endpoint> endpointConsumer = builder.provides(endpointName); final Supplier<XnioWorker> workerSupplier = builder.requires(ServiceName.JBOSS.append("serverManagement", "controller", "management", "worker")); builder.setInstance(new EndpointService(endpointConsumer, workerSupplier, hostName, type, options)); builder.install(); }
Example 18
Source File: DeploymentMountProvider.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static void addService(final ServiceTarget serviceTarget) { //ServerDeploymentRepositoryImpl service = new ServerDeploymentRepositoryImpl(); final ServiceBuilder<?> sb = serviceTarget.addService(DeploymentMountProvider.SERVICE_NAME); final Consumer<DeploymentMountProvider> dmpConsumer = sb.provides(DeploymentMountProvider.SERVICE_NAME); final Supplier<ExecutorService> esSupplier = org.jboss.as.server.Services.requireServerExecutor(sb); sb.setInstance(new ServerDeploymentRepositoryImpl(dmpConsumer, esSupplier)); sb.install(); }
Example 19
Source File: HttpListenerRegistryService.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public static void install(final ServiceTarget serviceTarget) { final ServiceBuilder<?> builder = serviceTarget.addService(RemotingServices.HTTP_LISTENER_REGISTRY); final Consumer<ListenerRegistry> serviceConsumer = builder.provides(RemotingServices.HTTP_LISTENER_REGISTRY, SERVICE_NAME); builder.setInstance(new HttpListenerRegistryService(serviceConsumer)); builder.install(); }
Example 20
Source File: SecurityRealmServiceUtilTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@SuppressWarnings("deprecation") @Test public void testSaslAuthenticationFactoryDigest() throws Exception { registerElytronProviders(); try { File propsFile = createPropertyFile(TESTNAME + "-users.properties", "user1", "password1"); ServiceTarget serviceTarget = container.subTarget(); final Supplier<String> tmpDirSupplier = () -> tmpDir.toAbsolutePath().toString(); // register a realm service with a properties file to perform a SASL DIGEST-MD5 login final ServiceName realmServiceName = SecurityRealm.ServiceUtil.createServiceName(TESTNAME); final ServiceBuilder<?> realmBuilder = serviceTarget.addService(realmServiceName); final Consumer<SecurityRealm> securityRealmConsumer = realmBuilder.provides(realmServiceName, SecurityRealm.ServiceUtil.createLegacyServiceName(TESTNAME)); // create the properties service to check username/password final ServiceName propsServiceName = PropertiesCallbackHandler.ServiceUtil.createServiceName("PropertiesRealm"); final ServiceBuilder<?> propsBuilder = serviceTarget.addService(propsServiceName); final Consumer<CallbackHandlerService> chsConsumer = propsBuilder.provides(propsServiceName); propsBuilder.setInstance(new PropertiesCallbackHandler(chsConsumer, null, TESTNAME, propsFile.getAbsolutePath(), null, true)); propsBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND); propsBuilder.install(); final SecurityRealmService securityRealmService = new SecurityRealmService( securityRealmConsumer, null, null, null, null, tmpDirSupplier, Collections.singleton(CallbackHandlerService.ServiceUtil.requires(realmBuilder, propsServiceName)), TESTNAME, false); realmBuilder.setInstance(securityRealmService); realmBuilder.install(); // wait for server stability container.awaitStability(60, TimeUnit.SECONDS); // get the sasl factory for DIGEST-MD5 and create the sasl server with it SaslAuthenticationFactory saslAuthFact = securityRealmService.getSaslAuthenticationFactory(new String[]{"DIGEST-MD5"}, true); Assert.assertNotNull("Server Sasl Factory is not null", saslAuthFact); SaslServer server = saslAuthFact.createMechanism("DIGEST-MD5"); // now create a sasl client and perform the sasl dance final AuthenticationConfiguration authConfig = AuthenticationConfiguration.empty() .useName("user1") .usePassword("password1") .useRealm(TESTNAME) .setSaslMechanismSelector(SaslMechanismSelector.NONE.addMechanism(SaslMechanismInformation.Names.DIGEST_MD5)); AuthenticationContextConfigurationClient contextConfigurationClient = AccessController.doPrivileged(AuthenticationContextConfigurationClient.ACTION); SaslClient client = contextConfigurationClient.createSaslClient(new URI("unknown://server"), authConfig, Collections.singletonList("DIGEST-MD5")); Assert.assertNotNull("Sasl client is not null", client); Assert.assertFalse("Sasl client has no initial response", client.hasInitialResponse()); byte[] message = server.evaluateResponse(new byte[0]); message = client.evaluateChallenge(message); server.evaluateResponse(message); Assert.assertTrue("Sasl server is complete", server.isComplete()); Assert.assertEquals("Correct user is logged in", "user1", server.getAuthorizationID()); } finally { removeElytronProviders(); } }