org.jboss.msc.service.ServiceName Java Examples
The following examples show how to use
org.jboss.msc.service.ServiceName.
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: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void createJndiBindings() { final PlatformServiceReferenceFactory managedReferenceFactory = new PlatformServiceReferenceFactory(this); final ServiceName processEngineServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME .append(BpmPlatform.APP_JNDI_NAME) .append(BpmPlatform.MODULE_JNDI_NAME) .append(BpmPlatform.PROCESS_ENGINE_SERVICE_NAME); // bind process engine service BindingUtil.createJndiBindings(childTarget, processEngineServiceBindingServiceName, BpmPlatform.PROCESS_ENGINE_SERVICE_JNDI_NAME, managedReferenceFactory); final ServiceName processApplicationServiceBindingServiceName = ContextNames.GLOBAL_CONTEXT_SERVICE_NAME .append(BpmPlatform.APP_JNDI_NAME) .append(BpmPlatform.MODULE_JNDI_NAME) .append(BpmPlatform.PROCESS_APPLICATION_SERVICE_NAME); // bind process application service BindingUtil.createJndiBindings(childTarget, processApplicationServiceBindingServiceName, BpmPlatform.PROCESS_APPLICATION_SERVICE_JNDI_NAME, managedReferenceFactory); }
Example #2
Source File: FilteringKeyStoreDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void registerAttributes(ManagementResourceRegistration resourceRegistration) { for (AttributeDefinition current : CONFIG_ATTRIBUTES) { resourceRegistration.registerReadWriteAttribute(current, null, WRITE); } if (isServerOrHostController(resourceRegistration)) { resourceRegistration.registerReadOnlyAttribute(STATE, new ElytronRuntimeOnlyHandler() { @Override protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException { ServiceName keyStoreName = FILTERING_KEY_STORE_UTIL.serviceName(operation); ServiceController<?> serviceController = context.getServiceRegistry(false).getRequiredService(keyStoreName); populateResponse(context.getResult(), serviceController); } }); } }
Example #3
Source File: CompositeOperationHandlerUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testBadServiceNestedComposite() throws Exception { ModelNode step1 = getOperation("good", "attr1", 2); ModelNode step2 = getOperation("good", "attr2", 1); ModelNode comp1 = getCompositeOperation(null, step1, step2); ModelNode step3 = getOperation("good", "attr1", 20); ModelNode step4 = getOperation("bad-service", "attr2", 10); ModelNode comp2 = getCompositeOperation(null, step3, step4); ModelNode op = getCompositeOperation(null, comp1, comp2); // System.out.println(op); ModelNode result = controller.execute(op, null, null, null); // System.out.println(result); Assert.assertEquals("failed", result.get("outcome").asString()); assertTrue(result.hasDefined(FAILURE_DESCRIPTION)); assertTrue(sharedState.get()); ServiceController<?> sc = container.getService(ServiceName.JBOSS.append("bad-service")); if (sc != null) { Assert.assertEquals(ServiceController.Mode.REMOVE, sc.getMode()); } Assert.assertEquals(1, controller.execute(getOperation("good", "attr1", 3), null, null, null).get("result").asInt()); Assert.assertEquals(2, controller.execute(getOperation("good", "attr2", 3), null, null, null).get("result").asInt()); }
Example #4
Source File: RemotingLegacySubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testSubsystem12WithConnector() throws Exception { KernelServices services = createKernelServicesBuilder(createRuntimeAdditionalInitialization(true)) .setSubsystemXmlResource("remoting12-with-connector.xml").build(); ServiceName connectorServiceName = RemotingServices.serverServiceName("test-connector"); DependenciesRetrievalService dependencies = DependenciesRetrievalService.create(services, connectorServiceName); Object connectorService = dependencies.getService(connectorServiceName); assertNotNull(connectorService); ModelNode model = services.readWholeModel(); ModelNode subsystem = model.require(SUBSYSTEM).require(RemotingExtension.SUBSYSTEM_NAME); ModelNode connector = subsystem.require(CommonAttributes.CONNECTOR).require("test-connector"); assertEquals(1, connector.require(CommonAttributes.PROPERTY).require("org.xnio.Options.WORKER_ACCEPT_THREADS").require(CommonAttributes.VALUE).asInt()); // the following 2 attributes are new in remoting 1.2 NS assertEquals("myProto", connector.require(CommonAttributes.SASL_PROTOCOL).asString()); assertEquals("myServer", connector.require(CommonAttributes.SERVER_NAME).asString()); // Validate the io subsystem was added assertTrue(model.require(SUBSYSTEM).hasDefined("io")); }
Example #5
Source File: RealmsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testAggregateRealmWithPrincipalTransformer() throws Exception { KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("realms-test.xml").build(); if (!services.isSuccessfulBoot()) { Assert.fail(services.getBootError().toString()); } ServiceName serviceName = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("AggregateRealmTwo"); SecurityRealm securityRealm = (SecurityRealm) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(securityRealm); RealmIdentity identity1 = securityRealm.getRealmIdentity(fromName("firstUser")); Assert.assertTrue(identity1.exists()); //Assert that transformation was successful and the correct identity and attributes were loaded from filesystem-realm-2 Assert.assertEquals(3, identity1.getAuthorizationIdentity().getAttributes().size()); Assert.assertEquals("[Jane2]", identity1.getAuthorizationIdentity().getAttributes().get("firstName").toString()); Assert.assertEquals("[Doe2]", identity1.getAuthorizationIdentity().getAttributes().get("lastName").toString()); Assert.assertEquals("[Employee2, Manager2, Admin2]", identity1.getAuthorizationIdentity().getAttributes().get("roles").toString()); identity1.dispose(); }
Example #6
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 #7
Source File: MappersTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testCustomEvidenceDecoder() throws Exception { KernelServices services = super.createKernelServicesBuilder(new TestEnvironment()).setSubsystemXmlResource("mappers-test.xml").build(); if (!services.isSuccessfulBoot()) { Assert.fail(services.getBootError().toString()); } TestEnvironment.activateService(services, Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY, "CustomTestingDomain"); X509Certificate[] certificateChain = populateCertificateChain(true); X509PeerCertificateChainEvidence evidence = new X509PeerCertificateChainEvidence(certificateChain); ServiceName serviceName = Capabilities.EVIDENCE_DECODER_RUNTIME_CAPABILITY.getCapabilityServiceName("customEvidenceDecoder"); EvidenceDecoder evidenceDecoder = (EvidenceDecoder) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(evidenceDecoder); // custom evidence decoder just converts the subject name to upper case Assert.assertEquals("CN=BOB0", evidenceDecoder.getPrincipal(evidence).getName()); }
Example #8
Source File: RoleMappersTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testRegexRoleMapper3() throws Exception { init("TestDomain7"); ServiceName serviceName = Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName("TestDomain7"); Assert.assertNotNull(services.getContainer()); Assert.assertNotNull(services.getContainer().getService(serviceName)); SecurityDomain domain = (SecurityDomain) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(domain); ServerAuthenticationContext context = domain.createNewAuthenticationContext(); context.setAuthenticationName("user3"); Assert.assertTrue(context.exists()); Assert.assertTrue(context.authorize()); context.succeed(); SecurityIdentity identity = context.getAuthorizedIdentity(); Roles roles = identity.getRoles(); Assert.assertTrue(roles.contains("admin")); Assert.assertTrue(roles.contains("user")); Assert.assertTrue(roles.contains("joe")); Assert.assertFalse(roles.contains("application-user")); Assert.assertFalse(roles.contains("123-admin-123")); Assert.assertFalse(roles.contains("aa-user-aa")); Assert.assertEquals("user3", identity.getPrincipal().getName()); }
Example #9
Source File: MetricsUndefinedValueUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private ManagementResourceRegistration setupController(TestResourceDefinition resourceDefinition) throws InterruptedException { // restore default blockObject = new CountDownLatch(1); latch = new CountDownLatch(1); System.out.println("========= New Test \n"); container = ServiceContainer.Factory.create(TEST_METRIC); ServiceTarget target = container.subTarget(); ModelControllerService svc = new ModelControllerService(resourceDefinition); target.addService(ServiceName.of("ModelController")).setInstance(svc).install(); svc.awaitStartup(30, TimeUnit.SECONDS); controller = svc.getValue(); ModelNode setup = Util.getEmptyOperation("setup", new ModelNode()); controller.execute(setup, null, null, null); client = controller.createClient(executor); return svc.managementControllerResource; }
Example #10
Source File: OutboundSocketBindingWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Boolean> handbackHolder) throws OperationFailedException { final String bindingName = context.getCurrentAddressValue(); final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); final ServiceName serviceName = OUTBOUND_SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, OutboundSocketBinding.class); final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName); final OutboundSocketBinding binding = controller.getState() == ServiceController.State.UP ? OutboundSocketBinding.class.cast(controller.getValue()) : null; final boolean bound = binding != null && binding.isConnected(); // FIXME see if this can be used, or remove if (binding == null) { // existing is not started, so can't "update" it. Instead reinstall the service handleBindingReinstall(context, bindingModel, serviceName); handbackHolder.setHandback(Boolean.TRUE); } else { // We don't allow runtime changes without a context reload for outbound socket bindings // since any services which might have already injected/depended on the outbound // socket binding service would have use the (now stale) attributes. context.reloadRequired(); } return false; // we handle the reloadRequired stuff ourselves; it's clearer }
Example #11
Source File: SubDeploymentProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void undeploy(final DeploymentUnit deploymentUnit) { final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry(); final List<ResourceRoot> childRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (final ResourceRoot childRoot : childRoots) { if (!SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final ServiceName serviceName = Services.deploymentUnitName(deploymentUnit.getName(), childRoot.getRootName()); final ServiceController<?> serviceController = serviceRegistry.getService(serviceName); if (serviceController != null) { serviceController.setMode(ServiceController.Mode.REMOVE); } } deploymentUnit.removeAttachment(Attachments.SUB_DEPLOYMENTS); }
Example #12
Source File: RemotingServices.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
public static void installConnectorServicesForSocketBinding(final ServiceTarget serviceTarget, final ServiceName endpointName, final String connectorName, final ServiceName socketBindingName, final OptionMap connectorPropertiesOptionMap, final ServiceName securityRealm, final ServiceName saslAuthenticationFactory, final ServiceName sslContext, final ServiceName socketBindingManager) { final ServiceName serviceName = serverServiceName(connectorName); final ServiceBuilder<?> builder = serviceTarget.addService(serviceName); final Consumer<AcceptingChannel<StreamConnection>> streamServerConsumer = builder.provides(serviceName); final Supplier<Endpoint> eSupplier = builder.requires(endpointName); final Supplier<SecurityRealm> srSupplier = securityRealm != null ? builder.requires(securityRealm) : null; final Supplier<SaslAuthenticationFactory> safSupplier = saslAuthenticationFactory != null ? builder.requires(saslAuthenticationFactory) : null; final Supplier<SSLContext> scSupplier = sslContext != null ? builder.requires(sslContext) : null; final Supplier<SocketBindingManager> sbmSupplier = builder.requires(socketBindingManager); final Supplier<SocketBinding> sbSupplier = builder.requires(socketBindingName); builder.setInstance(new InjectedSocketBindingStreamServerService(streamServerConsumer, eSupplier, srSupplier, safSupplier, scSupplier, sbmSupplier, sbSupplier, connectorPropertiesOptionMap)); builder.install(); }
Example #13
Source File: RoleMappersTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testKeepBothMappedRoleMapper() throws Exception { init("TestDomain4"); ServiceName serviceName = Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName("TestDomain4"); Assert.assertNotNull(services.getContainer()); Assert.assertNotNull(services.getContainer().getService(serviceName)); SecurityDomain domain = (SecurityDomain) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(domain); ServerAuthenticationContext context = domain.createNewAuthenticationContext(); context.setAuthenticationName("user1"); Assert.assertTrue(context.exists()); Assert.assertTrue(context.authorize()); context.succeed(); SecurityIdentity identity = context.getAuthorizedIdentity(); Roles roles = identity.getRoles(); Assert.assertTrue(roles.contains("mappedGroup")); Assert.assertTrue(roles.contains("firstGroup")); Assert.assertTrue(roles.contains("secondGroup")); Assert.assertFalse(roles.contains("notInThisGroup")); Assert.assertEquals("user1", identity.getPrincipal().getName()); }
Example #14
Source File: OperationTimeoutUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void setupController() throws InterruptedException { // restore default blockObject = new CountDownLatch(1); latch = new CountDownLatch(1); System.out.println("========= New Test \n"); container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); controllerService = new ModelControllerService(); target.addService(ServiceName.of("ModelController")).setInstance(controllerService).install(); controllerService.awaitStartup(30, TimeUnit.SECONDS); ModelController controller = controllerService.getValue(); client = controller.createClient(executor); System.setProperty(BlockingTimeout.SYSTEM_PROPERTY, "1"); }
Example #15
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 #16
Source File: ConsoleAvailabilityUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Before public void setupController() throws InterruptedException { container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); this.controlledProcessState = new ControlledProcessState(true); ServiceBuilder<?> sb = target.addService(ServiceName.of("ModelController")); this.caSupplier = sb.requires(CONSOLE_AVAILABILITY_CAPABILITY.getCapabilityServiceName()); ConsoleAvailabilityControllerTmp caService = new ConsoleAvailabilityControllerTmp(controlledProcessState); ControlledProcessStateService.addService(target, controlledProcessState); ConsoleAvailabilityService.addService(target, () -> {}); sb.setInstance(caService) .install(); caService.awaitStartup(30, TimeUnit.SECONDS); }
Example #17
Source File: KeyStoresTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testFilteringKeystoreService() throws Exception { ServiceName serviceName = Capabilities.KEY_STORE_RUNTIME_CAPABILITY.getCapabilityServiceName("FilteringKeyStore"); KeyStore keyStore = (KeyStore) services.getContainer().getService(serviceName).getValue(); assertNotNull(keyStore); assertTrue(keyStore.containsAlias("firefly")); assertTrue(keyStore.isKeyEntry("firefly")); assertEquals(2, keyStore.getCertificateChain("firefly").length); // has CA in chain Certificate cert = keyStore.getCertificate("firefly"); assertNotNull(cert); assertEquals("firefly", keyStore.getCertificateAlias(cert)); assertFalse(keyStore.containsAlias("ca")); assertFalse(keyStore.isCertificateEntry("ca")); }
Example #18
Source File: ManagementUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static UserDomainCallbackHandler getUserDomainCallbackHandler(final OperationContext context, final ModelNode operation) { final String realmName = getSecurityRealmName(operation); ServiceRegistry registry = context.getServiceRegistry(true); ServiceName svcName = UserDomainCallbackHandler.ServiceUtil.createServiceName(realmName); ServiceController<?> sc = registry.getService(svcName); return sc == null ? null : UserDomainCallbackHandler.class.cast(sc.getValue()); }
Example #19
Source File: AbstractBindingWriteHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void revertBindingReinstall(OperationContext context, String bindingName, ModelNode bindingModel, String attributeName, ModelNode previousValue) { final ServiceName serviceName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, SocketBinding.class); context.removeService(serviceName); ModelNode unresolvedConfig = bindingModel.clone(); unresolvedConfig.get(attributeName).set(previousValue); try { BindingAddHandler.installBindingService(context, unresolvedConfig, bindingName); } catch (Exception e) { // Bizarro, as we installed the service before throw new RuntimeException(e); } }
Example #20
Source File: LdapTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testLdapRealm() throws Exception { ServiceName serviceName = Capabilities.SECURITY_REALM_RUNTIME_CAPABILITY.getCapabilityServiceName("LdapRealm"); ModifiableSecurityRealm securityRealm = (ModifiableSecurityRealm) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(securityRealm); RealmIdentity identity1 = securityRealm.getRealmIdentity(new NamePrincipal("plainUser")); Assert.assertTrue(identity1.exists()); Attributes as = identity1.getAttributes(); Assert.assertArrayEquals(new String[]{"uid=plainUser,dc=users,dc=elytron,dc=wildfly,dc=org"}, as.get("userDn").toArray()); Assert.assertArrayEquals(new String[]{"plainUser"}, as.get("userName").toArray()); Assert.assertArrayEquals(new String[]{"plainUserCn"}, as.get("firstName").toArray()); Assert.assertArrayEquals(new String[]{"plainUserSn"}, as.get("SN").toArray()); Assert.assertArrayEquals(new String[]{"(408) 555-2468", "+420 123 456 789"}, as.get("phones").toArray()); Assert.assertArrayEquals(new String[]{"cn=Retail,ou=Finance,dc=groups,dc=elytron,dc=wildfly,dc=org"}, as.get("rolesDn").toArray()); Assert.assertArrayEquals(new String[]{"Retail","Sales"}, as.get("rolesRecRdnCn").toArray()); Assert.assertArrayEquals(new String[]{"Retail"}, as.get("rolesCn").toArray()); Assert.assertArrayEquals(new String[]{"Retail department","Second description","Sales department"}, as.get("rolesDescription").toArray()); Assert.assertArrayEquals(new String[]{"StreetOfRoleByName1","StreetOfRoleByName2"}, as.get("rolesByName").toArray()); Assert.assertArrayEquals(new String[]{"Sales department","Management department"}, as.get("memberOfDescription").toArray()); Assert.assertArrayEquals(new String[]{"cn=Manager,ou=Finance,dc=groups,dc=elytron,dc=wildfly,dc=org","cn=Sales,ou=Finance,dc=groups,dc=elytron,dc=wildfly,dc=org"}, as.get("memberOfDn").toArray()); Assert.assertTrue(identity1.verifyEvidence(new PasswordGuessEvidence("plainPassword".toCharArray()))); identity1.dispose(); RealmIdentity identity2 = securityRealm.getRealmIdentity(new NamePrincipal("refUser")); // referrer test Assert.assertTrue(identity2.exists()); as = identity2.getAttributes(); Assert.assertArrayEquals(new String[]{"uid=refUser,dc=referredUsers,dc=elytron,dc=wildfly,dc=org"}, as.get("userDn").toArray()); Assert.assertArrayEquals(new String[]{"refUserCn"}, as.get("firstName").toArray()); Assert.assertTrue(identity2.verifyEvidence(new PasswordGuessEvidence("plainPassword".toCharArray()))); identity2.dispose(); RealmIdentity x509User = securityRealm.getRealmIdentity(new NamePrincipal("x509User")); Assert.assertTrue(x509User.exists()); Assert.assertTrue(x509User.verifyEvidence(new X509PeerCertificateChainEvidence(SCARAB_CERTIFICATE))); }
Example #21
Source File: AddServerExecutorDependencyTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Tests that Services.requireServerExecutor'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 Value<ExecutorService> value = new ImmediateValue<>(executorService); final Service<ExecutorService> mscExecutorService = new ValueService<>(value); ServiceController<?> executorController = serviceTarget.addService(ServerService.MANAGEMENT_EXECUTOR, mscExecutorService).install(); //TestService legacy = new TestService(); ServiceBuilder<?> legacyBuilder = serviceTarget.addService(ServiceName.of("LEGACY")); TestService legacy = new TestService(Services.requireServerExecutor(legacyBuilder)); legacyBuilder.setInstance(legacy); ServiceController<?> legacyController = legacyBuilder.install(); ServiceBuilder<?> currentBuilder = serviceTarget.addService(ServiceName.of("CURRENT")); TestService current = new TestService(Services.requireServerExecutor(currentBuilder)); 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, executorController.getState()); Assert.assertEquals(ServiceController.State.UP, legacyController.getState()); Assert.assertEquals(ServiceController.State.UP, currentController.getState()); Assert.assertSame(executorService, legacy.getValue()); Assert.assertSame(executorService, current.getValue()); }
Example #22
Source File: AuthenticationContextDependencyProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException { String defaultAuthenticationContext = this.defaultAuthenticationContext; if (defaultAuthenticationContext != null) { CapabilityServiceSupport capabilityServiceSupport = context.getDeploymentUnit().getAttachment(CAPABILITY_SERVICE_SUPPORT); ServiceName serviceName = capabilityServiceSupport.getCapabilityServiceName(AUTHENTICATION_CONTEXT_CAPABILITY, defaultAuthenticationContext); context.addDependency(serviceName, ElytronExtension.AUTHENTICATION_CONTEXT_KEY); } }
Example #23
Source File: SocketCapabilityOnHostResolutionUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Before public void setupController() throws InterruptedException { container = ServiceContainer.Factory.create("test"); ServiceTarget target = container.subTarget(); ModelControllerService svc = new ModelControllerService(); target.addService(ServiceName.of("ModelController")).setInstance(svc).install(); svc.awaitStartup(30, TimeUnit.SECONDS); controller = svc.getValue(); assertEquals(ControlledProcessState.State.RUNNING, svc.getCurrentProcessState()); }
Example #24
Source File: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ProcessEngine getProcessEngineService(ServiceName processEngineServiceName) { try { ServiceController<ProcessEngine> serviceController = getProcessEngineServiceController(processEngineServiceName); return serviceController.getValue(); } catch (ServiceNotFoundException e) { return null; } }
Example #25
Source File: RoleMappersTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testAddRegexRoleMapperWithRegexBoundaries() throws Exception { init("TestDomain9"); ServiceName serviceName = Capabilities.SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName("TestDomain9"); Assert.assertNotNull(services.getContainer()); Assert.assertNotNull(services.getContainer().getService(serviceName)); SecurityDomain domain = (SecurityDomain) services.getContainer().getService(serviceName).getValue(); Assert.assertNotNull(domain); ServerAuthenticationContext context = domain.createNewAuthenticationContext(); context.setAuthenticationName("user4"); Assert.assertTrue(context.exists()); Assert.assertTrue(context.authorize()); context.succeed(); SecurityIdentity identity = context.getAuthorizedIdentity(); Assert.assertEquals("user4", identity.getPrincipal().getName()); Roles roles = identity.getRoles(); Assert.assertFalse(roles.contains("app-user")); Assert.assertFalse(roles.contains("app-user-first-time-user")); Assert.assertFalse(roles.contains("app-admin-first-time-user")); Assert.assertFalse(roles.contains("app-user-first-time-admin")); Assert.assertFalse(roles.contains("joe")); Assert.assertFalse(roles.contains("app-admin")); Assert.assertFalse(roles.contains("app-admin-first-time-admin")); context = domain.createNewAuthenticationContext(); context.setAuthenticationName("user7"); Assert.assertTrue(context.exists()); Assert.assertTrue(context.authorize()); context.succeed(); identity = context.getAuthorizedIdentity(); Assert.assertEquals("user7", identity.getPrincipal().getName()); roles = identity.getRoles(); Assert.assertTrue(roles.contains("admin")); Assert.assertFalse(roles.contains("user")); }
Example #26
Source File: DeploymentUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static ServiceName getDeploymentUnitPhaseServiceName(final DeploymentUnit depUnit, final Phase phase) { DeploymentUnit parent = depUnit.getParent(); if (parent == null) { return Services.deploymentUnitName(depUnit.getName(), phase); } else { return Services.deploymentUnitName(parent.getName(), depUnit.getName(), phase); } }
Example #27
Source File: ModifiableKeyStoreDecorator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Try to obtain a {@link KeyStore} based on the given {@link OperationContext}. * * @param context the current context * @return the unmodifiable KeyStore * @throws OperationFailedException if any error occurs while obtaining. */ static KeyStore getKeyStore(OperationContext context) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); PathAddress currentAddress = context.getCurrentAddress(); RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue()); ServiceName serviceName = runtimeCapability.getCapabilityServiceName(); ServiceController<KeyStore> serviceController = getRequiredService(serviceRegistry, serviceName, KeyStore.class); return Assert.assertNotNull(serviceController.getValue()); }
Example #28
Source File: SecurityRealmAddHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private Supplier<CallbackHandlerService> addClientCertService(String realmName, ServiceTarget serviceTarget, ServiceBuilder<?> realmBuilder) { final ServiceName clientCertServiceName = ClientCertCallbackHandler.ServiceUtil.createServiceName(realmName); final ServiceBuilder<?> builder = serviceTarget.addService(clientCertServiceName); final Consumer<CallbackHandlerService> chsConsumer = builder.provides(clientCertServiceName); builder.setInstance(new ClientCertCallbackHandler(chsConsumer)); builder.setInitialMode(ON_DEMAND); builder.install(); return CallbackHandlerService.ServiceUtil.requires(realmBuilder, clientCertServiceName); }
Example #29
Source File: SaslServerDefinitions.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> runtimeCapability = SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue()); ServiceName saslServerFactoryName = runtimeCapability.getCapabilityServiceName(SaslServerFactory.class); commonDependencies(installService(context, saslServerFactoryName, model)) .setInitialMode(Mode.ACTIVE) .install(); }
Example #30
Source File: ExternalModuleService.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public ModuleIdentifier addExternalModule(String moduleName, String path, ServiceRegistry serviceRegistry, ServiceTarget serviceTarget) { ModuleIdentifier identifier = ModuleIdentifier.create(EXTERNAL_MODULE_PREFIX + moduleName); ServiceName serviceName = ServiceModuleLoader.moduleSpecServiceName(identifier); ServiceController<?> controller = serviceRegistry.getService(serviceName); if (controller == null) { ExternalModuleSpecService service = new ExternalModuleSpecService(identifier, new File(path)); serviceTarget.addService(serviceName) .setInstance(service) .setInitialMode(Mode.ON_DEMAND) .install(); } return identifier; }