legacy/web/src/main/java/org/jboss/as/web/WebMigrateOperation.java
private SSLInformation createSecurityRealm(OperationContext context, Map<PathAddress, ModelNode> migrationOperations, ModelNode legacyModelAddOps, String connector, ModelNode legacyAddOp, List<String> warnings, boolean domainMode) {

        //read all the info from the SSL definition
        ModelNode keyAlias = legacyAddOp.get(WebSSLDefinition.KEY_ALIAS.getName());
        ModelNode password = legacyAddOp.get(WebSSLDefinition.PASSWORD.getName());
        ModelNode certificateKeyFile = legacyAddOp.get(WebSSLDefinition.CERTIFICATE_KEY_FILE.getName());
        ModelNode cipherSuite = legacyAddOp.get(WebSSLDefinition.CIPHER_SUITE.getName());
        ModelNode protocol = legacyAddOp.get(WebSSLDefinition.PROTOCOL.getName());
        ModelNode verifyClient = legacyAddOp.get(WebSSLDefinition.VERIFY_CLIENT.getName());
        ModelNode verifyDepth = legacyAddOp.get(WebSSLDefinition.VERIFY_DEPTH.getName());
        ModelNode certificateFile = legacyAddOp.get(WebSSLDefinition.CERTIFICATE_FILE.getName());
        ModelNode caCertificateFile = legacyAddOp.get(WebSSLDefinition.CA_CERTIFICATE_FILE.getName());
        ModelNode caCertificatePassword = legacyAddOp.get(WebSSLDefinition.CA_CERTIFICATE_PASSWORD.getName());
        ModelNode csRevocationURL = legacyAddOp.get(WebSSLDefinition.CA_REVOCATION_URL.getName());
        ModelNode trustStoreType = legacyAddOp.get(WebSSLDefinition.TRUSTSTORE_TYPE.getName());
        ModelNode keystoreType = legacyAddOp.get(WebSSLDefinition.KEYSTORE_TYPE.getName());
        ModelNode sessionCacheSize = legacyAddOp.get(WebSSLDefinition.SESSION_CACHE_SIZE.getName());
        ModelNode sessionTimeout = legacyAddOp.get(WebSSLDefinition.SESSION_TIMEOUT.getName());
        ModelNode sslProvider = legacyAddOp.get(WebSSLDefinition.SSL_PROTOCOL.getName());

        if(verifyDepth.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.VERIFY_DEPTH.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        if(certificateFile.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.CERTIFICATE_FILE.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        if(sslProvider.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.SSL_PROTOCOL.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }

        if(csRevocationURL.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.CA_REVOCATION_URL.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        String realmName;
        PathAddress managementCoreService;
        if(domainMode) {
            Set<String> hosts = new HashSet<>();
            Resource hostResource = context.readResourceFromRoot(pathAddress(), false);
            hosts.addAll(hostResource.getChildrenNames(HOST));

            //now we need to find a unique name
            //in domain mode different profiles could have different SSL configurations
            //but the realms are not scoped to a profile
            //if we hard coded a name migration would fail when migrating domains with multiple profiles
            int counter = 1;
            realmName = REALM_NAME + counter;
            while(true) {
                boolean hostOk = true;
                for(String host : hosts) {
                    Resource root = context.readResourceFromRoot(pathAddress(pathElement(HOST, host), pathElement(CORE_SERVICE, MANAGEMENT)), false);
                    if (root.getChildrenNames(SECURITY_REALM).contains(realmName)) {
                        counter++;
                        realmName = REALM_NAME + counter;
                        hostOk = false;
                        break;
                    }
                }
                if(hostOk) {
                    break;
                }
            }
            for (String host : hosts) {
                createHostSSLConfig(realmName, migrationOperations, keyAlias, password, certificateKeyFile, protocol, caCertificateFile, caCertificatePassword, trustStoreType, keystoreType, pathAddress(pathElement(HOST, host), pathElement(CORE_SERVICE, MANAGEMENT)));
            }

        } else {
            managementCoreService = pathAddress(CORE_SERVICE, MANAGEMENT);
            //now we need to find a unique name
            //in domain mode different profiles could have different SSL configurations
            //but the realms are not scoped to a profile
            //if we hard coded a name migration would fail when migrating domains with multiple profiles
            int counter = 1;
            realmName = REALM_NAME + counter;
            boolean ok = false;
            do {
                Resource root = context.readResourceFromRoot(managementCoreService, false);
                if (root.getChildrenNames(SECURITY_REALM).contains(realmName)) {
                    counter++;
                    realmName = REALM_NAME + counter;
                } else {
                    ok = true;
                }
            } while (!ok);

            //we have a unique realm name
            createHostSSLConfig(realmName, migrationOperations, keyAlias, password, certificateKeyFile, protocol, caCertificateFile, caCertificatePassword, trustStoreType, keystoreType, managementCoreService);

        }

        return new SSLInformation(realmName, verifyClient, sessionCacheSize, sessionTimeout, protocol, cipherSuite);
    }
private SSLInformation createSecurityRealm(OperationContext context, Map<PathAddress, ModelNode> migrationOperations, ModelNode legacyModelAddOps, String connector, ModelNode legacyAddOp, List<String> warnings, boolean domainMode) {

        //read all the info from the SSL definition
        ModelNode keyAlias = legacyAddOp.get(WebSSLDefinition.KEY_ALIAS.getName());
        ModelNode password = legacyAddOp.get(WebSSLDefinition.PASSWORD.getName());
        ModelNode certificateKeyFile = legacyAddOp.get(WebSSLDefinition.CERTIFICATE_KEY_FILE.getName());
        ModelNode cipherSuite = legacyAddOp.get(WebSSLDefinition.CIPHER_SUITE.getName());
        ModelNode protocol = legacyAddOp.get(WebSSLDefinition.PROTOCOL.getName());
        ModelNode verifyClient = legacyAddOp.get(WebSSLDefinition.VERIFY_CLIENT.getName());
        ModelNode verifyDepth = legacyAddOp.get(WebSSLDefinition.VERIFY_DEPTH.getName());
        ModelNode certificateFile = legacyAddOp.get(WebSSLDefinition.CERTIFICATE_FILE.getName());
        ModelNode caCertificateFile = legacyAddOp.get(WebSSLDefinition.CA_CERTIFICATE_FILE.getName());
        ModelNode caCertificatePassword = legacyAddOp.get(WebSSLDefinition.CA_CERTIFICATE_PASSWORD.getName());
        ModelNode csRevocationURL = legacyAddOp.get(WebSSLDefinition.CA_REVOCATION_URL.getName());
        ModelNode trustStoreType = legacyAddOp.get(WebSSLDefinition.TRUSTSTORE_TYPE.getName());
        ModelNode keystoreType = legacyAddOp.get(WebSSLDefinition.KEYSTORE_TYPE.getName());
        ModelNode sessionCacheSize = legacyAddOp.get(WebSSLDefinition.SESSION_CACHE_SIZE.getName());
        ModelNode sessionTimeout = legacyAddOp.get(WebSSLDefinition.SESSION_TIMEOUT.getName());
        ModelNode sslProvider = legacyAddOp.get(WebSSLDefinition.SSL_PROTOCOL.getName());

        if(verifyDepth.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.VERIFY_DEPTH.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        if(certificateFile.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.CERTIFICATE_FILE.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        if(sslProvider.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.SSL_PROTOCOL.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }

        if(csRevocationURL.isDefined()) {
            warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateResource(WebSSLDefinition.CA_REVOCATION_URL.getName(), pathAddress(legacyAddOp.get(ADDRESS))));
        }
        String realmName;
        PathAddress managementCoreService;
        if(domainMode) {
            Set<String> hosts = new HashSet<>();
            Resource hostResource = context.readResourceFromRoot(pathAddress(), false);
            hosts.addAll(hostResource.getChildrenNames(HOST));

            //now we need to find a unique name
            //in domain mode different profiles could have different SSL configurations
            //but the realms are not scoped to a profile
            //if we hard coded a name migration would fail when migrating domains with multiple profiles
            int counter = 1;
            realmName = REALM_NAME + counter;
            while(true) {
                boolean hostOk = true;
                for(String host : hosts) {
                    Resource root = context.readResourceFromRoot(pathAddress(pathElement(HOST, host), pathElement(CORE_SERVICE, MANAGEMENT)), false);
                    if (root.getChildrenNames(SECURITY_REALM).contains(realmName)) {
                        counter++;
                        realmName = REALM_NAME + counter;
                        hostOk = false;
                        break;
                    }
                }
                if(hostOk) {
                    break;
                }
            }
            for (String host : hosts) {
                createHostSSLConfig(realmName, migrationOperations, keyAlias, password, certificateKeyFile, protocol, caCertificateFile, caCertificatePassword, trustStoreType, keystoreType, pathAddress(pathElement(HOST, host), pathElement(CORE_SERVICE, MANAGEMENT)));
            }

        } else {
            managementCoreService = pathAddress(CORE_SERVICE, MANAGEMENT);
            //now we need to find a unique name
            //in domain mode different profiles could have different SSL configurations
            //but the realms are not scoped to a profile
            //if we hard coded a name migration would fail when migrating domains with multiple profiles
            int counter = 1;
            realmName = REALM_NAME + counter;
            boolean ok = false;
            do {
                Resource root = context.readResourceFromRoot(managementCoreService, false);
                if (root.getChildrenNames(SECURITY_REALM).contains(realmName)) {
                    counter++;
                    realmName = REALM_NAME + counter;
                } else {
                    ok = true;
                }
            } while (!ok);

            //we have a unique realm name
            createHostSSLConfig(realmName, migrationOperations, keyAlias, password, certificateKeyFile, protocol, caCertificateFile, caCertificatePassword, trustStoreType, keystoreType, managementCoreService);

        }

        return new SSLInformation(realmName, verifyClient, sessionCacheSize, sessionTimeout, protocol, cipherSuite);
    }
private SSLInformation createSecurityRealm ( OperationContext context , Map < PathAddress , ModelNode > migrationOperations , ModelNode legacyModelAddOps , String connector , ModelNode legacyAddOp , List < String > warnings , boolean domainMode ) { //read all the info from the SSL definition ModelNode keyAlias = legacyAddOp . get ( WebSSLDefinition . KEY_ALIAS . getName ( ) ) ; ModelNode password = legacyAddOp . get ( WebSSLDefinition . PASSWORD . getName ( ) ) ; ModelNode certificateKeyFile = legacyAddOp . get ( WebSSLDefinition . CERTIFICATE_KEY_FILE . getName ( ) ) ; ModelNode cipherSuite = legacyAddOp . get ( WebSSLDefinition . CIPHER_SUITE . getName ( ) ) ; ModelNode protocol = legacyAddOp . get ( WebSSLDefinition . PROTOCOL . getName ( ) ) ; ModelNode verifyClient = legacyAddOp . get ( WebSSLDefinition . VERIFY_CLIENT . getName ( ) ) ; ModelNode verifyDepth = legacyAddOp . get ( WebSSLDefinition . VERIFY_DEPTH . getName ( ) ) ; ModelNode certificateFile = legacyAddOp . get ( WebSSLDefinition . CERTIFICATE_FILE . getName ( ) ) ; ModelNode caCertificateFile = legacyAddOp . get ( WebSSLDefinition . CA_CERTIFICATE_FILE . getName ( ) ) ; ModelNode caCertificatePassword = legacyAddOp . get ( WebSSLDefinition . CA_CERTIFICATE_PASSWORD . getName ( ) ) ; ModelNode csRevocationURL = legacyAddOp . get ( WebSSLDefinition . CA_REVOCATION_URL . getName ( ) ) ; ModelNode trustStoreType = legacyAddOp . get ( WebSSLDefinition . TRUSTSTORE_TYPE . getName ( ) ) ; ModelNode keystoreType = legacyAddOp . get ( WebSSLDefinition . KEYSTORE_TYPE . getName ( ) ) ; ModelNode sessionCacheSize = legacyAddOp . get ( WebSSLDefinition . SESSION_CACHE_SIZE . getName ( ) ) ; ModelNode sessionTimeout = legacyAddOp . get ( WebSSLDefinition . SESSION_TIMEOUT . getName ( ) ) ; ModelNode sslProvider = legacyAddOp . get ( WebSSLDefinition . SSL_PROTOCOL . getName ( ) ) ; if ( verifyDepth . isDefined ( ) ) { warnings . add ( WebLogger . ROOT_LOGGER . couldNotMigrateResource ( WebSSLDefinition . VERIFY_DEPTH . getName ( ) , pathAddress ( legacyAddOp . get ( ADDRESS ) ) ) ) ; } if ( certificateFile . isDefined ( ) ) { warnings . add ( WebLogger . ROOT_LOGGER . couldNotMigrateResource ( WebSSLDefinition . CERTIFICATE_FILE . getName ( ) , pathAddress ( legacyAddOp . get ( ADDRESS ) ) ) ) ; } if ( sslProvider . isDefined ( ) ) { warnings . add ( WebLogger . ROOT_LOGGER . couldNotMigrateResource ( WebSSLDefinition . SSL_PROTOCOL . getName ( ) , pathAddress ( legacyAddOp . get ( ADDRESS ) ) ) ) ; } if ( csRevocationURL . isDefined ( ) ) { warnings . add ( WebLogger . ROOT_LOGGER . couldNotMigrateResource ( WebSSLDefinition . CA_REVOCATION_URL . getName ( ) , pathAddress ( legacyAddOp . get ( ADDRESS ) ) ) ) ; } String realmName ; PathAddress managementCoreService ; if ( domainMode ) { Set < String > hosts = new HashSet <> ( ) ; Resource hostResource = context . readResourceFromRoot ( pathAddress ( ) , false ) ; hosts . addAll ( hostResource . getChildrenNames ( HOST ) ) ; //now we need to find a unique name //in domain mode different profiles could have different SSL configurations //but the realms are not scoped to a profile //if we hard coded a name migration would fail when migrating domains with multiple profiles int counter = 1 ; realmName = REALM_NAME + counter ; while ( true ) { boolean hostOk = true ; for ( String host : hosts ) { Resource root = context . readResourceFromRoot ( pathAddress ( pathElement ( HOST , host ) , pathElement ( CORE_SERVICE , MANAGEMENT ) ) , false ) ; if ( root . getChildrenNames ( SECURITY_REALM ) . contains ( realmName ) ) { counter ++ ; realmName = REALM_NAME + counter ; hostOk = false ; break ; } } if ( hostOk ) { break ; } } for ( String host : hosts ) { createHostSSLConfig ( realmName , migrationOperations , keyAlias , password , certificateKeyFile , protocol , caCertificateFile , caCertificatePassword , trustStoreType , keystoreType , pathAddress ( pathElement ( HOST , host ) , pathElement ( CORE_SERVICE , MANAGEMENT ) ) ) ; } } else { managementCoreService = pathAddress ( CORE_SERVICE , MANAGEMENT ) ; //now we need to find a unique name //in domain mode different profiles could have different SSL configurations //but the realms are not scoped to a profile //if we hard coded a name migration would fail when migrating domains with multiple profiles int counter = 1 ; realmName = REALM_NAME + counter ; boolean ok = false ; do { Resource root = context . readResourceFromRoot ( managementCoreService , false ) ; if ( root . getChildrenNames ( SECURITY_REALM ) . contains ( realmName ) ) { counter ++ ; realmName = REALM_NAME + counter ; } else { ok = true ; } } while ( ! ok ) ; //we have a unique realm name createHostSSLConfig ( realmName , migrationOperations , keyAlias , password , certificateKeyFile , protocol , caCertificateFile , caCertificatePassword , trustStoreType , keystoreType , managementCoreService ) ; } return new SSLInformation ( realmName , verifyClient , sessionCacheSize , sessionTimeout , protocol , cipherSuite ) ; }
Creates the security realm

@param context
@param migrationOperations
@return
Creates the security realm