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


Java UserStoreException类代码示例

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


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

示例1: getUserStoreManager

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的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: verifyUserExists

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的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

示例3: setSubjectClaimForStandardDialect

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的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: startTenantFlow

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
/**
 * Starts the tenant flow for the given tenant domain
 *
 * @param tenantDomain tenant domain
 */
public static void startTenantFlow(String tenantDomain) {
    String tenantDomainParam = tenantDomain;
    int tenantId = MultitenantConstants.SUPER_TENANT_ID;

    if (tenantDomainParam != null && !tenantDomainParam.trim().isEmpty()) {
        try {
            tenantId = FrameworkServiceComponent.getRealmService().getTenantManager()
                    .getTenantId(tenantDomain);
        } catch (UserStoreException e) {
            log.error("Error while getting tenantId from tenantDomain query param", e);
        }
    } else {
        tenantDomainParam = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
    }

    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
            .getThreadLocalCarbonContext();
    carbonContext.setTenantId(tenantId);
    carbonContext.setTenantDomain(tenantDomainParam);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:FrameworkUtils.java

示例5: getMultiAttributeSeparator

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
public static String getMultiAttributeSeparator() {

        String multiAttributeSeparator = null;
        try {
            multiAttributeSeparator = CarbonContext.getThreadLocalCarbonContext().getUserRealm().
                    getRealmConfiguration().getUserStoreProperty(IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR);
        } catch (UserStoreException e) {
            log.warn("Error while retrieving MultiAttributeSeparator from UserRealm.");
            if (log.isDebugEnabled()) {
                log.debug("Error while retrieving MultiAttributeSeparator from UserRealm." + e);
            }
        }

        if (StringUtils.isBlank(multiAttributeSeparator)) {
            multiAttributeSeparator = IdentityCoreConstants.MULTI_ATTRIBUTE_SEPARATOR_DEFAULT;
            if (log.isDebugEnabled()) {
                log.debug("Multi Attribute Separator is defaulting to " + multiAttributeSeparator);
            }
        }

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

示例6: isExistsInUserStore

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
/**
 * Check whether the authenticated user exists in any user store that belongs to the realm the user belongs to.
 *
 * @param authenticatedUserName
 * @param tenantDomain
 * @return
 */
private boolean isExistsInUserStore(String authenticatedUserName, String tenantDomain,
                                    String realm) throws AuthenticationFailedException {
    UserStoreManager userStoreManager;
    try {
        userStoreManager = getPrimaryUserStoreManager(tenantDomain).getSecondaryUserStoreManager();
        String userStoreDomain = IdentityUtil.getPrimaryDomainName();
        authenticatedUserName = IdentityUtil.addDomainToName(authenticatedUserName, userStoreDomain);

        // Check whether the authenticated user is in primary user store. This is a limitation and will be improved
        // to support ADs mounted as secondary user stores
        return userStoreManager.isExistingUser(MultitenantUtils.getTenantAwareUsername(authenticatedUserName));

    } catch (UserStoreException e) {
        throw new
                AuthenticationFailedException("IWALocalAuthenticator failed to find the user in the userstore", e);
    }

}
 
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:26,代码来源:IWALocalAuthenticator.java

示例7: getAllSupportClaimMappingsByDefault

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
@Override
@Deprecated
public ClaimMapping[] getAllSupportClaimMappingsByDefault() throws UserStoreException {

    try {
        List<LocalClaim> localClaims = localClaimDAO.getLocalClaims(this.tenantId);

        List<ClaimMapping> claimMappings = new ArrayList<>();

        for (LocalClaim localClaim : localClaims) {
            ClaimMapping claimMapping = ClaimMetadataUtils.convertLocalClaimToClaimMapping(localClaim, this
                    .tenantId);

            if (claimMapping.getClaim().isSupportedByDefault()) {
                claimMappings.add(claimMapping);
            }
        }

        return claimMappings.toArray(new ClaimMapping[0]);
    } catch (ClaimMetadataException e) {
        throw new UserStoreException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:DefaultClaimMetadataStore.java

示例8: getAllRequiredClaimMappings

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
@Override
@Deprecated
public ClaimMapping[] getAllRequiredClaimMappings() throws UserStoreException {

    try {
        List<LocalClaim> localClaims = localClaimDAO.getLocalClaims(this.tenantId);

        List<ClaimMapping> claimMappings = new ArrayList<>();

        for (LocalClaim localClaim : localClaims) {
            ClaimMapping claimMapping = ClaimMetadataUtils.convertLocalClaimToClaimMapping(localClaim, this
                    .tenantId);

            if (claimMapping.getClaim().isRequired()) {
                claimMappings.add(claimMapping);
            }
        }

        return claimMappings.toArray(new ClaimMapping[0]);
    } catch (ClaimMetadataException e) {
        throw new UserStoreException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:DefaultClaimMetadataStore.java

示例9: canUserBeProvisioned

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
/**
 * @param provisioningEntity
 * @param provisionByRoleList
 * @param tenantDomain
 * @return
 * @throws CarbonException
 * @throws UserStoreException
 */
protected boolean canUserBeProvisioned(ProvisioningEntity provisioningEntity,
                                       String[] provisionByRoleList, String tenantDomain) throws UserStoreException,
                                                                                                 CarbonException {

    if (provisioningEntity.getEntityType() != ProvisioningEntityType.USER
        || provisionByRoleList == null || provisionByRoleList.length == 0) {
        // we apply restrictions only for users.
        // if service provider's out-bound provisioning configuration does not define any roles
        // to be provisioned then we apply no restrictions.
        return true;
    }

    String userName = getUserName(provisioningEntity.getAttributes());
    List<String> roleListOfUser = getUserRoles(userName, tenantDomain);

    for (String provisionByRole : provisionByRoleList) {
        if (roleListOfUser.contains(provisionByRole)) {
            return true;
        }
    }

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

示例10: createAppRole

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
/**
 * Create a role for the application and assign the user to that role.
 *
 * @param applicationName
 * @throws IdentityApplicationManagementException
 */
public static void createAppRole(String applicationName, String username)
        throws IdentityApplicationManagementException {

    String roleName = getAppRoleName(applicationName);
    String[] usernames = {username};

    try {
        // create a role for the application and assign the user to that role.
        if (log.isDebugEnabled()) {
            log.debug("Creating application role : " + roleName + " and assign the user : "
                      + Arrays.toString(usernames) + " to that role");
        }
        CarbonContext.getThreadLocalCarbonContext().getUserRealm().getUserStoreManager()
                .addRole(roleName, usernames, null);
    } catch (UserStoreException e) {
        throw new IdentityApplicationManagementException("Error while creating application role: " + roleName +
                " with user " + username, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:ApplicationMgtUtil.java

示例11: testGetScreenAttribute

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
@Test
public void testGetScreenAttribute() throws UserStoreException, AuthenticationFailedException {
    mockStatic(IdentityTenantUtil.class);
    mockStatic(SMSOTPUtils.class);
    when(SMSOTPUtils.getScreenUserAttribute(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn
            ("http://wso2.org/claims/mobile");
    when(IdentityTenantUtil.getTenantId("carbon.super")).thenReturn(-1234);
    when(IdentityTenantUtil.getRealmService()).thenReturn(realmService);
    when(realmService.getTenantUserRealm(-1234)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when(userRealm.getUserStoreManager()
            .getUserClaimValue("admin", "http://wso2.org/claims/mobile", null)).thenReturn("0778965231");
    when(SMSOTPUtils.getNoOfDigits(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("4");

    // with forward order
    Assert.assertEquals(smsotpAuthenticator.getScreenAttribute(context,userRealm,"admin"),"0778");

    // with backward order
    when(SMSOTPUtils.getDigitsOrder(context, SMSOTPConstants.AUTHENTICATOR_NAME)).thenReturn("backward");
    Assert.assertEquals(smsotpAuthenticator.getScreenAttribute(context,userRealm,"admin"),"5231");
}
 
开发者ID:wso2-extensions,项目名称:identity-outbound-auth-sms-otp,代码行数:22,代码来源:SMSOTPAuthenticatorTest.java

示例12: getTenantDomain

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
public static String getTenantDomain(int tenantId) throws IdentityRuntimeException {

        String tenantDomain = null;
        try {
            tenantDomain = realmService.getTenantManager().getDomain(tenantId);
        } catch (UserStoreException e) {
            // Ideally user.core should be throwing an unchecked exception, in which case no need to wrap at this
            // level once more without adding any valuable contextual information. Because we don't have exception
            // enrichment properly implemented, we are appending the error message from the UserStoreException to the
            // new message
            throw IdentityRuntimeException.error("Error occurred while retrieving tenantDomain for tenantId: " +
                    tenantId + e.getMessage(), e);
        }
        if(tenantDomain == null){
            throw IdentityRuntimeException.error("Can not find the tenant domain for the tenant id " + tenantId);
        } else {
            return tenantDomain;
        }

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

示例13: getTenantIdOfUser

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
/**
 * Get the tenant id of the given user.
 *
 * @param username Username
 * @return Tenant Id of domain user belongs to.
 * @throws IdentityRuntimeException Error when getting the tenant Id from tenant domain
 */
public static int getTenantIdOfUser(String username) throws IdentityRuntimeException {

    int tenantId = MultitenantConstants.INVALID_TENANT_ID;
    String domainName = MultitenantUtils.getTenantDomain(username);
    if (domainName != null) {
        try {
            TenantManager tenantManager = IdentityTenantUtil.getRealmService().getTenantManager();
            tenantId = tenantManager.getTenantId(domainName);
        } catch (UserStoreException e) {
            String errorMsg = "Error when getting the tenant id from the tenant domain : " + domainName;
            throw IdentityRuntimeException.error(errorMsg, e);
        }
    }
    if(tenantId == MultitenantConstants.INVALID_TENANT_ID){
        throw IdentityRuntimeException.error("Invalid tenant domain of user " + username);
    } else {
        return tenantId;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:IdentityTenantUtil.java

示例14: getUserstoreUsernameCaseSensitiveData

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的package包/类
@DataProvider
public Object[][] getUserstoreUsernameCaseSensitiveData() {
    try {
        when(mockTenantManager.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)).thenReturn
                (MultitenantConstants.SUPER_TENANT_ID);
        when(mockTenantManager.getTenantId("wso2.com")).thenReturn(1);
        when(mockTenantManager.getTenantId("none.com")).thenReturn(MultitenantConstants.INVALID_TENANT_ID);
        when(mockRealmService.getTenantUserRealm(anyInt())).thenReturn(mockUserRealm);
        when(mockUserStoreManager.getSecondaryUserStoreManager(anyString())).thenReturn(mockUserStoreManager);
    } catch (UserStoreException e) {
        // Ignored, since this is a mock behaviour
    }
    return new Object[][]{
            {"admin", "false", true},
            {"[email protected]", "false", true},
            {"[email protected]", "false", true},
            {"foo/[email protected]", null, true},
            {"[email protected]", "true", true},
            {"sec/[email protected]", "true", false},
    };
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:IdentityUtilTest.java

示例15: changeUserPassword

import org.wso2.carbon.user.api.UserStoreException; //导入依赖的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


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