Package org.rhq.common.jbossas.client.controller

Examples of org.rhq.common.jbossas.client.controller.SecurityDomainJBossASClient


        HashMap<String, String> serverProperties) throws Exception {

        final String dbUsername = buildExpression(ServerProperties.PROP_DATABASE_USERNAME, serverProperties, true);
        final String obfuscatedPassword = buildExpression(ServerProperties.PROP_DATABASE_PASSWORD, serverProperties,
            true);
        final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
        String securityDomain = RHQ_DS_SECURITY_DOMAIN_XA;
        if (!client.isSecurityDomain(securityDomain)) {
            client.createNewSecureIdentitySecurityDomain72(securityDomain, dbUsername, obfuscatedPassword);
            LOG.info("Security domain [" + securityDomain + "] created");
        } else {
            LOG.info("Security domain [" + securityDomain + "] already exists, skipping the creation request");
            client.updateSecureIdentitySecurityDomainCredentials(securityDomain, dbUsername, obfuscatedPassword);
            LOG.info("Credentials have been updated for security domain [" + securityDomain + "]");
        }

        // we need separate security domains per datasource due to BZ 1102332
        securityDomain = RHQ_DS_SECURITY_DOMAIN_NOTX;
        if (!client.isSecurityDomain(securityDomain)) {
            client.createNewSecureIdentitySecurityDomain72(securityDomain, dbUsername, obfuscatedPassword);
            LOG.info("Security domain [" + securityDomain + "] created");
        } else {
            LOG.info("Security domain [" + securityDomain + "] already exists, skipping the creation request");
            client.updateSecureIdentitySecurityDomainCredentials(securityDomain, dbUsername, obfuscatedPassword);
            LOG.info("Credentials have been updated for security domain [" + securityDomain + "]");
        }
    }
View Full Code Here


        options.put("hashEncoding", "base64");

        SecurityDomainJBossASClient.LoginModuleRequest loginModuleRequest = new SecurityDomainJBossASClient.LoginModuleRequest(
            JDBC_LOGIN_MODULE_NAME, AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, options);

        SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
        client.createNewSecurityDomain(RHQ_USER_SECURITY_DOMAIN, loginModuleRequest);

    }
View Full Code Here

        options.put("roles", "rest-user");

        SecurityDomainJBossASClient.LoginModuleRequest loginModuleRequest = new SecurityDomainJBossASClient.LoginModuleRequest(
            DELEGATING_LOGIN_MODULE_NAME, AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, options);

        SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
        client.createNewSecurityDomain(RHQ_REST_SECURITY_DOMAIN, loginModuleRequest);
    }
View Full Code Here

            if (isLdapAuthenticationEnabled) {

                ModelControllerClient mcc = null;
                try {
                    mcc = ManagementService.createClient();
                    final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);

                    boolean ldapModulesPresent = client.securityDomainHasLoginModule(RHQ_USER_SECURITY_DOMAIN,
                        "org.rhq.enterprise.server.core.jaas.LdapLoginModule");


                    if (!ldapModulesPresent) {
                        LOG.info("Updating RHQ Server's JAAS login modules with LDAP support");
View Full Code Here

    private void updateJaasModules(Properties systemConfig) throws Exception {

        ModelControllerClient mcc = null;
        try {
            mcc = ManagementService.createClient();
            final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);

            if (client.isSecurityDomain(RHQ_USER_SECURITY_DOMAIN)) {
                LOG.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] already exists, it will be replaced.");
            }

            List<LoginModuleRequest> loginModules = new ArrayList<LoginModuleRequest>(3);

            // Always register the RHQ user JDBC login module, this checks the principal against the RHQ DB
            LoginModuleRequest jdbcLoginModule = new LoginModuleRequest(JDBCLoginModule.class.getName(),
                AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, getJdbcOptions(systemConfig));
            loginModules.add(jdbcLoginModule);

            // Optionally register two more login modules for LDAP support. The first ensures
            // we don't have a DB principal (if we do then the JDBC login module is sufficient.
            // The second performs the actual LDAP authorization.
            String value = systemConfig.getProperty(SystemSetting.LDAP_BASED_JAAS_PROVIDER.getInternalName());
            boolean isLdapAuthenticationEnabled = (value != null) ? RHQConstants.LDAPJAASProvider.equals(value) : false;

            if (isLdapAuthenticationEnabled) {
                // this is a "gatekeeper" that only allows us to go to LDAP if there is no principal in the DB
                LoginModuleRequest jdbcPrincipalCheckLoginModule = new LoginModuleRequest(
                    JDBCPrincipalCheckLoginModule.class.getName(),
                    AppConfigurationEntry.LoginModuleControlFlag.REQUISITE, getJdbcOptions(systemConfig));
                loginModules.add(jdbcPrincipalCheckLoginModule);

                // this is the LDAP module that checks the LDAP for auth
                Map<String, String> ldapModuleOptionProperties = getLdapOptions(systemConfig);
                try {
                    validateLdapOptions(ldapModuleOptionProperties);

                } catch (NamingException e) {
                    String descriptiveMessage = null;
                    if (e instanceof AuthenticationException) {
                        descriptiveMessage = "The LDAP integration cannot function because the LDAP Bind credentials"
                            + " for RHQ integration are incorrect. Contact the Administrator:" + e;

                    } else {
                        descriptiveMessage = "Problems encountered when communicating with LDAP server."
                            + " Contact the Administrator:" + e;
                    }
                    this.LOG.error(descriptiveMessage, e);
                }

                // Enable the login module even if the LDAP properties have issues
                LoginModuleRequest ldapLoginModule = new LoginModuleRequest(LdapLoginModule.class.getName(),
                    AppConfigurationEntry.LoginModuleControlFlag.REQUISITE, ldapModuleOptionProperties);
                loginModules.add(ldapLoginModule);
            }

            client.createNewSecurityDomain(RHQ_USER_SECURITY_DOMAIN,
                loginModules.toArray(new LoginModuleRequest[loginModules.size()]));
            client.flushSecurityDomainCache("RHQRESTSecurityDomain");
            LOG.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] re-created with login modules " + loginModules);

        } catch (Exception e) {
            throw new Exception("Error registering RHQ JAAS modules", e);
        } finally {
View Full Code Here

TOP

Related Classes of org.rhq.common.jbossas.client.controller.SecurityDomainJBossASClient

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.