Examples of UserStoreManager


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

     * @param password Password
     * @return true if user successfully authenticated
     */
    public static boolean doLogin(String username, String password) {
        try {
            UserStoreManager userStore = IdentityTenantUtil.getRealm(null, username)
                    .getUserStoreManager();
            return userStore.authenticate(username, password);
        } catch (Exception e) {
            log.error("Error while authenticating user", e);
            return false;
        }

View Full Code Here

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

    public String getUserIM(String userId) throws Exception {
        String message = "Invalid parameters provided to hasXMPPSettings";
        validateInputParameters(new String[]{userId}, message);
        checkUserAuthorization(userId, "hasXMPPSettings");

        UserStoreManager userStore = AdminServicesUtil.getUserRealm().getUserStoreManager();
        String[] imClaim = {UserCoreConstants.ClaimTypeURIs.IM};
        Map<String, String> claimValues = userStore.getUserClaimValues(userId, imClaim,
                UserCoreConstants.DEFAULT_PROFILE);

        if (claimValues.containsKey(UserCoreConstants.ClaimTypeURIs.IM)) {
            return claimValues.get(UserCoreConstants.ClaimTypeURIs.IM);
        } else {
View Full Code Here

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

     *
     * @param rahasData
     * @throws IdentityProviderException
     */
    protected void populateClaimValues(RahasData rahasData) throws IdentityProviderException {
        UserStoreManager connector = null;

        if (log.isDebugEnabled()) {
            log.debug("Populating claim values");
        }

        try {
            connector = IdentityTenantUtil.getRealm(null, userIdentifier).getUserStoreManager();
        } catch (Exception e) {
            log.error("Error while instantiating IdentityUserStore", e);
            throw new IdentityProviderException("Error while instantiating IdentityUserStore", e);
        }

        // get the column names for the URIs
        Iterator<RequestedClaimData> ite = requestedClaims.values().iterator();
        List<String> claimList = new ArrayList<String>();

        while (ite.hasNext()) {
            RequestedClaimData claim = (RequestedClaimData) ite.next();
            if (claim != null && !claim.getUri().equals(IdentityConstants.CLAIM_PPID)
                    && !claim.getUri().equals(IdentityConstants.CLAIM_TENANT_DOMAIN)) {
                claimList.add(claim.getUri());
            }
        }
        String[] claims = new String[claimList.size()];
        String userId = UserCoreUtil.getTenantLessUsername(userIdentifier);
        Map<String, String> mapValues = null;

        try {
            mapValues = connector.getUserClaimValues(userId, claimList.toArray(claims), null);
        } catch (Exception e) {
            throw new IdentityProviderException(e.getMessage(), e);
        }

        ite = requestedClaims.values().iterator();
View Full Code Here

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

    }
    /**
     * This overrides the base class functionality to suit the OpenID related functionality.
     */
    protected void populateClaimValues(RahasData rahasData) throws IdentityProviderException {
        UserStoreManager connector = null;
        Iterator<RequestedClaimData> iterator = null;
        List<String> list = null;
        OpenIDRequestedClaimData requestedClaimData = null;
        String userId = null;
        Map<String, String> mapValues = null;
        String claimVal = null;

        // Get the user id.
       userId = getUserIdentifier();

        try {
            connector = IdentityTenantUtil.getRealm(null, userId).getUserStoreManager();
        } catch (Exception e) {
            throw new IdentityProviderException(e.getMessage(), e);
        }

        // Get the column names for the URIs
        iterator = requestedClaims.values().iterator();
        list = new ArrayList<String>();

        // First we need to figure-out which attributed we need to retrieve from
        // the user store.
        while (iterator.hasNext()) {
            requestedClaimData = (OpenIDRequestedClaimData) iterator.next();
            if (requestedClaimData != null
                    && !requestedClaimData.getUri().equals(IdentityConstants.CLAIM_PPID)
                    && !requestedClaimData.getUri().equals(IdentityConstants.CLAIM_OPENID)) {
                list.add(requestedClaimData.getUri());
            }
        }

        String[] claimValues = new String[list.size()];
        // Get the claims values corresponding to the user from the user store.
        try {
            mapValues = connector.getUserClaimValues(userId, list.toArray(claimValues), null);
        } catch (Exception e) {
            throw new IdentityProviderException(e.getMessage(), e);
        }
        iterator = requestedClaims.values().iterator();

View Full Code Here

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

    public boolean isAddUserEnabled() throws Exception {
      
        UserRealm userRealm = IdentityTenantUtil.getRealm(null, null);
        if (userRealm != null) {
            UserStoreManager userStoreManager = userRealm.getUserStoreManager();
            if (userStoreManager != null) {
                return !userStoreManager.isReadOnly();
            }
        }

        return false;
View Full Code Here

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

        return fieldDTO;
    }

    private void addUser(String userName, String password, Map<String, String> claimList,
            String profileName, UserRealm realm) throws IdentityException {
        UserStoreManager admin = null;
        Permission permission = null;
        try {
            admin = realm.getUserStoreManager();
            if (!admin.isExistingRole(IdentityConstants.IDENTITY_DEFAULT_ROLE)) {
                permission = new Permission("/permission/admin/login", UserMgtConstants.EXECUTE_ACTION);
                admin.addRole(IdentityConstants.IDENTITY_DEFAULT_ROLE, null,
                        new Permission[]{permission});
            }
            admin.addUser(userName, password,
                    new String[]{IdentityConstants.IDENTITY_DEFAULT_ROLE}, claimList, profileName);
        } catch (UserStoreException e) {
            throw new IdentityException("Error occurred while adding user : " + userName, e);
        }
    }
View Full Code Here

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

        }
    }

    protected void populateClaimValues(String userIdentifier, SAMLAttributeCallback callback)
            throws IdentityProviderException {
        UserStoreManager connector = null;
        RahasData rahasData = null;

        if (log.isDebugEnabled()) {
            log.debug("Populating claim values");
        }

        if (requestedClaims.isEmpty()) {
            return;
        }

        try {
            connector = IdentityTenantUtil.getRealm(null, userIdentifier).getUserStoreManager();
        } catch (Exception e) {
            log.error("Error while instantiating IdentityUserStore", e);
            throw new IdentityProviderException("Error while instantiating IdentityUserStore", e);
        }

        // get the column names for the URIs
        Iterator<RequestedClaimData> ite = requestedClaims.values().iterator();
        List<String> claimList = new ArrayList<String>();
        rahasData = callback.getData();

        while (ite.hasNext()) {
            RequestedClaimData claim = (RequestedClaimData) ite.next();
            if (claim != null && !claim.getUri().equals(IdentityConstants.CLAIM_PPID)) {
                claimList.add(claim.getUri());
            }
        }

        String[] claimArray = new String[claimList.size()];
        String userId = userIdentifier;
        Map<String, String> mapValues = null;

        try {
            mapValues = connector.getUserClaimValues(userId, claimList.toArray(claimArray), null);
            ite = requestedClaims.values().iterator();
            while (ite.hasNext()) {
                SAMLAttribute attribute = null;
                Attribute saml2Attribute = null;
                RequestedClaimData claimData = ite.next();
View Full Code Here

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

        log.info("Information card details stored for card id : "
                + card.getInformationCardReference().getCardId());
    }

    private boolean isValidClaim(String user, Claim claim) throws IdentityProviderException {
        UserStoreManager userStore = null;

        if (IdentityConstants.CLAIM_PPID.equals(claim.getClaimUri())) {
            claim.setDisplayTag(IdentityConstants.PPID_DISPLAY_VALUE);
            return true;
        }

        try {
            userStore = AdminServicesUtil.getUserRealm().getUserStoreManager();
            if (userStore.getUserClaimValue(user, claim.getClaimUri(), null) != null) {
                return true;
            }
        } catch (Exception e) {
            throw new IdentityProviderException(e.getMessage(), e);
        }
View Full Code Here

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

     */
    public OpenIDUserProfileDTO[] getUserProfiles(String openId, OpenIDParameterDTO[] requredClaims)
            throws Exception {
        String userName = null;
        UserRealm realm = null;
        UserStoreManager reader = null;
        String tenatUser = null;
        String domainName = null;

        try {
            userName = OpenIDUtil.getUserName(openId);
            tenatUser = UserCoreUtil.getTenantLessUsername(userName);

            domainName = TenantUtils.getDomainNameFromOpenId(openId);

            realm = IdentityTenantUtil.getRealm(domainName, userName);
            reader = realm.getUserStoreManager();
            String[] profileNames = reader.getProfileNames(tenatUser);
            OpenIDUserProfileDTO[] profileDtoSet = new OpenIDUserProfileDTO[profileNames.length];

            ParameterList paramList = null;
            AuthRequest authReq = null;
            List<String> claimList = null;
View Full Code Here

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

     * @return
     * @throws Exception
     */
    private OpenIDClaimDTO[] getOpenIDClaimValues(String openId, String profileId,
            List<String> claimList) throws Exception {
        UserStoreManager userStore = null;
        Map<String, String> claimValues = null;
        OpenIDClaimDTO[] claims = null;
        OpenIDClaimDTO dto = null;
        IdentityClaimManager claimManager = null;
        Claim[] claimData = null;
        String[] claimArray = new String[claimList.size()];
        String userName = null;
        String domainName = null;
        String tenatUser;
        UserRealm realm = null;

        userName = OpenIDUtil.getUserName(openId);
        domainName = TenantUtils.getDomainNameFromOpenId(openId);
        tenatUser = UserCoreUtil.getTenantLessUsername(userName);

        realm = IdentityTenantUtil.getRealm(domainName, userName);
        userStore = realm.getUserStoreManager();
        claimValues = userStore.getUserClaimValues(tenatUser, claimList.toArray(claimArray),
                profileId);

        claims = new OpenIDClaimDTO[claimValues.size()];
        int i = 0;
        claimManager = IdentityClaimManager.getInstance();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.