org.jboss.msc.service.StartException Java Examples

The following examples show how to use org.jboss.msc.service.StartException. 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: ConsulService.java    From ARCHIVE-wildfly-swarm with Apache License 2.0 6 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {

    Consul.Builder builder = Consul.builder();


    // pool because of multiple threads.
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
    clientBuilder = clientBuilder.connectionPoolSize(20);

    builder.withClientBuilder(clientBuilder);
    builder.withUrl(this.url);

    try {
        this.consul = builder.build();
    } catch (Exception e) {
        throw new StartException("Failed to connect consul at "+url, e);
    }
}
 
Example #2
Source File: HttpServerDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static ResourceDefinition getServiceLoaderServerMechanismFactoryDefinition() {
    AttributeDefinition[] attributes = new AttributeDefinition[] { MODULE };
    AbstractAddStepHandler add = new TrivialAddHandler<HttpServerAuthenticationMechanismFactory>(HttpServerAuthenticationMechanismFactory.class, ServiceController.Mode.ACTIVE, ServiceController.Mode.PASSIVE, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY) {

        @Override
        protected ValueSupplier<HttpServerAuthenticationMechanismFactory> getValueSupplier(
                ServiceBuilder<HttpServerAuthenticationMechanismFactory> serviceBuilder, OperationContext context,
                ModelNode model) throws OperationFailedException {
            final String module = MODULE.resolveModelAttribute(context, model).asStringOrNull();

            return () -> {
                try {
                    ClassLoader classLoader = doPrivileged((PrivilegedExceptionAction<ClassLoader>) () -> resolveClassLoader(module));

                    return new SetMechanismInformationMechanismFactory(new ServiceLoaderServerMechanismFactory(classLoader));
                } catch (Exception e) {
                    throw new StartException(e);
                }
            };

        }
    };

    return wrapFactory(new TrivialResourceDefinition(ElytronDescriptionConstants.SERVICE_LOADER_HTTP_SERVER_MECHANISM_FACTORY,
            add, attributes, HTTP_SERVER_MECHANISM_FACTORY_RUNTIME_CAPABILITY));
}
 
Example #3
Source File: SSLDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static X509ExtendedKeyManager getX509KeyManager(KeyManager keyManager) throws StartException {
    if (keyManager == null) {
        return null;
    }
    if (keyManager instanceof X509ExtendedKeyManager) {
        X509ExtendedKeyManager x509KeyManager = (X509ExtendedKeyManager) keyManager;
        if (x509KeyManager instanceof DelegatingKeyManager && IS_FIPS.getAsBoolean()) {
            ROOT_LOGGER.trace("FIPS enabled on JVM, unwrapping KeyManager");
            // If FIPS is enabled unwrap the KeyManager
            x509KeyManager = ((DelegatingKeyManager) x509KeyManager).delegating.get();
        }

        return x509KeyManager;
    }
    throw ROOT_LOGGER.invalidTypeInjected(X509ExtendedKeyManager.class.getSimpleName());
}
 
Example #4
Source File: ServerInventoryService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** {@inheritDoc} */
@Override
public synchronized void start(StartContext context) throws StartException {
    ROOT_LOGGER.debug("Starting Host Controller Server Inventory");
    try {
        final ProcessControllerConnectionService processControllerConnectionService = client.getValue();
        URI managementURI = new URI(protocol, null, NetworkUtils.formatAddress(getNonWildCardManagementAddress()), port, null, null, null);
        serverInventory = new ServerInventoryImpl(domainController, environment, managementURI, processControllerConnectionService.getClient(), extensionRegistry);
        processControllerConnectionService.setServerInventory(serverInventory);
        serverCallback.getValue().setCallbackHandler(serverInventory.getServerCallbackHandler());
        if (domainServerCallback != null && domainServerCallback.getValue() != null) {
            domainServerCallback.getValue().setServerCallbackHandler(serverInventory.getServerCallbackHandler());
        }
        futureInventory.setInventory(serverInventory);
    } catch (Exception e) {
        futureInventory.setFailure(e);
        throw new StartException(e);
    }
}
 
Example #5
Source File: SecretIdentityService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void start(final StartContext startContext) throws StartException {
    final char[] thePassword;
    if (base64) {
        byte[] value = Base64.getDecoder().decode(password);
        String tempPassword = new String(value, StandardCharsets.ISO_8859_1);
        String trimmedPassword = tempPassword.trim();
        if (tempPassword.equals(trimmedPassword) == false) {
            ROOT_LOGGER.whitespaceTrimmed();
        }

        thePassword = trimmedPassword.toCharArray();
    } else {
        thePassword = password.toCharArray();
    }

    callbackHandlerFactoryConsumer.accept((String username) -> new SecretCallbackHandler(username, resolvePassword(thePassword)));
}
 
Example #6
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Case 2: principal name matches protocol/hostname
 */
@Test
public void testPrincipalWithProto() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "HTTP/SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", RIGHT_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "*", WRONG_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "EXAMPLE");

    Assert.assertNotNull(subjectIdentity);
    Assert.assertEquals("Different keytab used then expected.", subjectIdentity, RIGHT_SUBJECT_IDENTITY);
}
 
Example #7
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void invokePostDeploy(final ProcessApplicationInterface processApplication) throws ClassNotFoundException, StartException {
  Class<?> paClass = getPaClass(postDeployDescription);
  final Method postDeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, PostDeploy.class);

  if(postDeployMethod != null) {
    try {
      processApplication.execute(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          postDeployMethod.invoke(processApplication.getRawObject(), getInjections(postDeployMethod));
          return null;
        }
      });
    }catch(Exception e) {
      throw new StartException("Exception while invoking the @PostDeploy method ", e);
    }
  }

}
 
Example #8
Source File: FilteringKeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    try {
        KeyStore keyStore = keyStoreInjector.getValue();
        AliasFilter filter = AliasFilter.fromString(aliasFilter);
        KeyStore unmodifiable = UnmodifiableKeyStore.unmodifiableKeyStore(keyStore);
        KeyStore modifiable = keyStore;

        ROOT_LOGGER.tracef(
                "starting:  aliasFilter = %s  filter = %s  unmodifiable = %s  modifiable = %s",
                aliasFilter, filter, unmodifiable, modifiable);

        filteringKeyStore = FilteringKeyStore.filteringKeyStore(unmodifiable, filter);
        if (modifiableFilteringKeyStore == null) {
            modifiableFilteringKeyStore = FilteringKeyStore.filteringKeyStore(modifiable, filter);
        }
    } catch (Exception e) {
        throw new StartException(e);
    }
}
 
Example #9
Source File: PropertyFileFinder.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Map<String, String> loadAllGroups(List<File> foundGroupsFiles) throws StartException, IOException {
    Map<String, String> loadedGroups = new HashMap<String, String>();
    for (File file : foundGroupsFiles) {
        PropertiesFileLoader propertiesLoad = null;
        try {
            propertiesLoad = new PropertiesFileLoader(file.getCanonicalPath());
            propertiesLoad.start(null);
            loadedGroups.putAll((Map) propertiesLoad.getProperties());
        } finally {
            if (propertiesLoad != null) {
                propertiesLoad.stop(null);
            }
        }
    }
    return loadedGroups;
}
 
Example #10
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Case 4: principal hostname matches hostname
 */
@Test
public void testPrincipalWithoutProto() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "HTTP/SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "SOMEHOST", RIGHT_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "*", WRONG_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "EXAMPLE");

    Assert.assertNotNull(subjectIdentity);
    Assert.assertEquals("Different keytab used then expected.", subjectIdentity, RIGHT_SUBJECT_IDENTITY);
}
 
Example #11
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Case 3: for-hosts contains hostname
 */
@Test
public void testForHostWithoutProto() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "HTTP/SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "EXAMPLE", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", RIGHT_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "*", WRONG_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "EXAMPLE");

    Assert.assertNotNull(subjectIdentity);
    Assert.assertEquals("Different keytab used then expected.", subjectIdentity, RIGHT_SUBJECT_IDENTITY);
}
 
Example #12
Source File: BlockerExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
        public void start(final StartContext context) throws StartException {
            if (blockStart) {
//                Runnable r = new Runnable() {
//                    @Override
//                    public void run() {
                        try {
                            synchronized (waitObject) {
                                log.info("BlockService blocking in start");
                                waitObject.wait(blockTime);
                            }
                            context.complete();
                        } catch (InterruptedException e) {
                            log.info("BlockService interrupted");
//                            context.failed(new StartException(e));
                            throw new StartException(e);
                        }
//                    }
//                };
//                Thread thread = new Thread(r);
//                thread.start();
//                context.asynchronous();
            }
        }
 
Example #13
Source File: ServiceActivatorBaseDeployment.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    setProperty(propertyName, qualifier);
    System.out.println("===> " + this.getClass() + " setting property " + propertyName + "=" + qualifier);
    InputStream in = getClass().getResourceAsStream("overlay");
    if (in != null) {
        try {
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))){
                String s = reader.readLine();
                setProperty(overridePropertyName, s);
                System.out.println("===> " + this.getClass() + " setting property " + overridePropertyName + "=" + s);
            } catch (IOException e) {
                throw new StartException(e);
            }
        } finally {
            try {
                in.close();
            } catch (IOException ignore){
            }
        }
    }
}
 
Example #14
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Case 1: for-hosts contains protocol/hostname
 */
@Test
public void testForHostWithProto() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "HTTP/EXAMPLE", RIGHT_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "EXAMPLE", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "*", WRONG_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "EXAMPLE");

    Assert.assertNotNull(subjectIdentity);
    Assert.assertTrue("Different keytab used then expected.", subjectIdentity == RIGHT_SUBJECT_IDENTITY);
}
 
Example #15
Source File: MBeanServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** {@inheritDoc} */
public synchronized void start(final StartContext context) throws StartException {
    //If the platform MBeanServer was set up to be the PluggableMBeanServer, use that otherwise create a new one and delegate
    MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
    PluggableMBeanServerImpl pluggable = platform instanceof PluggableMBeanServerImpl ? (PluggableMBeanServerImpl)platform : new PluggableMBeanServerImpl(platform, null);
    MBeanServerDelegate delegate = platform instanceof PluggableMBeanServerImpl ? ((PluggableMBeanServerImpl)platform).getMBeanServerDelegate() : null;
    pluggable.setAuditLogger(auditLoggerInfo);
    pluggable.setAuthorizer(authorizer);
    pluggable.setSecurityIdentitySupplier(securityIdentitySupplier);
    pluggable.setJmxEffect(jmxEffect);
    authorizer.setNonFacadeMBeansSensitive(coreMBeanSensitivity);
    if (resolvedDomainName != null || expressionsDomainName != null) {
        //TODO make these configurable
        ConfiguredDomains configuredDomains = new ConfiguredDomains(resolvedDomainName, expressionsDomainName);
        showModelPlugin = new ModelControllerMBeanServerPlugin(pluggable, configuredDomains, modelControllerValue.getValue(),
                notificationRegistryValue.getValue(), delegate, legacyWithProperPropertyFormat, processType, managementModelProviderValue.getValue(), isMasterHc);
        pluggable.addPlugin(showModelPlugin);
    }
    mBeanServer = pluggable;
}
 
Example #16
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Case 5: default
 */
@Test
public void testDefault() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "HTTP/SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "*", RIGHT_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "EXAMPLE");

    Assert.assertNotNull(subjectIdentity);
    Assert.assertEquals("Different keytab used then expected.", subjectIdentity, RIGHT_SUBJECT_IDENTITY);
}
 
Example #17
Source File: FileTrustManagerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private synchronized X509TrustManager getDelegate() {
    if (theTrustStore.isModified()) {
        try {
            theTrustStore.load();
        } catch (StartException e1) {
            throw DomainManagementLogger.ROOT_LOGGER.unableToLoadKeyTrustFile(e1.getCause());
        }
        try {
            trustManagerFactory.init(theTrustStore.getKeyStore());
            TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
            for (TrustManager current : trustManagers) {
                if (current instanceof X509TrustManager) {
                    delegate = (X509TrustManager) current;
                    break;
                }
            }
        } catch (GeneralSecurityException e) {
            throw DomainManagementLogger.ROOT_LOGGER.unableToOperateOnTrustStore(e);

        }
    }
    if (delegate == null) {
        throw DomainManagementLogger.ROOT_LOGGER.unableToCreateDelegateTrustManager();
    }

    return delegate;
}
 
Example #18
Source File: PermissionMapperDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Permissions createPermissions(List<Permission> permissionsList, List<InjectedValue<Permissions>> permissionSetInjectors) throws StartException {
    Permissions allPermissions = createPermissions(permissionsList);
    for (InjectedValue<Permissions> permissionSetInjector : permissionSetInjectors) {
        Permissions permissionSet = permissionSetInjector.getValue();
        Enumeration<java.security.Permission> permissions = permissionSet.elements();
        while (permissions.hasMoreElements()) {
            allPermissions.add(permissions.nextElement());
        }
    }
    return allPermissions;
}
 
Example #19
Source File: NetworkInterfaceService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public synchronized void start(StartContext arg0) throws StartException {
    log.debug("Starting NetworkInterfaceService\n");
    try {
        this.interfaceBinding = createBinding(anyLocal, criteria);
    } catch (Exception e) {
        throw new StartException(e);
    }
    if (this.interfaceBinding == null) {
        throw ServerLogger.ROOT_LOGGER.failedToResolveInterface(name);
    }
    log.debugf("NetworkInterfaceService matched interface binding: %s\n", interfaceBinding);
}
 
Example #20
Source File: AddUserTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Assert that the enabled/disabled user is correctly added to the user and roles files.
 * @param expectedPassword The expected password
 * @param expectedGroups The expected groups
 * @param previousRoleFileLineNumber The number of lines of the roles file before enabling/disabling the user
 * @param previousUserFileLineNumber The number of lines of the user file before enabling/disabling the user
 * @param assertConsole The console to validate the output
 * @throws StartException
 * @throws IOException
 */
private void assertEnableDisableUser(String expectedPassword, String expectedGroups, int previousRoleFileLineNumber, int previousUserFileLineNumber, AssertConsoleBuilder assertConsole) throws StartException, IOException {
    assertRolePropertyFile(values.getUserName(), expectedGroups);
    assertUserPropertyFile(values.getUserName(), expectedPassword);
    if (previousRoleFileLineNumber > 0) {
        assertEquals("Enabling/disabling a role just uncomment/comment out the line and must not create a new one", previousRoleFileLineNumber, countLineNumberRoleFile());
    }
    if (previousUserFileLineNumber > 0) {
        assertEquals("Enabling/disabling a user just uncomment/comment out the line and must not create a new one", previousUserFileLineNumber, countLineNumberUserFile());
    }
    assertConsole.validate();
}
 
Example #21
Source File: TestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext context) throws StartException {
    if (initializer != null) {
        initializer.setDelegate();
    }
    super.start(context);
    latch.countDown();
}
 
Example #22
Source File: KeyStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Provider resolveProvider() throws StartException {
    Provider[] candidates = providers.getOptionalValue();
    Supplier<Provider[]> providersSupplier = () -> candidates == null ? Security.getProviders() : candidates;
    Provider identified = findProvider(providersSupplier, provider, KeyStore.class, type);
    if (identified == null) {
        throw ROOT_LOGGER.noSuitableProvider(type);
    }
    return identified;
}
 
Example #23
Source File: AggregateComponentService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @see org.jboss.msc.service.Service#start(org.jboss.msc.service.StartContext)
 */
@SuppressWarnings("unchecked")
@Override
public void start(StartContext context) throws StartException {
    ArrayList<T> toAggregate = new ArrayList<T>(injections.size());
    for (InjectedValue<T> current : injections) {
        toAggregate.add(current.getValue());
    }

    aggregation = aggregator.apply(toAggregate.toArray((T[])Array.newInstance(aggregationType, toAggregate.size())));
}
 
Example #24
Source File: ServerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void start(StartContext context) throws StartException {
    if (EnhancedQueueExecutor.DISABLE_HINT) {
        executorService = new ThreadPoolExecutor(getCorePoolSize(forDomain), Integer.MAX_VALUE, 20L, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(), threadFactory);
    } else {
        executorService = new EnhancedQueueExecutor.Builder()
            .setCorePoolSize(getCorePoolSize(forDomain))
            .setMaximumPoolSize(1024)
            .setKeepAliveTime(20L, TimeUnit.SECONDS)
            .setThreadFactory(threadFactory)
            .build();
    }
}
 
Example #25
Source File: CamelUndertowHostService.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    runtimeState.setHttpHost(getConnectionURL());
    eventListener = new CamelUndertowEventListener();
    injectedUndertowService.getValue().registerListener(eventListener);
    undertowHost = new WildFlyUndertowHost(injectedDefaultHost.getValue());
}
 
Example #26
Source File: CredentialStoreService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void start(StartContext startContext) throws StartException {
    Path loc = location == null ? null : resolveLocation();
    try {
        ROOT_LOGGER.tracef("starting CredentialStore:  name = %s", name);
        credentialStoreAttributes.put(CS_LOCATION_ATTRIBUTE, loc == null ? null : loc.toAbsolutePath().toString());
        CredentialStore cs = getCredentialStoreInstance();
        Provider[] otherProvidersArr = otherProviders.getOptionalValue();
        if (ROOT_LOGGER.isTraceEnabled()) {
            ROOT_LOGGER.tracef(
                    "initializing CredentialStore:  name = %s  type = %s  provider = %s  otherProviders = %s  attributes = %s",
                    name, type, provider, Arrays.toString(otherProvidersArr), credentialStoreAttributes
            );
        }
        synchronized (EmptyProvider.getInstance()) {
            cs.initialize(credentialStoreAttributes, resolveCredentialStoreProtectionParameter(), otherProvidersArr);
        }
        if (credentialStoreAttributes.get(ElytronDescriptionConstants.CREATE).equals("true") && loc != null && !loc.toFile().exists()){
            ROOT_LOGGER.tracef("CredentialStore %s does not exist, creating", name);
            cs.flush();
        }
        credentialStore.set(cs);
        ROOT_LOGGER.tracef("CredentialStore started:  name = %s  credentialStore = %s", name, cs);
    } catch (Exception e) {
        throw ElytronSubsystemMessages.ROOT_LOGGER.unableToStartService(e);
    }
}
 
Example #27
Source File: AddUserTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testEnableDisabledUser_keepRolesPassword() throws IOException, StartException {
    // Disable user
    disableUser("Omar.Ulmer", UUID.randomUUID().toString(), ROLES);
    // Enable user with the same roles(groups)/password
    enableUser("Omar.Ulmer", null, null);
}
 
Example #28
Source File: AddUserTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Test
public void testEnableEnabledUser() throws IOException, StartException {
    // Enable user
    enableUser("Aldo.Raine", UUID.randomUUID().toString(), ROLES);
    // (Re)Enable user
    enableUser("Aldo.Raine", null, null);
}
 
Example #29
Source File: SSLDefinitions.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static X509ExtendedTrustManager getX509TrustManager(TrustManager trustManager) throws StartException {
    if (trustManager == null) {
        return null;
    }
    if (trustManager instanceof X509ExtendedTrustManager) {
        X509ExtendedTrustManager x509TrustManager = (X509ExtendedTrustManager) trustManager;
        if (x509TrustManager instanceof DelegatingTrustManager && IS_FIPS.getAsBoolean()) {
            ROOT_LOGGER.trace("FIPS enabled on JVM, unwrapping TrustManager");
            x509TrustManager = ((DelegatingTrustManager)x509TrustManager).delegating.get();
        }
        return x509TrustManager;
    }
    throw ROOT_LOGGER.invalidTypeInjected(X509ExtendedTrustManager.class.getSimpleName());
}
 
Example #30
Source File: KeytabIdentityFactoryServiceTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Host name should be case insensitive according to The Kerberos Network Authentication Service (V5)
 */
@Test
public void testHostNameCaseInSensitive() throws StartException {
    KeytabIdentityFactoryService service = new KeytabIdentityFactoryService(null);
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", RIGHT_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("HTTP/[email protected]", "SOMEHOST", WRONG_SUBJECT_IDENTITY));
    service.addKeytabSupplier(createKeytabService("PROTO/[email protected]", "localhost", WRONG_SUBJECT_IDENTITY));
    service.start(null);

    SubjectIdentity subjectIdentity = service.getSubjectIdentity("HTTP", "LocalHost");
    service.stop(null);

    Assert.assertNotNull(subjectIdentity);
    Assert.assertTrue("Different keytab used then expected.", subjectIdentity == RIGHT_SUBJECT_IDENTITY);
}