Package org.wso2.carbon.user.core

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


     * @throws Exception
     */
    public void upateClaimMapping(ClaimMapping mapping) throws Exception {
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                // There can be cases - we get a request for an external user store - where we don'
                // have a claims administrator.
                claimManager.updateClaimMapping(mapping);
            }
View Full Code Here


     * @throws Exception
     */
    public void addNewClaimMapping(ClaimMapping mapping) throws Exception {
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                // There can be cases - we get a request for an external user store - where we don'
                // have a claims administrator.
                claimManager.addNewClaimMapping(mapping);
            }
View Full Code Here

            throws Exception {
        ClaimMapping mapping = null;
        Claim claim = null;
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                // There can be cases - we get a request for an external user store - where we don'
                // have a claims administrator.
                claim = new Claim();
                claim.setClaimUri(claimUri);
View Full Code Here

     */
    public void addNewClaimDialect(ClaimDialect mappings) throws Exception {
        ClaimMapping[] mapping = null;
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                mapping = mappings.getClaimMapping();
                for (int i = 0; i < mapping.length; i++) {
                    claimManager.addNewClaimMapping(mapping[i]);
                }
View Full Code Here

        getUserStoreManager().updateUserListOfRole(roleName, deletedUsers, newUsers);
    }

    private UserStoreManager getUserStoreManager() throws UserStoreException {
        try {
            UserRealm realm = super.getUserRealm();
            if (realm == null) {
                throw new UserStoreException("UserRealm is null");
            }
            return realm.getUserStoreManager();
        } catch (Exception e) {
            throw new UserStoreException(e);
        }
    }
View Full Code Here

            RegistryService registryService = OAuthServiceComponent.getRegistryService();
            String username = UserCoreUtil.getTenantLessUsername(oauthConsumer
                    .getOauthConsumerKey());
            RealmService realmService = OAuthServiceComponent.getRealmService();
            int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
            UserRealm realm = registryService.getUserRealm(tenantId);
            int userId = realm.getUserStoreManager().getUserId(username);

            String baseString = "TenantId:=" + tenantId + "&UserId:=" + userId;
            Registry registry = registryService.getConfigSystemRegistry(tenantId);

            String path = RegistryConstants.PROFILES_PATH + username;
View Full Code Here

        String userName = userRegistry.getUserName();
        PermissionBean permissionsBean = new PermissionBean();
        permissionsBean.setPathWithVersion(resourcePath.getPathWithVersion());
        permissionsBean.setVersionView(!resourcePath.isCurrentVersion());

        UserRealm userRealm = userRegistry.getUserRealm();

        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) {
View Full Code Here

    public static void changeRolePermissions(UserRegistry userRegistry,
                                             String resourcePath, String permissionString)
            throws Exception {

        AuthorizationManager accessControlAdmin ;
        UserRealm realm;
        try {
            realm = userRegistry.getUserRealm();
            accessControlAdmin = realm.getAuthorizationManager();

        } catch (Exception e) {
            String msg = "Couldn't get access control admin for changing authorizations. Caused by: " + e.getMessage();
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }

        try {

            String[] rolePermissions = permissionString.split("\\|");

            for (int i = 0; i < rolePermissions.length; i++) {

                String notificationResponse = "The following changes have been made.";
                if (rolePermissions[i].trim().length() == 0) {
                    continue;
                }

                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

        if (!realmService.getTenantManager().isTenantActive(tenantId)) {
            /* the tenant is not active. */
            log.error("The tenant is not active. Tenant domain:" + tenantDomain);
            throw new DataServiceFault("The tenant is not active. Tenant domain:" + tenantDomain);
        }
        UserRealm realm;
        String roles[];
        try {
            realm = registryService.getUserRealm(tenantId);
            roles = realm.getUserStoreManager().getRoleListOfUser(userName);
        } catch (Exception e) {
            String msg = "Error in retrieving the realm for the tenant id: " + tenantId
                    + ", username: " + userName + ". " + e.getMessage();
            log.error(msg);
            throw new DataServiceFault(msg);
View Full Code Here

    }

    private boolean authenticate(String username, String password) throws IdentityException {
        boolean isAuthenticated = false;
        try {
            UserRealm realm = AnonymousSessionUtil.getRealmByUserName(
                    SAMLSSOUtil.getRegistryService(), SAMLSSOUtil.getRealmService(), username);

            if(realm == null){
                log.warn("Realm creation failed. Tenant may be inactive or invalid.");
                return false;
            }
           
            UserStoreManager userStoreManager = realm.getUserStoreManager();

//            //update the permission tree before authentication
//            String tenantDomain = MultitenantUtils.getTenantDomain(username);
//            int tenantId = SAMLSSOUtil.getRealmService().getTenantManager().getTenantId(tenantDomain);
//            PermissionUpdateUtil.updatePermissionTree(tenantId);

            // Check the authentication
            isAuthenticated = userStoreManager.authenticate(UserCoreUtil.getTenantLessUsername(username), password);
            if(!isAuthenticated){
                if (log.isDebugEnabled()) {
                    log.debug("user authentication failed due to invalid credentials.");
                }
                return false;
            }

            // Check the authorization
            boolean isAuthorized = realm.getAuthorizationManager().
                    isUserAuthorized(UserCoreUtil.getTenantLessUsername(username), "/permission/admin/login", CarbonConstants.UI_PERMISSION_ACTION);
            if(!isAuthorized){
                if(log.isDebugEnabled()){
                    log.debug("Authorization Failure when performing log-in action");
                }
View Full Code Here

TOP

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

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.