Examples of RealmConfiguration


Examples of org.wso2.carbon.user.api.RealmConfiguration

    public void testMultipleUserTags() throws Exception {

        // embeddedRegistryService = new InMemoryEmbeddedRegistryService();
        // get the realm config to retrieve admin username, password
        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
       
        UserRegistry adminRegistry = embeddedRegistryService.
                getUserRegistry(realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
        UserRealm adminRealm = adminRegistry.getUserRealm();

        adminRealm.getUserStoreManager().addUser("foo", "cce123", null, null, null);
        adminRealm.getUserStoreManager();
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

    }


    // Test each registry has different has different user stores
    public void testUserStores() throws RegistryException {
        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
        // first we will fill the user store for tenant 0
        UserRegistry registry1 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 0);

        Resource r = registry1.newResource();
        registry1.put("/test2", r);

        UserRealm userRealm1 = registry1.getUserRealm();
        UserStoreManager userStoreManager1;
        try {
            userStoreManager1 = userRealm1.getUserStoreManager();
        } catch (UserStoreException e) {
            throw new RegistryException("Error in retrieving UserStoreManager.");
        }
        AuthorizationManager authorizationManager1;
        try {
            authorizationManager1 = userRealm1.getAuthorizationManager();
        } catch (UserStoreException e) {
            throw new RegistryException("Error in retrieving AuthorizationManager.");
        }

        // adding some users
        try {
            userStoreManager1.addUser("user1t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user1t0.");
        }
        try {
            userStoreManager1.addUser("user2t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user2t0.");
        }
        try {
            userStoreManager1.addUser("user3t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user3t0.");
        }

        // adding more users we are going to add roles with
        try {
            userStoreManager1.addUser("user4t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user4t0.");
        }
        try {
            userStoreManager1.addUser("user5t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user5t0.");
        }
        try {
            userStoreManager1.addUser("user6t0", "password", null, null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user6t0.");
        }

        // adding some roles
        try {
            userStoreManager1.addRole("role1t0", null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding role role1t0.");
        }
        try {
            userStoreManager1.addRole("role2t0", null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding role role2t0.");
        }
        try {
            userStoreManager1.addRole("role3t0", null, null);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding role role3t0.");
        }
//
//        // now assign authorizations to first set of users.
//        try {
//            authorizationManager1.authorizeUser("user1t0", "/test2", ActionConstants.PUT);
//        } catch (UserStoreException e) {
//            throw new RegistryException("Error in authorizing user1t0.");
//        }
//        try {
//            authorizationManager1.authorizeUser("user2t0", "/test2", ActionConstants.DELETE);
//        } catch (UserStoreException e) {
//            throw new RegistryException("Error in authorizing user2t0.");
//        }
//        try {
//            authorizationManager1.authorizeUser("user2t0", "/test2", "authorize");
//        } catch (UserStoreException e) {
//            throw new RegistryException("Error in authorizing user3t0.");
//        }

        // then assign roles to the second set of users.
        try {
            userStoreManager1.updateRoleListOfUser("user4t0", null, new String[]{"role1t0"});
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user4t0 to role1t0 role.");
        }
        try {
            userStoreManager1.updateRoleListOfUser("user5t0", null, new String[]{"role2t0"});
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user5t0 to role2t0 role.");
        }
        try {
            userStoreManager1.updateRoleListOfUser("user6t0", null, new String[]{"role3t0"});
        } catch (UserStoreException e) {
            throw new RegistryException("Error in adding user user6t0 to role3t0 role.");
        }

        // now giving authorizations to the role.
        try {
            authorizationManager1.authorizeRole("role1t0", "/test2", ActionConstants.PUT);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in authorizing role1t0.");
        }
        try {
            authorizationManager1.authorizeRole("role2t0", "/test2", ActionConstants.DELETE);
        } catch (UserStoreException e) {
            throw new RegistryException("Error in authorizing role2t0.");
        }
        try {
            authorizationManager1.authorizeRole("role3t0", "/test2", "authorize");
        } catch (UserStoreException e) {
            throw new RegistryException("Error in authorizing role3t0.");
        }

        // secondly we will check the user store from tenant 1 and verify no overlaps with tenant 0
        UserRegistry registry2 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 1);

        UserRealm userRealm2 = registry2.getUserRealm();
        UserStoreManager userStoreManager2;
        try {
            userStoreManager2 = userRealm2.getUserStoreManager();
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

        TenantManager tenantManager = realmService.getTenantManager();

        String userMgtXML = getUserManagementConfigurationPath();

        RealmConfigXMLProcessor processor = new RealmConfigXMLProcessor();
        RealmConfiguration realmConfig = processor.buildRealmConfiguration(new FileInputStream(
                userMgtXML));

        Tenant tenant = new Tenant();
        tenant.setDomain("wso2.org");
        tenant.setRealmConfig(realmConfig);
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

        return userMgtFile;
    }

    public void testClaims() throws RegistryException, UserStoreException {
        // first we will fill the user store for tenant 0
        RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
        UserRegistry userRegistry1 =
                embeddedRegistryService.getUserRegistry(realmConfig.getAdminUserName(), 1);

        UserStoreManager userStoreManager = userRegistry1.getUserRealm().getUserStoreManager();

        Map<String, String> claimMap = new HashMap<String, String>();
        claimMap.put("http://wso2.org/claims/givenname", "admin123");
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

            RealmUnawareRegistryCoreServiceComponent comp =
                    new RealmUnawareRegistryCoreServiceComponent();
            comp.setRealmService(ctx.getRealmService());
            comp.registerBuiltInHandlers(embeddedRegistryService);
            // get the realm config to retrieve admin username, password
            RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
            registry = embeddedRegistryService.getConfigUserRegistry(
                    realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
            systemRegistry = embeddedRegistryService.getConfigSystemRegistry();
        } catch (RegistryException e) {
            fail("Failed to initialize the registry. Caused by: " + e.getMessage());
        }
    }
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

    }

    private RealmConfiguration loadDefaultRealmConfigs() throws UserStoreException {
        RealmConfigXMLProcessor processor = new RealmConfigXMLProcessor();
        RealmConfiguration config = processor.buildRealmConfigurationFromFile();
        return config;
    }
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

        }
    }

    public UserStoreInfo getUserStoreInfo() throws UserAdminException {
        try {
            RealmConfiguration realmConfig = realm.getRealmConfiguration();
            UserStoreInfo info = new UserStoreInfo();
            if ("true".equals(realmConfig
                    .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_READ_ONLY))) {
                info.setReadOnly(true);
            } else {
                info.setReadOnly(false);
            }
            info.setPasswordsExternallyManaged(realmConfig.isPasswordsExternallyManaged());
            info.setJsRegEx(realmConfig
                    .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_JS_REG_EX));
            info.setUserNameRegEx(
                realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USER_NAME_JS_REG_EX));
            info.setRoleNameRegEx(
                realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_ROLE_NAME_JS_REG_EX));
            info.setExternalIdP(realmConfig.
                                           getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP));
           
            MessageContext msgContext = MessageContext.getCurrentMessageContext();
            HttpServletRequest request = (HttpServletRequest) msgContext
                    .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
            HttpSession httpSession = request.getSession(false);
            if (httpSession != null) {
                String userName = (String) httpSession.getAttribute(ServerConstants.USER_LOGGED_IN);
                if (realm.getAuthorizationManager().isUserAuthorized(userName,
                        "/permission/admin/configure/security",
                        CarbonConstants.UI_PERMISSION_ACTION)) {
                    info.setAdminRole(realmConfig.getAdminRoleName());
                    info.setAdminUser(realmConfig.getAdminUserName());
                    info.setEveryOneRole(realmConfig.getEveryOneRoleName());
                    info.setMaxUserListCount(Integer.parseInt(realmConfig
                            .getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_MAX_USER_LIST)));
                }
            }

            info.setBulkImportSupported(this.isBulkImportSupported());
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

                    new RealmUnawareRegistryCoreServiceComponent();
            comp.setRealmService(ctx.getRealmService());
            comp.registerBuiltInHandlers(embeddedRegistryService);
           
            // get the realm config to retrieve admin username, password
            RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
            registry = embeddedRegistryService.getUserRegistry(
                realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
            systemRegistry = embeddedRegistryService.getSystemRegistry();
            configSystemRegistry = embeddedRegistryService.getConfigSystemRegistry();
            localRepository = embeddedRegistryService.getLocalRepository();
        } catch (RegistryException e){
            fail("Failed to initialize the registry. Caused by: " + e.getMessage());
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

    }

    public void addUser(String userName, String password, String[] roles, ClaimValue[] claims,
            String profileName) throws UserAdminException {
        try {
            RealmConfiguration realmConfig = realm.getRealmConfiguration();
            if (realmConfig.
                           getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP) != null) {
                throw new UserAdminException(
                                             "Please contact your extenernal Identity Provider to add users");
            }
            if (roles != null) {
                boolean isContained = false;
                String[] temp = new String[roles.length + 1];
                for (int i = 0; i < roles.length; i++) {
                    temp[i] = roles[i];
                    if (roles[i].equals(realmConfig.getEveryOneRoleName())) {
                        isContained = true;
                        break;
                    }
                }

                if (!isContained) {
                    temp[roles.length] = realmConfig.getEveryOneRoleName();
                    roles = temp;
                }
            }
            UserStoreManager admin = realm.getUserStoreManager();
            Map<String, String> claimMap = new HashMap<String, String>();
View Full Code Here

Examples of org.wso2.carbon.user.api.RealmConfiguration

            RealmUnawareRegistryCoreServiceComponent comp =
                    new RealmUnawareRegistryCoreServiceComponent();
            comp.setRealmService(ctx.getRealmService());
            comp.registerBuiltInHandlers(embeddedRegistryService);

            RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
            registry = embeddedRegistryService.getGovernanceUserRegistry(
                    realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
            configSystemRegistry = embeddedRegistryService.getConfigSystemRegistry();
        } catch (RegistryException e){
            fail("Failed to initialize the registry. Caused by: " + e.getMessage());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.