Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.AuthRealm


            }
        }
        final SecurityService securityService = config.getSecurityService();

        // ensure we have the file authrealm
        AuthRealm fileAuthRealm = null;
       
        if (authRealmName == null)
            authRealmName = securityService.getDefaultRealm();       
       
        for (AuthRealm authRealm : securityService.getAuthRealm()) {           
            if (authRealm.getName().equals(authRealmName)) {
                fileAuthRealm = authRealm;           
                break;
            }
        }      
               
        if (fileAuthRealm == null) {
            report.setMessage(localStrings.getLocalString(
                "create.file.user.filerealmnotfound",
                "File realm {0} does not exist",
                authRealmName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;                                           
        }
       
        // Get FileRealm class name, match it with what is expected.
        String fileRealmClassName = fileAuthRealm.getClassname();

        // Report error if provided impl is not the one expected
        if (fileRealmClassName != null &&
            !fileRealmClassName.equals(
                "com.sun.enterprise.security.auth.realm.file.FileRealm")) {
            report.setMessage(
                localStrings.getLocalString(
                    "create.file.user.realmnotsupported",
                    "Configured file realm {0} is not supported.",
                    fileRealmClassName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;               
        }
        // ensure we have the file associated with the authrealm
        String keyFile = null;
        for (Property fileProp : fileAuthRealm.getProperty()) {
            if (fileProp.getName().equals("file"))
                keyFile = fileProp.getValue();
        }
        final String kf = keyFile;
        if (keyFile == null) {
View Full Code Here


        try {
            ConfigSupport.apply(new SingleConfigCode<SecurityService>() {

                public Object run(SecurityService param)
                throws PropertyVetoException, TransactionFailure {
                AuthRealm newAuthRealm = param.createChild(AuthRealm.class);
                    populateAuthRealmElement(newAuthRealm);
                    param.getAuthRealm().add(newAuthRealm);
                    //In case of cluster instances, this is required to
                    //avoid issues with the listener's callback method
                    SecurityConfigListener.authRealmCreated(config, newAuthRealm);
View Full Code Here

        // ensure we have the file authrealm
        if (authRealmName == null)
            authRealmName = securityService.getDefaultRealm();       

        AuthRealm fileAuthRealm = null;       
        for (AuthRealm authRealm : securityService.getAuthRealm()) {
            if (authRealm.getName().equals(authRealmName))                
                fileAuthRealm = authRealm;           
        }       
        if (fileAuthRealm == null) {
            report.setMessage(localStrings.getLocalString(
                "delete.file.user.filerealmnotfound",
                "File realm {0} does not exist", authRealmName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;                                           
        }
       
        // Get FileRealm class name, match it with what is expected.
        String fileRealmClassName = fileAuthRealm.getClassname();
       
        // Report error if provided impl is not the one expected
        if (fileRealmClassName != null &&
            !fileRealmClassName.equals(
                "com.sun.enterprise.security.auth.realm.file.FileRealm")) {
            report.setMessage(
                localStrings.getLocalString(
                    "delete.file.user.realmnotsupported",
                    "Configured file realm {0} is not supported.",
                    fileRealmClassName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;               
        }

        // ensure we have the file associated with the authrealm
        String keyFile = null;
        for (Property fileProp : fileAuthRealm.getProperty()) {
            if (fileProp.getName().equals("file"))
                keyFile = fileProp.getValue();
        }
        final String kFile = keyFile;
        if (keyFile == null) {
View Full Code Here

    private void createRealm(SecurityService ss, final StringBuilder sb) throws TransactionFailure {
        SingleConfigCode<SecurityService> scc = new SingleConfigCode<SecurityService>() {
            @Override
            public Object run(SecurityService ss) throws PropertyVetoException, TransactionFailure {
                AuthRealm ldapr = createLDAPRealm(ss);
                ss.getAuthRealm().add(ldapr);
                appendNL(sb,lsm.getString("ldap.realm.setup", FIXED_ADMIN_REALM_NAME));
                return true;
            }
        };
View Full Code Here

    // delete and create a new realm to replace it in a single transaction
    private void deleteRealm(SecurityService ss, final StringBuilder sb) throws TransactionFailure {
        SingleConfigCode<SecurityService> scc = new SingleConfigCode<SecurityService>() {
            @Override
            public Object run(SecurityService ss) throws PropertyVetoException, TransactionFailure {
                AuthRealm oldAdminRealm = getAdminRealm(ss);
                ss.getAuthRealm().remove(oldAdminRealm);
                appendNL(sb,"...");
                //AuthRealm ldapr = createLDAPRealm(ss);
                //ss.getAuthRealm().add(ldapr);
                //appendNL(sb,lsm.getString("ldap.realm.setup", FIXED_ADMIN_REALM_NAME));
View Full Code Here

        };
        ConfigSupport.apply(scc, realm);
    }

    private AuthRealm createLDAPRealm(SecurityService ss) throws TransactionFailure, PropertyVetoException {
        AuthRealm ar = ss.createChild(AuthRealm.class);
        ar.setClassname(LDAPRealm.class.getName());
        ar.setName(FIXED_ADMIN_REALM_NAME);
        List<Property> props = ar.getProperty();

        Property p = ar.createChild(Property.class);
        p.setName(DIR_P);
        p.setValue(url);
        props.add(p);

        p = ar.createChild(Property.class);
        p.setName(BASEDN_P);
        p.setValue(basedn);
        props.add(p);

        p = ar.createChild(Property.class);
        p.setName(JAAS_P);
        p.setValue(JAAS_V);
        props.add(p);

        if (ldapGroupName!= null) {
            p = ar.createChild(Property.class);
            p.setName(Realm.PARAM_GROUP_MAPPING);
            p.setValue(ldapGroupName +"->asadmin"); //appears as gfdomain1->asadmin in domain.xml
            props.add(p);
        }
       
View Full Code Here

        List <Config> configList = configs.getConfig();
        Config config = configList.get(0);

        SecurityService securityService = config.getSecurityService();
      
        AuthRealm fileAuthRealm = null;       
        for (AuthRealm authRealm : securityService.getAuthRealm()) {           
            if (authRealm.getName().equals(ADMIN_REALM)) {               
                fileAuthRealm = authRealm;           
                break;
            }
        }       

        if (fileAuthRealm == null) {
            report.setMessage(localStrings.getLocalString(
                "change.admin.password.adminrealmnotfound", "Server " +
                "Error: There is no admin realm to perform this operation"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;                                           
        }
       
        // Get FileRealm class name, match it with what is expected.
        String fileRealmClassName = fileAuthRealm.getClassname();
       
        // Report error if provided impl is not the one expected
        if (fileRealmClassName != null &&
            !fileRealmClassName.equals(
                "com.sun.enterprise.security.auth.realm.file.FileRealm")) {
            report.setMessage(
                localStrings.getLocalString(
                    "change.admin.password.adminrealmnotsupported",
                    "Configured admin realm is not supported."));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;               
        }

        // ensure we have the file associated with the authrealm
        String keyFile = null;
        for (Property fileProp : fileAuthRealm.getProperty()) {
            if (fileProp.getName().equals("file"))
                keyFile = fileProp.getValue();
        }
        if (keyFile == null) {
            report.setMessage(
                localStrings.getLocalString(
                    "change.admin.password.keyfilenotfound",
                    "There is no physical file associated with admin realm"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;                                           
        }
                           
        // We have the right impl so let's get to updating existing user
        FileRealm fr = null;
        try {
            realmsManager.createRealms(config);
            fr = (FileRealm) realmsManager.getFromLoadedRealms(config.getName(), fileAuthRealm.getName());
            if (fr == null) {
                throw new NoSuchRealmException(fileAuthRealm.getName());
            }
        }  catch(NoSuchRealmException e) {
            report.setMessage(
                localStrings.getLocalString(
                    "change.admin.password.realmnotsupported",
View Full Code Here

        // ensure we have the file authrealm
        if (authRealmName == null)
            authRealmName = securityService.getDefaultRealm();       
       
        AuthRealm fileAuthRealm = null;       
        for (AuthRealm authRealm : securityService.getAuthRealm()) {           
            if (authRealm.getName().equals(authRealmName))                
                fileAuthRealm = authRealm;           
        }       
        if (fileAuthRealm == null) {
            report.setMessage(localStrings.getLocalString(
                "update.file.user.filerealmnotfound",
                "There is no File realm {0} to perform this operation",
                authRealmName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;                                           
        }
       
        // Get FileRealm class name, match it with what is expected.
        String fileRealmClassName = fileAuthRealm.getClassname();
       
        // Report error if provided impl is not the one expected
        if (fileRealmClassName != null &&
            !fileRealmClassName.equals(
                "com.sun.enterprise.security.auth.realm.file.FileRealm")) {
            report.setMessage(
                localStrings.getLocalString(
                    "update.file.user.realmnotsupported",
                    "Configured file realm {0} is not supported.",
                    fileRealmClassName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;               
        }

        // ensure we have the file associated with the authrealm
        String keyFile = null;
        for (Property fileProp : fileAuthRealm.getProperty()) {
            if (fileProp.getName().equals("file"))
                keyFile = fileProp.getValue();
        }
        if (keyFile == null) {
            report.setMessage(
View Full Code Here

        if (properties != null && properties.size() > 0) {
            for (Property p: properties) {
                if (p != null && "authRealm".equals(p.getName())) {
                    authRealmName = p.getValue();
                    if (authRealmName != null) {
                        AuthRealm realm = null;
                        List<AuthRealm> rs = securityService.getAuthRealm();
                        if (rs != null && rs.size() > 0) {
                            for (AuthRealm r : rs) {
                                if (r != null &&
                                        r.getName().equals(authRealmName)) {
View Full Code Here

        try {
            ConfigSupport.apply(new SingleConfigCode<SecurityService>() {

                public Object run(SecurityService param)
                throws PropertyVetoException, TransactionFailure {
                AuthRealm newAuthRealm = param.createChild(AuthRealm.class);
                    populateAuthRealmElement(newAuthRealm);
                    param.getAuthRealm().add(newAuthRealm);
                    //In case of cluster instances, this is required to
                    //avoid issues with the listener's callback method
                    SecurityConfigListener.authRealmCreated(config, newAuthRealm);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.AuthRealm

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.