Package org.wso2.carbon.user.api

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


        profz.setProfileName(profileConfig.getProfileName());
        return profz;
    }
   
    public static RealmConfiguration convertToRealmConfiguration(RealmConfigurationDTO realmConfigDTO) {
        RealmConfiguration realmConfig = new RealmConfiguration();
        realmConfig.setRealmClassName(realmConfigDTO.getRealmClassName());
        realmConfig.setUserStoreClass(realmConfigDTO.getUserStoreClass());
        realmConfig.setAuthorizationManagerClass(realmConfigDTO.getAuthorizationManagerClass());
        realmConfig.setAdminRoleName(realmConfigDTO.getAdminRoleName());
        realmConfig.setAdminUserName(realmConfigDTO.getAdminUserName());
        realmConfig.setAdminPassword(realmConfigDTO.getAdminPassword());
        realmConfig.setEveryOneRoleName(realmConfigDTO.getEveryOneRoleName());
        realmConfig.setUserStoreProperties(getPropertyValueMap(realmConfigDTO
                .getUserStoreProperties()));
        realmConfig.setAuthzProperties(getPropertyValueMap(realmConfigDTO.getAuthzProperties()));
        realmConfig.setRealmProperties(getPropertyValueMap(realmConfigDTO.getRealmProperties()));
        return realmConfig;
       
    }
View Full Code Here


        String[] userNames = userRealm.getUserStoreManager().listUsers("*", 100);

        // remove the admin and system
        ArrayList<String> filteredUserNames = new ArrayList<String>();

        RealmConfiguration realmConfig = userRealm.getRealmConfiguration();
        String systemUserName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
        String adminUserName = realmConfig.getAdminUserName();
        for (String userN: userNames) {
            if (userN.equals(adminUserName) ||
                    userN.equals(systemUserName)) {
                continue;
            }
            filteredUserNames.add(userN);
        }

        userNames = filteredUserNames.toArray(new String[filteredUserNames.size()]);

        permissionsBean.setUserNames(userNames);

        String[] roleNames = userRealm.getUserStoreManager().getRoleNames();
        // remove the admin role
        ArrayList<String> filteredRoleNames = new ArrayList<String>();

        String adminRoleName = realmConfig.getAdminRoleName();
        for (String roleN: roleNames) {
            if (roleN.equals(adminRoleName)) {
                continue;
            }
            filteredRoleNames.add(roleN);
View Full Code Here

        Map <String, PermissionEntry> userPermissionMap = new HashMap <String, PermissionEntry>();

        AuthorizationManager authorizer = userRealm.getAuthorizationManager();

        RealmConfiguration realmConfig = userRealm.getRealmConfiguration();
        String systemUserName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
        String adminUserName = realmConfig.getAdminUserName();
        String[] raUsers = authorizer.getExplicitlyAllowedUsersForResource(path, ActionConstants.GET);
        for (String raUser : raUsers) {
            if (raUser.equals(systemUserName) || raUser.equals(adminUserName)) {
                continue;
            }
View Full Code Here

            throws UserStoreException {

        Map <String, PermissionEntry> rolePermissionMap = new HashMap <String, PermissionEntry> ();

        AuthorizationManager authorizer = userRealm.getAuthorizationManager();
        RealmConfiguration realmConfig = userRealm.getRealmConfiguration();
        String adminRoleName = realmConfig.getAdminRoleName();

        String[] raRoles = authorizer.getAllowedRolesForResource(path, ActionConstants.GET);
        for (String raRole : raRoles) {
            if (raRole.equals(adminRoleName)) {
                continue;
View Full Code Here

                }

                String[] permissions = rolePermissions[i].split(":");
                String permRole = permissions[0];

                RealmConfiguration realmConfig = realm.getRealmConfiguration();
                if (!permRole.equals(realmConfig.getAdminRoleName())) {
                    accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.GET);
                    accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.PUT);
                    accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, ActionConstants.DELETE);
                    accessControlAdmin.clearRoleAuthorization(permRole, resourcePath, AccessControlConstants.AUTHORIZE);
                }
View Full Code Here

        tenantMan = new JDBCTenantManager(ds, "super.com");
    }

    public void doTenantStuff() throws Exception{
        RealmConfigXMLProcessor processor = new RealmConfigXMLProcessor();
        RealmConfiguration realmConfig = processor.buildRealmConfiguration(new FileInputStream(CarbonUtils.getUserMgtXMLPath()));
        Tenant[] tarray = TenantTestUtil.createTenant(realmConfig);

        assertEquals(1,tenantMan.addTenant(tarray[0]));
        assertEquals(2,tenantMan.addTenant(tarray[1]));
        assertEquals(3,tenantMan.addTenant(tarray[2]));
View Full Code Here

            embeddedRegistryService = ctx.getEmbeddedRegistryService();
            RealmUnawareRegistryCoreServiceComponent comp =
                    new RealmUnawareRegistryCoreServiceComponent();
            comp.registerBuiltInHandlers(embeddedRegistryService);
           
            RealmConfiguration realmConfig = ctx.getRealmService().getBootstrapRealmConfiguration();
            registry = embeddedRegistryService.getUserRegistry(
                realmConfig.getAdminUserName(), realmConfig.getAdminPassword());
        } catch (RegistryException e) {
                fail("Failed to initialize the registry. Caused by: " + e.getMessage());
        }
    }
View Full Code Here

                    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());
        } catch (RegistryException e) {
                fail("Failed to initialize the registry. Caused by: " + e.getMessage());
        }
    }
View Full Code Here

        DatabaseCreator creator = new DatabaseCreator(ds);
        creator.createRegistryDatabase();

        realm = new DefaultRealm();
        InputStream inStream = this.getClass().getClassLoader().getResource(JDBCRealmTest.JDBC_TEST_USERMGT_XML).openStream();
        RealmConfiguration realmConfig = TestRealmConfigBuilder
                .buildRealmConfigWithJDBCConnectionUrl(inStream, TEST_URL);
        realm.init(realmConfig, ClaimTestUtil.getClaimTestData(), ClaimTestUtil
                .getProfileTestData(),0);
    }
View Full Code Here

           UserStoreManager admin = realm.getUserStoreManager();

           InputStream inStream = this.getClass().getClassLoader().getResource(JDBCRealmTest.
                                  JDBC_TEST_USERMGT_XML).openStream();
           RealmConfigXMLProcessor realmConfigProcessor = new RealmConfigXMLProcessor();
           RealmConfiguration realmConfig = realmConfigProcessor.buildRealmConfiguration(inStream);

           admin.addRole("role2", null, null);
           admin.addRole("role3", null, null);
           admin.addRole("role4", null, null);
           assertEquals(7, admin.getRoleNames().length);//admin,everyone,role1,role2,role3,role4

           //Test delete role method
           assertTrue(admin.isExistingRole("role3"));
           admin.deleteRole("role3");
           admin.deleteRole("role4");
           assertFalse(admin.isExistingRole("role3"));
           admin.addRole("role3", null, null);
           admin.addRole("role4", null, null);


           //add users
           admin.addUser("saman", "pass1", null, null, null, false);
           admin.addUser("amara", "pass2", null, null, null, false);
           admin.addUser("sunil", "pass3", null, null, null, false);

           //update the ROLE list of USERS
           admin.updateRoleListOfUser("saman", null, new String[] { "role2" });
           admin.updateRoleListOfUser("saman", new String[] { "role2" }, new String[] { "role4",
                   "role3" });
            try{
               admin.updateRoleListOfUser(null, null, new String[] { "role2" });
               fail("Exceptions at missing user name");
            }catch(Exception ex){
                    //expected user
            }

           // Renaming Role
           admin.updateRoleName("role4", "role5");
          

           String[] rolesOfSaman = admin.getRoleListOfUser("saman");
           assertEquals(3, rolesOfSaman.length);
          
           String[] rolesOfisuru = admin.getRoleListOfUser("isuru");
           assertEquals(0, rolesOfisuru.length);
         
           admin.updateUserListOfRole("role2", new String[] { "saman" }, null);
           admin.updateUserListOfRole("role3", null, new String[] { "amara", "sunil" });

           String[] userOfRole5 = admin.getUserListOfRole("role5");
           assertEquals(1, userOfRole5.length);

           String[] userOfRole4 = admin.getUserListOfRole("role4");
           assertEquals(0, userOfRole4.length);

           try {
            admin.updateUserListOfRole("rolexx", null, new String[] { "amara", "sunil" });
            TestCase.assertTrue(false);
           } catch (Exception e) {
            // exptected error in negative testing
           }
           try {
             admin.updateUserListOfRole("role2", null, new String[] { "d" });
             TestCase.assertTrue(false);
           } catch (Exception e) {
            // exptected error in negative testing
           }

           try {
               admin.updateRoleListOfUser("saman", new String[] { "x" }, new String[] { "y" });
               TestCase.assertTrue(false);
           } catch (Exception e) {
               // exptected error in negative testing
           }

           try {
               admin.updateUserListOfRole (realmConfig.getAdminRoleName(),null,
                                           new String[] {realmConfig.getAdminUserName()});
               TestCase.assertTrue(false);
           } catch (Exception e) {
               // exptected error in negative testing
           }

           try {
               admin.updateRoleListOfUser(realmConfig.getAdminUserName(),new String[]{realmConfig.
                                          getAdminRoleName()},null);
               TestCase.assertTrue(false);
           } catch (Exception e) {
               // exptected error in negative testing
           }

           try {
               admin.updateUserListOfRole(realmConfig.getEveryOneRoleName(),new String[] {"saman"},
                                          null);
               TestCase.assertTrue(false);
           } catch (Exception e) {
               // exptected error in negative testing
           }

           try {
               admin.updateRoleListOfUser("sunil",new String[]{realmConfig.getEveryOneRoleName()},
                                          null);
               TestCase.assertTrue(false);
           } catch (Exception e) {
               // exptected error in negative testing
           }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.api.RealmConfiguration

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.