Package org.wso2.carbon.user.core

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


            }
        }
       
        if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
            try {
                UserRealm realm = null;
                if (realmService != null) {
                    realm = (UserRealm) realmService.getTenantUserRealm(tenantId);
                }
                if (realm == null) {
                    String msg = "Failed to obtain the user realm for tenant: " + tenantId + ".";
View Full Code Here


        return subscribeAndPopulate(userRegistry, path, endpoint, eventName, false);
    }

    public static boolean isAuthorized(UserRegistry userRegistry, String path, String action) {
        try {
            UserRealm realm = userRegistry.getUserRealm();
            if (realm.getAuthorizationManager() != null) {
                return realm.getAuthorizationManager().isUserAuthorized(userRegistry.getUserName(), path, action);
            }
            return false;
        } catch (UserStoreException e) {
            return false;
        }
View Full Code Here

        }
    }

    public static String[] getRolesOfUser(UserRegistry userRegistry, String username) {
        try {
            UserRealm realm = userRegistry.getUserRealm();
            if (realm.getUserStoreManager() != null) {
                return realm.getUserStoreManager().getRoleListOfUser(username);
            }
            return new String[0];
        } catch (UserStoreException e) {
            return new String[0];
        }
View Full Code Here

        }
    }

    public static boolean isAdmin(UserRegistry userRegistry, String[] rolesOfUser) {
        try {
            UserRealm realm = userRegistry.getUserRealm();
            if (realm.getRealmConfiguration() != null) {
                String adminRole = realm.getRealmConfiguration().getAdminRoleName();
                return Arrays.asList(rolesOfUser).contains(adminRole);
            }
            return false;
        } catch (UserStoreException e) {
            return false;
View Full Code Here

    public void removeClaimDialect(String dialectUri) throws Exception {
        Claim[] claims = null;
        ClaimMapping mapping = null;
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                claims = (Claim[]) claimManager.getAllClaims(dialectUri);
                for (int i = 0; i < claims.length; i++) {
                    mapping = new ClaimMapping(claims[i], null);
                    claimManager.deleteClaimMapping(mapping);
View Full Code Here

  private String getPathFromId(String id) {
    return id.substring(0, id.lastIndexOf("tenantId"));
  }

  private boolean isAuthorized(UserRegistry registry, String resourcePath, String action) throws RegistryException{
    UserRealm userRealm = registry.getUserRealm();
    String userName = getLoggedInUserName();

    try {
      if (!userRealm.getAuthorizationManager().isUserAuthorized(userName,
          resourcePath, action)) {
        return false;
      }
    } catch (UserStoreException e) {
      throw new RegistryException("Error at Authorizing " + resourcePath
View Full Code Here

    }

    private void doPostTenantCreationActions(Tenant tenant, String originatedService)
                                                                                    throws Exception {
        RealmService realmService = TenantMgtCoreServiceComponent.getRealmService();
        UserRealm userRealm = null;
        try {
            userRealm = (UserRealm) realmService.getTenantUserRealm(tenant.getId());
        } catch (UserStoreException e) {
            String msg = "Error in creating Realm for tenant: " + tenant.getDomain();
            throw new Exception(msg, e);
View Full Code Here

//        Reader reader = new StringReader(writer.toString());
//        UserRegistry tenantConfigSystemRegistry =
//                                                TenantMgtCoreServiceComponent.getConfigSystemRegistry(tenantId);
//        tenantConfigSystemRegistry.restore(CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION, reader);
        try {
            UserRealm realm =
                              (UserRealm) TenantMgtCoreServiceComponent.getRealmService().
                                                                        getTenantUserRealm(tenantId);
            String adminRole = realm.getRealmConfiguration().getAdminRoleName();
            AuthorizationManager authMan = realm.getAuthorizationManager();
            // Authorize the admin role, if not authorized yet.
            if (!authMan.isRoleAuthorized(adminRole,
                                          CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION,
                                          UserMgtConstants.EXECUTE_ACTION)) {
                authMan.authorizeRole(adminRole, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION,
View Full Code Here

     *            tenant information
     * @throws Exception
     *             UserStoreException
     */
    private void validateAdminUserName(Tenant tenant) throws Exception {
        UserRealm tenantZeroUserRealm =
                                        TenantMgtCoreServiceComponent.getRealmService().
                                                                      getBootstrapRealm();
        RealmConfiguration realmConfig =
                                         TenantMgtCoreServiceComponent.getBootstrapRealmConfiguration();
        String uniqueAcrossTenants =
                                     realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_USERNAME_UNIQUE);
        if ("true".equals(uniqueAcrossTenants)) {
            try {
                if (tenantZeroUserRealm.getUserStoreManager().isExistingUser(tenant.getAdminName())) {
                    throw new Exception("User name : " + tenant.getAdminName() +
                                        " exists in the system. " +
                                        "Please pick another user name for tenant Administrator.");
                }
            } catch (UserStoreException e) {
View Full Code Here

    private static final Log log = LogFactory.getLog(ActivityBeanPopulator.class);

    public static ActivityBean populate(UserRegistry userRegistry, String userName, String resourcePath, String fromDate,
                                        String toDate, String filter, String pageStr) throws Exception{
        UserRealm realm = userRegistry.getUserRealm();
        UserStoreManager reader = realm.getUserStoreManager();
        String[] roles = reader.getRoleListOfUser(userRegistry.getUserName());
        List list = Arrays.asList(roles);
        ActivityBean activityBean = new ActivityBean();

        if (resourcePath != null && resourcePath.equals("")) {
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.