Package org.jboss.security

Examples of org.jboss.security.JBossJSSESecurityDomain


        return applicationPolicy;
    }

    private JSSESecurityDomain createJSSESecurityDomain(String securityDomain, ModelNode operation) {
        JBossJSSESecurityDomain jsseSecurityDomain = null;
        ModelNode node = operation.get(JSSE);
        if (node.isDefined()) {
            jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
            String value = null;
            if (node.hasDefined(KEYSTORE_PASSWORD)) {
                value = node.get(KEYSTORE_PASSWORD).asString();
                try {
                    jsseSecurityDomain.setKeyStorePassword(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(KEYSTORE_TYPE)) {
                value = node.get(KEYSTORE_TYPE).asString();
                jsseSecurityDomain.setKeyStoreType(value);
            }
            if (node.hasDefined(KEYSTORE_URL)) {
                value = node.get(KEYSTORE_URL).asString();
                try {
                    jsseSecurityDomain.setKeyStoreURL(value);
                } catch (IOException ioe) {
                    throw new IllegalArgumentException(ioe);
                }
            }
            if (node.hasDefined(KEYSTORE_PROVIDER)) {
                value = node.get(KEYSTORE_PROVIDER).asString();
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            if (node.hasDefined(KEYSTORE_PROVIDER_ARGUMENT)) {
                value = node.get(KEYSTORE_PROVIDER_ARGUMENT).asString();
                jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
            if (node.hasDefined(KEY_MANAGER_FACTORY_PROVIDER)) {
                value = node.get(KEY_MANAGER_FACTORY_PROVIDER).asString();
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
            if (node.hasDefined(KEY_MANAGER_FACTORY_ALGORITHM)) {
                value = node.get(KEY_MANAGER_FACTORY_ALGORITHM).asString();
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            if (node.hasDefined(TRUSTSTORE_PASSWORD)) {
                value = node.get(TRUSTSTORE_PASSWORD).asString();
                try {
                    jsseSecurityDomain.setTrustStorePassword(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(TRUSTSTORE_TYPE)) {
                value = node.get(TRUSTSTORE_TYPE).asString();
                jsseSecurityDomain.setTrustStoreType(value);
            }
            if (node.hasDefined(TRUSTSTORE_URL)) {
                value = node.get(TRUSTSTORE_URL).asString();
                try {
                    jsseSecurityDomain.setTrustStoreURL(value);
                } catch (IOException ioe) {
                    throw new IllegalArgumentException(ioe);
                }
            }
            if (node.hasDefined(TRUSTSTORE_PROVIDER)) {
                value = node.get(TRUSTSTORE_PROVIDER).asString();
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            if (node.hasDefined(TRUSTSTORE_PROVIDER_ARGUMENT)) {
                value = node.get(TRUSTSTORE_PROVIDER_ARGUMENT).asString();
                jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
            if (node.hasDefined(TRUST_MANAGER_FACTORY_PROVIDER)) {
                value = node.get(TRUST_MANAGER_FACTORY_PROVIDER).asString();
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
            if (node.hasDefined(TRUST_MANAGER_FACTORY_ALGORITHM)) {
                value = node.get(TRUST_MANAGER_FACTORY_ALGORITHM).asString();
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            if (node.hasDefined(CLIENT_ALIAS)) {
                value = node.get(CLIENT_ALIAS).asString();
                jsseSecurityDomain.setClientAlias(value);
            }
            if (node.hasDefined(SERVER_ALIAS)) {
                value = node.get(SERVER_ALIAS).asString();
                jsseSecurityDomain.setServerAlias(value);
            }
            if (node.hasDefined(CLIENT_AUTH)) {
                boolean clientAuth = node.get(CLIENT_AUTH).asBoolean();
                jsseSecurityDomain.setClientAuth(clientAuth);
            }
            if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
                value = node.get(SERVICE_AUTH_TOKEN).asString();
                try {
                    jsseSecurityDomain.setServiceAuthToken(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(CIPHER_SUITES)) {
                value = node.get(CIPHER_SUITES).asString();
                jsseSecurityDomain.setCipherSuites(value);
            }
            if (node.hasDefined(PROTOCOLS)) {
                value = node.get(PROTOCOLS).asString();
                jsseSecurityDomain.setProtocols(value);
            }
            if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
                value = node.get(ADDITIONAL_PROPERTIES).asString();
                // remove line breaks and tab
                value = value.replaceAll("\\r", "").replaceAll("\\n", "").replaceAll("\\t", "");
                String[] entries = value.split(";");
                Properties properties = new Properties();
                for (int i = 0; i < entries.length; i++) {
                    String tmp = entries[i];
                    // trim leading white spaces
                    tmp = tmp.replaceAll("^\\s+", "");
                    String[] entry = tmp.split("=");
                    properties.put(entry[0], entry[1]);
                }
                jsseSecurityDomain.setAdditionalProperties(properties);
            }
        }

        return jsseSecurityDomain;
    }
View Full Code Here


    }

    public static HttpClient wrapClient(HttpClient base, String alias) {
        try {
            SSLContext ctx = SSLContext.getInstance("TLS");
            JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain("client-cert");
            jsseSecurityDomain.setKeyStorePassword("changeit");
            ClassLoader tccl = Thread.currentThread().getContextClassLoader();
            URL keystore = tccl.getResource("security/client.keystore");
            jsseSecurityDomain.setKeyStoreURL(keystore.getPath());
            jsseSecurityDomain.setClientAlias(alias);
            jsseSecurityDomain.reloadKeyAndTrustStore();
            KeyManager[] keyManagers = jsseSecurityDomain.getKeyManagers();
            TrustManager[] trustManagers = jsseSecurityDomain.getTrustManagers();
            ctx.init(keyManagers, trustManagers, null);
            SSLSocketFactory ssf = new SSLSocketFactory(ctx, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            ClientConnectionManager ccm = base.getConnectionManager();
            SchemeRegistry sr = ccm.getSchemeRegistry();
            sr.register(new Scheme("https", 8380, ssf));
View Full Code Here

    }

    public static HttpClient wrapClient(HttpClient base, String alias) {
        try {
            SSLContext ctx = SSLContext.getInstance("TLS");
            JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain("client-cert");
            jsseSecurityDomain.setKeyStorePassword("changeit");
            ClassLoader tccl = Thread.currentThread().getContextClassLoader();
            URL keystore = tccl.getResource("security/client.keystore");
            jsseSecurityDomain.setKeyStoreURL(keystore.getPath());
            jsseSecurityDomain.setClientAlias(alias);
            jsseSecurityDomain.reloadKeyAndTrustStore();
            KeyManager[] keyManagers = jsseSecurityDomain.getKeyManagers();
            TrustManager[] trustManagers = jsseSecurityDomain.getTrustManagers();
            ctx.init(keyManagers, trustManagers, null);
            X509HostnameVerifier verifier = new X509HostnameVerifier() {

                @Override
                public void verify(String s, SSLSocket sslSocket) throws IOException {
View Full Code Here

    private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node)
            throws OperationFailedException {
        node = peek(node, JSSE, CLASSIC);
        if (node == null) { return null; }

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);


        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }

            public void setKeyStoreType(String value) {
                jsseSecurityDomain.setKeyStoreType(value);
            }

            public void setKeyStoreURL(String value) throws IOException {
                jsseSecurityDomain.setKeyStoreURL(value);
            }

            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }

            public void setKeyStoreProviderArgument(String value) {
                jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }

            public void setKeyStoreType(String value) {
                jsseSecurityDomain.setTrustStoreType(value);
            }

            public void setKeyStoreURL(String value) throws IOException {
                jsseSecurityDomain.setTrustStoreURL(value);
            }

            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }

            public void setKeyStoreProviderArgument(String value) {
                jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }

            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

        processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }

            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });
        String value;
        if (node.hasDefined(CLIENT_ALIAS)) {
            value = JSSEResourceDefinition.CLIENT_ALIAS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = JSSEResourceDefinition.SERVER_ALIAS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = JSSEResourceDefinition.CLIENT_AUTH.resolveModelAttribute(context, node).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = JSSEResourceDefinition.SERVICE_AUTH_TOKEN.resolveModelAttribute(context, node).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw SecurityLogger.ROOT_LOGGER.runtimeException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = JSSEResourceDefinition.CIPHER_SUITES.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = JSSEResourceDefinition.PROTOCOLS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            properties.putAll(JSSEResourceDefinition.ADDITIONAL_PROPERTIES.unwrap(context, node));
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

    private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node)
            throws OperationFailedException {
        node = peek(node, JSSE, CLASSIC);
        if (node == null) { return null; }

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);


        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }

            public void setKeyStoreType(String value) {
                jsseSecurityDomain.setKeyStoreType(value);
            }

            public void setKeyStoreURL(String value) throws IOException {
                jsseSecurityDomain.setKeyStoreURL(value);
            }

            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }

            public void setKeyStoreProviderArgument(String value) {
                jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }

            public void setKeyStoreType(String value) {
                jsseSecurityDomain.setTrustStoreType(value);
            }

            public void setKeyStoreURL(String value) throws IOException {
                jsseSecurityDomain.setTrustStoreURL(value);
            }

            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }

            public void setKeyStoreProviderArgument(String value) {
                jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }

            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

        processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }

            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });
        String value;
        if (node.hasDefined(CLIENT_ALIAS)) {
            value = JSSEResourceDefinition.CLIENT_ALIAS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = JSSEResourceDefinition.SERVER_ALIAS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = JSSEResourceDefinition.CLIENT_AUTH.resolveModelAttribute(context, node).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = JSSEResourceDefinition.SERVICE_AUTH_TOKEN.resolveModelAttribute(context, node).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw SecurityMessages.MESSAGES.runtimeException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = JSSEResourceDefinition.CIPHER_SUITES.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = JSSEResourceDefinition.PROTOCOLS.resolveModelAttribute(context, node).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            properties.putAll(JSSEResourceDefinition.ADDITIONAL_PROPERTIES.unwrap(context, node));
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

    private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) {
        node = peek(node, JSSE, CLASSIC);
        if (node == null)
            return null;

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
        String value = null;

        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setKeyStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setKeyStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setTrustStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setTrustStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

         processKeyManager(node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });

        if (node.hasDefined(CLIENT_ALIAS)) {
            value = node.get(CLIENT_ALIAS).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = node.get(SERVER_ALIAS).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = node.get(CLIENT_AUTH).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = node.get(SERVICE_AUTH_TOKEN).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw SecurityMessages.MESSAGES.runtimeException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = node.get(CIPHER_SUITES).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = node.get(PROTOCOLS).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            for (Property prop : node.get(ADDITIONAL_PROPERTIES).asPropertyList()) {
                properties.setProperty(prop.getName(), prop.getValue().asString());
            }
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

            throws OperationFailedException {
        node = peek(node, JSSE, CLASSIC);
        if (node == null)
            return null;

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
        String value = null;

        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setKeyStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setKeyStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setTrustStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setTrustStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(context, node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

         processKeyManager(context, node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });

        if (node.hasDefined(CLIENT_ALIAS)) {
            value = context.resolveExpressions(node.get(CLIENT_ALIAS)).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = context.resolveExpressions(node.get(SERVER_ALIAS)).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = context.resolveExpressions(node.get(CLIENT_AUTH)).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = context.resolveExpressions(node.get(SERVICE_AUTH_TOKEN)).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw SecurityMessages.MESSAGES.runtimeException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = context.resolveExpressions(node.get(CIPHER_SUITES)).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = context.resolveExpressions(node.get(PROTOCOLS)).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            for (Property prop : node.get(ADDITIONAL_PROPERTIES).asPropertyList()) {
                properties.setProperty(prop.getName(), prop.getValue().asString());
            }
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

        return applicationPolicy;
    }

    private JSSESecurityDomain createJSSESecurityDomain(String securityDomain, ModelNode operation) {
        JBossJSSESecurityDomain jsseSecurityDomain = null;
        ModelNode node = operation.get(JSSE);
        if (node.isDefined()) {
            jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
            String value = null;
            if (node.hasDefined(KEYSTORE_PASSWORD)) {
                value = node.get(KEYSTORE_PASSWORD).asString();
                try {
                    jsseSecurityDomain.setKeyStorePassword(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(KEYSTORE_TYPE)) {
                value = node.get(KEYSTORE_TYPE).asString();
                jsseSecurityDomain.setKeyStoreType(value);
            }
            if (node.hasDefined(KEYSTORE_URL)) {
                value = node.get(KEYSTORE_URL).asString();
                try {
                    jsseSecurityDomain.setKeyStoreURL(value);
                } catch (IOException ioe) {
                    throw new IllegalArgumentException(ioe);
                }
            }
            if (node.hasDefined(KEYSTORE_PROVIDER)) {
                value = node.get(KEYSTORE_PROVIDER).asString();
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            if (node.hasDefined(KEYSTORE_PROVIDER_ARGUMENT)) {
                value = node.get(KEYSTORE_PROVIDER_ARGUMENT).asString();
                jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
            if (node.hasDefined(KEY_MANAGER_FACTORY_PROVIDER)) {
                value = node.get(KEY_MANAGER_FACTORY_PROVIDER).asString();
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
            if (node.hasDefined(KEY_MANAGER_FACTORY_ALGORITHM)) {
                value = node.get(KEY_MANAGER_FACTORY_ALGORITHM).asString();
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            if (node.hasDefined(TRUSTSTORE_PASSWORD)) {
                value = node.get(TRUSTSTORE_PASSWORD).asString();
                try {
                    jsseSecurityDomain.setTrustStorePassword(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(TRUSTSTORE_TYPE)) {
                value = node.get(TRUSTSTORE_TYPE).asString();
                jsseSecurityDomain.setTrustStoreType(value);
            }
            if (node.hasDefined(TRUSTSTORE_URL)) {
                value = node.get(TRUSTSTORE_URL).asString();
                try {
                    jsseSecurityDomain.setTrustStoreURL(value);
                } catch (IOException ioe) {
                    throw new IllegalArgumentException(ioe);
                }
            }
            if (node.hasDefined(TRUSTSTORE_PROVIDER)) {
                value = node.get(TRUSTSTORE_PROVIDER).asString();
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            if (node.hasDefined(TRUSTSTORE_PROVIDER_ARGUMENT)) {
                value = node.get(TRUSTSTORE_PROVIDER_ARGUMENT).asString();
                jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
            if (node.hasDefined(TRUST_MANAGER_FACTORY_PROVIDER)) {
                value = node.get(TRUST_MANAGER_FACTORY_PROVIDER).asString();
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
            if (node.hasDefined(TRUST_MANAGER_FACTORY_ALGORITHM)) {
                value = node.get(TRUST_MANAGER_FACTORY_ALGORITHM).asString();
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            if (node.hasDefined(CLIENT_ALIAS)) {
                value = node.get(CLIENT_ALIAS).asString();
                jsseSecurityDomain.setClientAlias(value);
            }
            if (node.hasDefined(SERVER_ALIAS)) {
                value = node.get(SERVER_ALIAS).asString();
                jsseSecurityDomain.setServerAlias(value);
            }
            if (node.hasDefined(CLIENT_AUTH)) {
                boolean clientAuth = node.get(CLIENT_AUTH).asBoolean();
                jsseSecurityDomain.setClientAuth(clientAuth);
            }
            if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
                value = node.get(SERVICE_AUTH_TOKEN).asString();
                try {
                    jsseSecurityDomain.setServiceAuthToken(value);
                } catch (Exception e) {
                    throw new IllegalArgumentException(e);
                }
            }
            if (node.hasDefined(CIPHER_SUITES)) {
                value = node.get(CIPHER_SUITES).asString();
                jsseSecurityDomain.setCipherSuites(value);
            }
            if (node.hasDefined(PROTOCOLS)) {
                value = node.get(PROTOCOLS).asString();
                jsseSecurityDomain.setProtocols(value);
            }
            if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
                value = node.get(ADDITIONAL_PROPERTIES).asString();
                // remove line breaks and tab
                value = value.replaceAll("\\r", "").replaceAll("\\n", "").replaceAll("\\t", "");
                String[] entries = value.split(";");
                Properties properties = new Properties();
                for (int i = 0; i < entries.length; i++) {
                    String tmp = entries[i];
                    // trim leading white spaces
                    tmp = tmp.replaceAll("^\\s+", "");
                    String[] entry = tmp.split("=");
                    properties.put(entry[0], entry[1]);
                }
                jsseSecurityDomain.setAdditionalProperties(properties);
            }
        }

        return jsseSecurityDomain;
    }
View Full Code Here

    private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) {
        node = peek(node, JSSE, CLASSIC);
        if (node == null)
            return null;

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
        String value = null;

        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setKeyStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setKeyStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setTrustStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setTrustStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

         processKeyManager(node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });

        if (node.hasDefined(CLIENT_ALIAS)) {
            value = node.get(CLIENT_ALIAS).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = node.get(SERVER_ALIAS).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = node.get(CLIENT_AUTH).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = node.get(SERVICE_AUTH_TOKEN).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw new IllegalArgumentException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = node.get(CIPHER_SUITES).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = node.get(PROTOCOLS).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            for (Property prop : node.get(ADDITIONAL_PROPERTIES).asPropertyList()) {
                properties.setProperty(prop.getName(), prop.getValue().asString());
            }
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

    private JSSESecurityDomain createJSSESecurityDomain(OperationContext context, String securityDomain, ModelNode node) {
        node = peek(node, JSSE, CLASSIC);
        if (node == null)
            return null;

        final JBossJSSESecurityDomain jsseSecurityDomain = new JBossJSSESecurityDomain(securityDomain);
        String value = null;

        processKeyStore(context, node, KEYSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setKeyStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setKeyStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setKeyStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setKeyStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setKeyStoreProviderArgument(value);
            }
        });

        processKeyStore(context, node, Constants.TRUSTSTORE, new KeyStoreConfig() {
            public void setKeyStorePassword(String value) throws Exception {
                jsseSecurityDomain.setTrustStorePassword(value);
            }
            public void setKeyStoreType(String value) {
                 jsseSecurityDomain.setTrustStoreType(value);
            }
            public void setKeyStoreURL(String value) throws IOException {
                 jsseSecurityDomain.setTrustStoreURL(value);
            }
            public void setKeyStoreProvider(String value) {
                jsseSecurityDomain.setTrustStoreProvider(value);
            }
            public void setKeyStoreProviderArgument(String value) {
                 jsseSecurityDomain.setTrustStoreProviderArgument(value);
            }
        });

        processKeyManager(node, Constants.KEY_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setKeyManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setKeyManagerFactoryProvider(value);
            }
        });

         processKeyManager(node, Constants.TRUST_MANAGER, new KeyManagerConfig() {
            public void setKeyManagerFactoryAlgorithm(String value) {
                jsseSecurityDomain.setTrustManagerFactoryAlgorithm(value);
            }
            public void setKeyManagerFactoryProvider(String value) {
                jsseSecurityDomain.setTrustManagerFactoryProvider(value);
            }
        });

        if (node.hasDefined(CLIENT_ALIAS)) {
            value = node.get(CLIENT_ALIAS).asString();
            jsseSecurityDomain.setClientAlias(value);
        }
        if (node.hasDefined(SERVER_ALIAS)) {
            value = node.get(SERVER_ALIAS).asString();
            jsseSecurityDomain.setServerAlias(value);
        }
        if (node.hasDefined(CLIENT_AUTH)) {
            boolean clientAuth = node.get(CLIENT_AUTH).asBoolean();
            jsseSecurityDomain.setClientAuth(clientAuth);
        }
        if (node.hasDefined(SERVICE_AUTH_TOKEN)) {
            value = node.get(SERVICE_AUTH_TOKEN).asString();
            try {
                jsseSecurityDomain.setServiceAuthToken(value);
            } catch (Exception e) {
                throw new IllegalArgumentException(e);
            }
        }
        if (node.hasDefined(CIPHER_SUITES)) {
            value = node.get(CIPHER_SUITES).asString();
            jsseSecurityDomain.setCipherSuites(value);
        }
        if (node.hasDefined(PROTOCOLS)) {
            value = node.get(PROTOCOLS).asString();
            jsseSecurityDomain.setProtocols(value);
        }
        if (node.hasDefined(ADDITIONAL_PROPERTIES)) {
            Properties properties = new Properties();
            for (Property prop : node.get(ADDITIONAL_PROPERTIES).asPropertyList()) {
                properties.setProperty(prop.getName(), prop.getValue().asString());
            }
            jsseSecurityDomain.setAdditionalProperties(properties);
        }

        return jsseSecurityDomain;
    }
View Full Code Here

TOP

Related Classes of org.jboss.security.JBossJSSESecurityDomain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.