当前位置: 首页>>代码示例>>Java>>正文


Java UserStoreManager类代码示例

本文整理汇总了Java中org.wso2.carbon.user.api.UserStoreManager的典型用法代码示例。如果您正苦于以下问题:Java UserStoreManager类的具体用法?Java UserStoreManager怎么用?Java UserStoreManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserStoreManager类属于org.wso2.carbon.user.api包,在下文中一共展示了UserStoreManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserStoreManager

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
private UserStoreManager getUserStoreManager(String tenantDomain, UserRealm realm, String userDomain) throws
        FrameworkException {
    UserStoreManager userStore = null;
    try {
        userStore = realm.getUserStoreManager();
        if (StringUtils.isNotBlank(userDomain)) {
            userStore = realm.getUserStoreManager().getSecondaryUserStoreManager(userDomain);
        }

        if (userStore == null) {
            // To avoid NPEs
            throw new FrameworkException("Invalid user store domain name : " + userDomain + " in tenant : "
                    + tenantDomain);
        }
    } catch (UserStoreException e) {
        throw new FrameworkException("Error occurred while retrieving the UserStoreManager " +
                                     "from Realm for " + tenantDomain + " to handle local claims", e);
    }
    return userStore;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultClaimHandler.java

示例2: setSubjectClaimForLocalClaims

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * Set federated subject's SP Subject Claim URI as a property
 */
private void setSubjectClaimForLocalClaims(String tenantAwareUserId,
                                           UserStoreManager userStore,
                                           Map<String, String> attributesMap,
                                           String spStandardDialect,
                                           AuthenticationContext context) {

    String subjectURI = context.getSequenceConfig().getApplicationConfig().getSubjectClaimUri();
    if (subjectURI != null && !subjectURI.isEmpty()) {
        if (spStandardDialect != null) {
            setSubjectClaim(tenantAwareUserId, userStore, attributesMap, spStandardDialect, context);
            if (context.getProperty(SERVICE_PROVIDER_SUBJECT_CLAIM_VALUE) == null) {
                log.warn("Subject claim could not be found amongst unfiltered local claims");
            }
        } else {
            setSubjectClaim(tenantAwareUserId, userStore, attributesMap, null, context);
            if (context.getProperty(SERVICE_PROVIDER_SUBJECT_CLAIM_VALUE) == null) {
                log.warn("Subject claim could not be found amongst service provider mapped " +
                         "unfiltered local claims");
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:DefaultClaimHandler.java

示例3: setSubjectClaimForStandardDialect

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
private void setSubjectClaimForStandardDialect(String tenantAwareUserId, UserStoreManager userStore,
                                               AuthenticationContext context, String subjectURI) {
    try {
        String value = userStore.getUserClaimValue(tenantAwareUserId, subjectURI, null);
        if (value != null) {
            context.setProperty(SERVICE_PROVIDER_SUBJECT_CLAIM_VALUE, value);
            if (log.isDebugEnabled()) {
                log.debug("Setting \'ServiceProviderSubjectClaimValue\' property value " +
                          "from user store " + value);
            }
        } else {
            if (log.isDebugEnabled()) {
                log.debug("Subject claim for " + tenantAwareUserId + " not found in user store");
            }
        }
    } catch (UserStoreException e) {
        log.error("Error occurred while retrieving " + subjectURI + " claim value for user " + tenantAwareUserId,
                e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultClaimHandler.java

示例4: changeUserPassword

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * User change the password of the user.
 *
 * @param newPassword
 * @throws IdentityMgtServiceException
 */
public void changeUserPassword(String newPassword, String oldPassword) throws IdentityMgtServiceException {

    String userName = CarbonContext.getThreadLocalCarbonContext().getUsername();

    try {
        UserStoreManager userStoreManager = getUserStore(userName);
        userName = UserCoreUtil.removeDomainFromName(userName);
        userStoreManager.updateCredential(userName, newPassword, oldPassword);
        log.info("Password changed for: " + userName);
    } catch (UserStoreException e) {
        String message = "Error while resetting the password for: " + userName;
        log.error(message, e);
        throw new IdentityMgtServiceException(message, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:UserIdentityManagementAdminService.java

示例5: setUserClaimsValuesInUserStore

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * This method sets user claim values in user store
 *
 * @param userStoreManager userStoreManager object
 * @param username         user name
 * @param claims           set of claims
 * @param profile          profile
 * @throws IdentityException
 */
protected void setUserClaimsValuesInUserStore(UserStoreManager userStoreManager,
                                              String username,
                                              Map<String, String> claims, String profile) throws IdentityException {

    try {
        // We are calling the doSetUserClaimsValues() method of the userstore to prevent Identity Management
        // listener being called once again for claim value set events.
        if (userStoreManager instanceof JDBCUserStoreManager) {
            ((JDBCUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
        } else if (userStoreManager instanceof ActiveDirectoryUserStoreManager) {
            ((ActiveDirectoryUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
        } else if (userStoreManager instanceof ReadWriteLDAPUserStoreManager) {
            ((ReadWriteLDAPUserStoreManager) userStoreManager).doSetUserClaimValues(username, claims, null);
        } else {
            String msg = "Cannot persist identity data to userstore for user:%s. Unsupported userstore type:%s to" +
                    " be used as UserStoreBasedIdentityDataStore.";
            throw IdentityException.error(String.format(msg, username, userStoreManager.getClass().getName()));
        }

    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        throw IdentityException.error("Error while persisting identity user data in to user store for user: "
                + username, e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:35,代码来源:UserStoreBasedIdentityDataStore.java

示例6: isAddProfileEnabledForDomain

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
public boolean isAddProfileEnabledForDomain(String domain) throws UserProfileException {

        org.wso2.carbon.user.core.UserStoreManager userStoreManager = null;
        org.wso2.carbon.user.core.UserRealm realm = getUserRealm();
        boolean isAddProfileEnabled = false;

        try {
            if (StringUtils.isBlank(domain) || StringUtils.equals(domain, UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME)) {
                userStoreManager = realm.getUserStoreManager();
            } else {
                userStoreManager = realm.getUserStoreManager().getSecondaryUserStoreManager(domain);
            }

        } catch (UserStoreException e) {
            String errorMessage = "Error in obtaining SecondaryUserStoreManager.";
            log.error(errorMessage, e);
            throw new UserProfileException(errorMessage, e);
        }

        if (userStoreManager != null) {
            isAddProfileEnabled = userStoreManager.isMultipleProfilesAllowed();
        }

        return isAddProfileEnabled;
    }
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:UserProfileAdmin.java

示例7: updateUserAttribute

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * Update the mobile number (user attribute) in user's profile.
 *
 * @param username  the Username
 * @param attribute the Attribute
 * @throws SMSOTPException
 */
public static void updateUserAttribute(String username, Map<String, String> attribute, String tenantDomain)
        throws SMSOTPException {
    try {
        // updating user attributes is independent from tenant association.not tenant association check needed here.
        UserRealm userRealm;
        // user is always in the super tenant.
        userRealm = SMSOTPUtils.getUserRealm(tenantDomain);
        if (userRealm == null) {
            throw new SMSOTPException("The specified tenant domain " + tenantDomain + " does not exist.");
        }
        // check whether user already exists in the system.
        SMSOTPUtils.verifyUserExists(username, tenantDomain);
        UserStoreManager userStoreManager = userRealm.getUserStoreManager();
        userStoreManager.setUserClaimValues(username, attribute, null);
    } catch (UserStoreException | AuthenticationFailedException e) {
        throw new SMSOTPException("Exception occurred while connecting to User Store: Authentication is failed. ", e);
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:26,代码来源:SMSOTPUtils.java

示例8: verifyUserExists

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * Verify whether user Exist in the user store or not.
 *
 * @param username the Username
 * @throws SMSOTPException
 */
public static void verifyUserExists(String username, String tenantDomain) throws SMSOTPException,
        AuthenticationFailedException {
    UserRealm userRealm;
    boolean isUserExist = false;
    try {
        userRealm = SMSOTPUtils.getUserRealm(tenantDomain);
        if (userRealm == null) {
            throw new SMSOTPException("Super tenant realm not loaded.");
        }
        UserStoreManager userStoreManager = userRealm.getUserStoreManager();
        if (userStoreManager.isExistingUser(username)) {
            isUserExist = true;
        }
    } catch (UserStoreException e) {
        throw new SMSOTPException("Error while validating the user.", e);
    }
    if (!isUserExist) {
        if (log.isDebugEnabled()) {
            log.debug("User does not exist in the User Store");
        }
        throw new SMSOTPException("User does not exist in the User Store.");
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:30,代码来源:SMSOTPUtils.java

示例9: getRegistryService

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * To get the registry service.
 * @return RegistryService
 * @throws RegistryException Registry Exception
 */
private  RegistryService getRegistryService() throws RegistryException, UserStoreException {
    RealmService realmService = new InMemoryRealmService();
    AuthenticatorFrameworkDataHolder.getInstance().setRealmService(realmService);
    UserStoreManager userStoreManager = AuthenticatorFrameworkDataHolder.getInstance().getRealmService()
            .getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID).getUserStoreManager();
    Permission adminPermission = new Permission(PermissionUtils.ADMIN_PERMISSION_REGISTRY_PATH,
            CarbonConstants.UI_PERMISSION_ACTION);
    userStoreManager.addRole(ADMIN_ROLE + "t", new String[] { ADMIN_USER }, new Permission[] { adminPermission });
    RegistryDataHolder.getInstance().setRealmService(realmService);
    DeviceManagementDataHolder.getInstance().setRealmService(realmService);
    InputStream is = BaseWebAppAuthenticatorFrameworkTest.class.getClassLoader()
            .getResourceAsStream("carbon-home/repository/conf/registry.xml");
    RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
    context.setSetup(true);
    return context.getEmbeddedRegistryService();
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:22,代码来源:BaseWebAppAuthenticatorFrameworkTest.java

示例10: getUserCountViaUserStoreManager

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
/**
 * This method returns the count of users using UserStoreManager.
 *
 * @return user count
 */
private Response getUserCountViaUserStoreManager() {
    if (log.isDebugEnabled()) {
        log.debug("Getting the user count");
    }

    try {
        UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
        int userCount = userStoreManager.listUsers("*", -1).length;
        BasicUserInfoList result = new BasicUserInfoList();
        result.setCount(userCount);
        return Response.status(Response.Status.OK).entity(result).build();
    } catch (UserStoreException e) {
        String msg = "Error occurred while retrieving the user count.";
        log.error(msg, e);
        return Response.serverError().entity(
                new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:24,代码来源:UserManagementServiceImpl.java

示例11: isUserExists

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
@GET
@Path("/checkUser")
@Override
public Response isUserExists(@QueryParam("username") String userName) {
    try {
        UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
        if (userStoreManager.isExistingUser(userName)) {
            return Response.status(Response.Status.OK).entity(true).build();
        } else {
            return Response.status(Response.Status.OK).entity(false).build();
        }
    } catch (UserStoreException e) {
        String msg = "Error while retrieving the user.";
        log.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
    }
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:18,代码来源:UserManagementServiceImpl.java

示例12: setup

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
@BeforeClass
public void setup() throws UserStoreException {
    initMocks(this);
    userManagementService = new UserManagementServiceImpl();
    userStoreManager = Mockito.mock(UserStoreManager.class, Mockito.RETURNS_MOCKS);
    deviceManagementProviderService = Mockito
            .mock(DeviceManagementProviderServiceImpl.class, Mockito.CALLS_REAL_METHODS);
    userRealm = Mockito.mock(UserRealm.class);
    RealmConfiguration realmConfiguration = Mockito.mock(RealmConfiguration.class);
    Mockito.doReturn(null).when(realmConfiguration).getSecondaryRealmConfig();
    Mockito.doReturn(realmConfiguration).when(userRealm).getRealmConfiguration();
    enrollmentInvitation = new EnrollmentInvitation();
    List<String> recipients = new ArrayList<>();
    recipients.add(TEST_USERNAME);
    enrollmentInvitation.setDeviceType("android");
    enrollmentInvitation.setRecipients(recipients);
    userList = new ArrayList<>();
    userList.add(TEST_USERNAME);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:20,代码来源:UserManagementServiceImplTest.java

示例13: manageGroupSharing

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
@Test(dependsOnMethods = ("updateGroupSecondTime"))
public void manageGroupSharing() throws GroupManagementException, RoleDoesNotExistException, UserStoreException {
    groupManagementProviderService.manageGroupSharing(0, null);
    List<String> newRoles = new ArrayList<>();
    newRoles.add("TEST_ROLE_1");
    newRoles.add("TEST_ROLE_2");
    newRoles.add("TEST_ROLE_3");

    UserStoreManager userStoreManager =
            DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(
                    -1234).getUserStoreManager();
    Permission[] permissions = new Permission[1];
    Permission perm = new Permission("/admin/test/perm", "add");
    permissions[0] = perm;

    userStoreManager.addRole("TEST_ROLE_1", null, permissions);
    userStoreManager.addRole("TEST_ROLE_2", null, permissions);
    userStoreManager.addRole("TEST_ROLE_3", null, permissions);

    groupManagementProviderService.manageGroupSharing(groupManagementProviderService.getGroup(
            TestUtils.createDeviceGroup1().getName()).getGroupId(), newRoles);
}
 
开发者ID:wso2,项目名称:carbon-device-mgt,代码行数:23,代码来源:GroupManagementProviderServiceTest.java

示例14: getRolesForTenant

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
@Override
public List<Role> getRolesForTenant(int tenantId) throws UserManagementException {

    String[] roleNames;
    ArrayList<Role> rolesList = new ArrayList<Role>();
    Role newRole;
    try {
        UserStoreManager userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService()
                .getTenantUserRealm(tenantId)
                .getUserStoreManager();

        roleNames = userStoreManager.getRoleNames();
        for (String roleName : roleNames) {
            newRole = new Role(roleName);
            rolesList.add(newRole);
        }

    } catch (UserStoreException userStoreEx) {
        String errorMsg = "User store error in fetching user list for role and tenant tenant id:" + tenantId;
        log.error(errorMsg, userStoreEx);
        throw new UserManagementException(errorMsg, userStoreEx);
    }
    return rolesList;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:25,代码来源:UserManagerImpl.java

示例15: getUser

import org.wso2.carbon.user.api.UserStoreManager; //导入依赖的package包/类
@Override public User getUser(String username, int tenantId) throws UserManagementException {
    UserStoreManager userStoreManager;
    User user;
    try {
        userStoreManager = DeviceMgtUserDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
                                                  .getUserStoreManager();
        user = new User(username);

        Claim[] claims = userStoreManager.getUserClaimValues(username, null);
        Map<String,String> claimMap = new HashMap<String, String>();
        for(Claim claim:claims){
            String claimURI = claim.getClaimUri();
            String value = claim.getValue();
            claimMap.put(claimURI, value);
        }

        setUserClaims(user, claimMap);
    } catch (UserStoreException userStoreEx) {
        String errorMsg = "User store error in fetching user " + username;
        log.error(errorMsg, userStoreEx);
        throw new UserManagementException(errorMsg, userStoreEx);
    }
    return user;
}
 
开发者ID:wso2-incubator,项目名称:iot-server-appliances,代码行数:25,代码来源:UserManagerImpl.java


注:本文中的org.wso2.carbon.user.api.UserStoreManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。