Package org.wso2.carbon.user.core

Examples of org.wso2.carbon.user.core.UserStoreManager


        }
    }

    public FlaggedName[] getAllRolesNames() throws UserAdminException {
        try {
            UserStoreManager userStoreMan = realm.getUserStoreManager();
            //get all roles
            String[] roleNames = userStoreMan.getRoleNames();
            //get hybrid roles
            String[] hybridRoles = userStoreMan.getHybridRoles();
            Arrays.sort(hybridRoles);
            FlaggedName[] flaggedNames = new FlaggedName[roleNames.length];
            for (int i = 0; i < roleNames.length; i++) {
                FlaggedName fName = new FlaggedName();
                fName.setItemName(roleNames[i]);
                fName.setEditable(true);
                //check whether role is a hybrid role or not
                if (Arrays.binarySearch(hybridRoles, roleNames[i])<0){
                    fName.setRoleType("External");
                } else{
                    fName.setRoleType("Internal");
                }
                //either if user store read only or external groups are read only, set
                // external roles editable false
                if ((userStoreMan.isReadOnly() && Arrays.binarySearch(hybridRoles, roleNames[i]) < 0)
                    || (("false").equals(realm.getRealmConfiguration().getUserStoreProperty(
                        LDAPConstants.WRITE_EXTERNAL_ROLES))) &&
                       (Arrays.binarySearch(hybridRoles, roleNames[i]) < 0)){
                    fName.setEditable(false); //external role
                }
View Full Code Here


    }


    private boolean isBulkImportSupported() throws UserAdminException {
        try {
            UserStoreManager userStoreManager = this.realm.getUserStoreManager();
            if (userStoreManager != null) {
                return userStoreManager.isBulkImportSupported();
            } else {
                throw new UserAdminException("Unable to retrieve user store manager from realm.");
            }

        } catch (UserStoreException e) {
View Full Code Here

                if (!isContained) {
                    temp[roles.length] = realmConfig.getEveryOneRoleName();
                    roles = temp;
                }
            }
            UserStoreManager admin = realm.getUserStoreManager();
            Map<String, String> claimMap = new HashMap<String, String>();
            if (claims != null) {
                for (ClaimValue claimValue : claims) {
                    claimMap.put(claimValue.getClaimURI(), claimValue.getValue());
                }
            }
            admin.addUser(userName, password, roles, claimMap, profileName, false);
        } catch (UserStoreException e) {
            // previously logged so logging not needed
            throw new UserAdminException(e.getMessage(), e);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
View Full Code Here

    }

    public void addRole(String roleName, String[] userList, String[] permissions)
            throws UserAdminException {
        try {
            UserStoreManager usAdmin = realm.getUserStoreManager();
            usAdmin.addRole(roleName, userList, null);
            ManagementPermissionUtil.updateRoleUIPermission(roleName, permissions);
        } catch (UserStoreException e) {
            // previously logged so logging not needed
            throw new UserAdminException(e.getMessage(), e);
        } catch (Exception e) {
View Full Code Here

    }

    public void updateRoleName(String roleName, String newRoleName)
            throws UserAdminException {
        try {
            UserStoreManager usAdmin = realm.getUserStoreManager();
            usAdmin.updateRoleName(roleName, newRoleName);
        } catch (UserStoreException e) {
            // previously logged so logging not needed
            throw new UserAdminException(e.getMessage(), e);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
View Full Code Here

        }
    }

    public FlaggedName[] getUsersOfRole(String roleName, String filter) throws UserAdminException {
        try {
            UserStoreManager usMan = realm.getUserStoreManager();
            String[] userNames = usMan.listUsers(filter, -1);
            String[] usersOfRole = usMan.getUserListOfRole(roleName);
            Arrays.sort(usersOfRole);
            FlaggedName[] flaggedNames = new FlaggedName[userNames.length];
            for (int i = 0; i < userNames.length; i++) {
                FlaggedName fName = new FlaggedName();
                fName.setItemName(userNames[i]);
View Full Code Here

                log.error("Security Alert! Carbon Everyone role is being manipulated");
                throw new UserStoreException("Invalid data");// obscure error
                                                             // message
            }

            UserStoreManager admin = realm.getUserStoreManager();
            String[] oldUserList = admin.getUserListOfRole(roleName);
            Arrays.sort(oldUserList);

            List<String> delUsers = new ArrayList<String>();
            List<String> addUsers = new ArrayList<String>();

            for (FlaggedName fName : userList) {
                boolean isSelected = fName.isSelected();
                String userName = fName.getItemName();
                if (CarbonConstants.REGISTRY_ANONNYMOUS_USERNAME.equals(userName)) {
                    log.error("Security Alert! Carbon anonymous user is being manipulated");
                    return;
                }
                int oldindex = Arrays.binarySearch(oldUserList, userName);
                if (oldindex > -1 && !isSelected) {
                    // deleted
                    delUsers.add(userName);
                } else if (oldindex < 0 && isSelected) {
                    // added
                    addUsers.add(userName);
                }
            }
            admin.updateUserListOfRole(roleName, delUsers.toArray(new String[delUsers.size()]),
                    addUsers.toArray(new String[addUsers.size()]));
        } catch (UserStoreException e) {
            // previously logged so logging not needed
            log.error(e.getMessage(), e);
            throw new UserAdminException(e.getMessage(), e);
View Full Code Here

        }
    }

    public FlaggedName[] getRolesOfUser(String userName) throws UserAdminException {
        try {
            UserStoreManager admin = realm.getUserStoreManager();
            String[] userroles = admin.getRoleListOfUser(userName);
            String[] allRoles = admin.getRoleNames();
            FlaggedName[] flaggedNames = new FlaggedName[allRoles.length];
            Arrays.sort(userroles);
            for (int i = 0; i < allRoles.length; i++) {
                String role = allRoles[i];
                FlaggedName fname = new FlaggedName();
View Full Code Here

                log.error("Security Alert! Carbon anonymous user is being manipulated");
                throw new UserAdminException("Invalid data");// obscure error
                                                             // message
            }

            UserStoreManager admin = realm.getUserStoreManager();
            String[] oldRoleList = admin.getRoleListOfUser(userName);
            Arrays.sort(roleList);
            Arrays.sort(oldRoleList);

            List<String> delRoles = new ArrayList<String>();
            List<String> addRoles = new ArrayList<String>();

            for (String name : roleList) {
                int oldindex = Arrays.binarySearch(oldRoleList, name);
                if (oldindex < 0) {
                    addRoles.add(name);
                }
            }

            for (String name : oldRoleList) {
                int newindex = Arrays.binarySearch(roleList, name);
                if (newindex < 0) {
                    if (realm.getRealmConfiguration().getEveryOneRoleName().equals(name)) {
                        log.error("Security Alert! Carbon everyone role is being manipulated");
                        throw new UserAdminException("Invalid data");// obscure
                                                                     // error
                                                                     // message
                    }
                    delRoles.add(name);
                }
            }

            admin.updateRoleListOfUser(userName, delRoles.toArray(new String[delRoles.size()]),
                    addRoles.toArray(new String[addRoles.size()]));
        } catch (UserStoreException e) {
            // previously logged so logging not needed
            throw new UserAdminException(e.getMessage(), e);
        } catch (Exception e) {
View Full Code Here

        try {
            BulkImportConfig config = new BulkImportConfig(inStream, fileName);
            if (defaultPassword != null && defaultPassword.trim().length() > 0) {
                config.setDefaultPassword(defaultPassword.trim());
            }
            UserStoreManager userStore = this.realm.getUserStoreManager();
            if (fileName.endsWith("csv")) {
                CSVUserBulkImport csvAdder = new CSVUserBulkImport(config);
                csvAdder.addUserList(userStore);
            } else if (fileName.endsWith("xls") || fileName.endsWith("xlsx")) {
                ExcelUserBulkImport excelAdder = new ExcelUserBulkImport(config);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.core.UserStoreManager

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.