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


Java UserStoreException类代码示例

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


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

示例1: doPostAddRole

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * This method is overridden to clear caches on doPostAddRole operation
 *
 * @param roleName         Name of the added role
 * @param userList         List of the users who got added the role
 * @param permissions      set of permissions
 * @param userStoreManager UserStoreManager instance got called
 * @return Always Returns true, since no major effect on further procedures
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostAddRole(String roleName, String[] userList, Permission[] permissions,
                             UserStoreManager userStoreManager) throws UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Clearing entitlement cache on post add role operation for role " +
                  roleName);
    }
    clearCarbonAttributeCache();
    // Always returns true since cache clearing failure does not make an effect on subsequent
    // User Operation Listeners
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:CacheClearingUserOperationListener.java

示例2: listUserByClaimWithPermission

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * List users with given claim value and permission
 *
 * @param claimValue claim to check
 * @param filter     filter to check
 * @param permission permission to check
 * @param maxLimit
 * @return
 * @throws UserAdminException
 */
public FlaggedName[] listUserByClaimWithPermission(ClaimValue claimValue, String filter, String permission, int
        maxLimit)
        throws UserAdminException {

    List<FlaggedName> permittedUsers = new ArrayList<>();
    try {
        org.wso2.carbon.user.api.UserRealm realm = UserMgtDSComponent.getRealmService().getTenantUserRealm
                (PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId());
        AuthorizationManager authorizationManager = realm.getAuthorizationManager();
        FlaggedName[] users = getUserAdminProxy().listUsers(claimValue, filter, maxLimit);
        for (int i = 0; i < users.length - 1; i++) {
            if (authorizationManager.isUserAuthorized(users[i].getItemName(),
                    permission, UserMgtConstants.EXECUTE_ACTION)) {
                permittedUsers.add(users[i]);
            }
        }
    } catch (org.wso2.carbon.user.api.UserStoreException e) {
        throw new UserAdminException("Error while filtering authorized users.", e);
    }
    FlaggedName[] permittedUsersArray = new FlaggedName[permittedUsers.size()];
    return permittedUsers.toArray(permittedUsersArray);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:UserAdmin.java

示例3: preparePassword

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
public static String preparePassword(String password, String saltValue) throws UserStoreException {
    try {
        String digestInput = password;
        if (saltValue != null) {
            digestInput = password + saltValue;
        }
        String digsestFunction = Util.getRealmConfig().getUserStoreProperties()
                .get(JDBCRealmConstants.DIGEST_FUNCTION);
        if (digsestFunction != null) {

            if (digsestFunction.equals(UserCoreConstants.RealmConfig.PASSWORD_HASH_METHOD_PLAIN_TEXT)) {
                return password;
            }

            MessageDigest dgst = MessageDigest.getInstance(digsestFunction);
            byte[] byteValue = dgst.digest(digestInput.getBytes(Charset.forName("UTF-8")));
            password = Base64.encode(byteValue);
        }
        return password;
    } catch (NoSuchAlgorithmException e) {
        log.error(e.getMessage(), e);
        throw new UserStoreException(e.getMessage(), e);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:Util.java

示例4: doPostUpdateRoleName

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * @param roleName         Old role name of the updating role
 * @param newRoleName      New role name of the updating role name
 * @param userStoreManager UserStoreManager instance got called
 * @return Always returns true since no major effect on further procedure.
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostUpdateRoleName(String roleName, String newRoleName,
                                    UserStoreManager userStoreManager) throws
                                                                       UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Clearing entitlement cache on post update role operation for role " +
                  roleName);
    }
    clearCarbonAttributeCache();
    // Always returns true since cache clearing failure does not make an effect on subsequent
    // User Operation Listeners
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:CacheClearingUserOperationListener.java

示例5: isAdminProfileSpoof

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * Checks whether the given user name is admin user name and the currently logged in user also admin.
 * Only admin user is allowed for admin user profile related operations.
 *
 * @param username Username to be checked.
 * @return True only if admin user.
 * @throws UserStoreException Error occurred while retrieving realm configuration.
 */
private boolean isAdminProfileSpoof(String username) throws UserStoreException {

    if (StringUtils.isEmpty(username)) {
        return false;
    }

    RealmConfiguration realmConfiguration = getUserRealm().getRealmConfiguration();
    String adminUsername = IdentityUtil.addDomainToName(realmConfiguration.getAdminUserName(),
            IdentityUtil.getPrimaryDomainName());
    String targetUsername = IdentityUtil.addDomainToName(username, IdentityUtil.getPrimaryDomainName());

    // If the given user name is not the admin username, simply we can allow and return false. Our intention is to
    // check whether a non admin user is trying to do operations on an admin profile.
    if (!StringUtils.equalsIgnoreCase(targetUsername, adminUsername)) {
        return false;
    }

    String loggedInUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
    if (loggedInUsername != null) {
        loggedInUsername = IdentityUtil.addDomainToName(loggedInUsername, IdentityUtil.getPrimaryDomainName());
    }

    // If the currently logged in user is also the admin user this isn't a spoof attempt. Hence returning false.
    return !StringUtils.equalsIgnoreCase(loggedInUsername, adminUsername);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:UserProfileAdmin.java

示例6: doPostUpdateRoleListOfUser

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * Overridden to trigger Notification Sending module to send messages to registered modules
 * on PostUpdateRoleListOfUser
 *
 * @param username         Username of role updated user
 * @param deletedRoles     List of roles deleted
 * @param newRoles         list of roles added
 * @param userStoreManager Instance of user store manager called
 * @return always returns true since no major effect on further operations.
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
public boolean doPostUpdateRoleListOfUser(String username,
                                          String[] deletedRoles, String[] newRoles,
                                          UserStoreManager userStoreManager)
        throws UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Sending user role list update notification for user " + username);
    }
    sendNotification(EVENT_TYPE_ROLE_UPDATE, username);
    // Returns true since no major effect on upcoming listeners
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:UserOperationsNotificationListener.java

示例7: testLocalIsExistingUserException

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
@Test
public void testLocalIsExistingUserException() throws Exception {

    initCommonMocks();
    setMockHttpSession();
    setMockAuthenticationContext();
    setMockIWAAuthenticationUtil();
    setMockUserCoreUtil();

    mockSession.setAttribute(IWAConstants.KERBEROS_TOKEN, Base64.encode(token));
    when(IWAAuthenticationUtil.processToken(any(byte[].class))).thenReturn("[email protected]");
    when(mockUserStoreManager.isExistingUser(anyString())).thenThrow(new UserStoreException());

    try {
        iwaLocalAuthenticator.processAuthenticationResponse(
                mockHttpRequest, mockHttpResponse, mockAuthenticationContext);
        Assert.fail("Response processed with user store exception");
    } catch (AuthenticationFailedException e) {
        Assert.assertTrue(e.getMessage().contains("IWALocalAuthenticator failed to find the user in the userstore"));
    }
}
 
开发者ID:wso2-extensions,项目名称:identity-local-auth-iwa-kerberos,代码行数:22,代码来源:IWAAuthenticatorTest.java

示例8: doPostDeleteUserClaimValues

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * TThis method is overridden to clear caches on doPostDeleteUserClaimValues operation
 *
 * @param userName         username
 * @param userStoreManager UserStoreManagerClass
 * @return Returns true always since no major effect on further procedures
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostDeleteUserClaimValues(String userName,
                                           UserStoreManager userStoreManager) throws
                                                                              UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Clearing entitlement cache on post delete user claim values operation for " +
                  "user " + userName);
    }
    // Always returns true since cache clearing failure does not make an effect on subsequent
    // User Operation Listeners
    clearCarbonAttributeCache();
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:CacheClearingUserOperationListener.java

示例9: doPostDeleteUserClaimValue

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * This method is overridden to clear caches on doPostDeleteUserClaimValue operation
 *
 * @param userName         username
 * @param userStoreManager UserStoreManagerClass
 * @return Always Returns true, since no major effect on further procedures
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostDeleteUserClaimValue(String userName, UserStoreManager userStoreManager)
        throws UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Clearing entitlement cache on post delete user claim value operation for " +
                  "user " + userName);
    }
    // Always returns true since cache clearing failure does not make an effect on subsequent
    // User Operation Listeners
    clearCarbonAttributeCache();
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:CacheClearingUserOperationListener.java

示例10: doPostAddUser

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
public boolean doPostAddUser(String userName, Object credential, String[] roleList, Map<String, String> claims,
                             String profile, UserStoreManager userStoreManager) throws UserStoreException {

    if(!isEnable()) {
        return true;
    }

    StringBuilder builder = new StringBuilder();
    if (roleList != null) {
        for (int i = 0; i < roleList.length; i++) {
            builder.append(roleList[i] + ",");
        }
    }
    audit.info(String.format(AUDIT_MESSAGE, getUser(), "Add User", userName, "Roles :"
            + builder.toString(), SUCCESS));
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:UserMgtAuditLogger.java

示例11: isAddProfileEnabledForDomain

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

示例12: doPostDeleteUserClaimValues

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * Overridden to trigger Notification Sending module to send messages to registered modules
 * on doPostDeleteUserClaimValues
 *
 * @param username         Username of the deleted user
 * @param userStoreManager Instance of user store manager called
 * @return Always returns true, even if message sending fails there is no major effect on
 * further operations.
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostDeleteUserClaimValues(String username, UserStoreManager userStoreManager)
        throws UserStoreException {

    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Sending user claim value update notification for user " + username);
    }
    sendNotification(EVENT_TYPE_PROFILE_UPDATE, username);
    // Returns true since no major effect on upcoming listeners
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:UserOperationsNotificationListener.java

示例13: doPostDeleteRole

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
/**
 * This method is overridden to clear caches on doPostDeleteRole operation
 *
 * @param roleName         Deleted role name
 * @param userStoreManager UserStoreManagerClass
 * @return Always Returns true, since no major effect on further procedures
 * @throws org.wso2.carbon.user.core.UserStoreException
 */
@Override
public boolean doPostDeleteRole(String roleName, UserStoreManager userStoreManager) throws
                                                                                    UserStoreException {
    if (!isEnable()) {
        return true;
    }

    if (log.isDebugEnabled()) {
        log.debug("Clearing entitlement cache on post delete role operation for role " +
                  roleName);
    }
    clearCarbonAttributeCache();
    // Always returns true since cache clearing failure does not make an effect on subsequent
    // User Operation Listeners
    return true;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:25,代码来源:CacheClearingUserOperationListener.java

示例14: getRolesToAdd

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
private Collection<String> getRolesToAdd(UserStoreManager userStoreManager, String[] newRoles)
        throws UserStoreException {

    List<String> rolesToAdd = Arrays.asList(newRoles);
    List<String> updatedRolesToAdd = new ArrayList<>();

    // Make Internal domain name case insensitive
    for (String role : rolesToAdd) {
        if (StringUtils.containsIgnoreCase(role, UserCoreConstants.INTERNAL_DOMAIN +
                CarbonConstants.DOMAIN_SEPARATOR)) {
            updatedRolesToAdd.add(UserCoreConstants.INTERNAL_DOMAIN + CarbonConstants.DOMAIN_SEPARATOR +
                    UserCoreUtil.removeDomainFromName(role));
        } else {
            updatedRolesToAdd.add(role);
        }
    }
    List<String> allExistingRoles = removeDomainFromNamesExcludeInternal(
            Arrays.asList(userStoreManager.getRoleNames()), userStoreManager.getTenantId());
    updatedRolesToAdd.retainAll(allExistingRoles);
    return updatedRolesToAdd;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:DefaultProvisioningHandler.java

示例15: handleFederatedUserNameEqualsToSuperAdminUserName

import org.wso2.carbon.user.core.UserStoreException; //导入依赖的package包/类
private void handleFederatedUserNameEqualsToSuperAdminUserName(UserRealm realm, String username,
                                                               UserStoreManager userStoreManager,
                                                               Collection<String> deletingRoles)
        throws UserStoreException, FrameworkException {
    if (userStoreManager.getRealmConfiguration().isPrimary()
        && username.equals(realm.getRealmConfiguration().getAdminUserName())) {
        if (log.isDebugEnabled()) {
            log.debug("Federated user's username is equal to super admin's username of local IdP.");
        }

        // Whether superadmin login without superadmin role is permitted
        if (deletingRoles
                .contains(realm.getRealmConfiguration().getAdminRoleName())) {
            if (log.isDebugEnabled()) {
                log.debug("Federated user doesn't have super admin role. Unable to sync roles, since" +
                          " super admin role cannot be unassigned from super admin user");
            }
            throw new FrameworkException(
                    "Federated user which having same username to super admin username of local IdP," +
                    " trying login without having super admin role assigned");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:DefaultProvisioningHandler.java


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