Package org.wso2.carbon.user.core.claim

Examples of org.wso2.carbon.user.core.claim.ClaimMapping


            throw new UserStoreException("Cannot set null values.");
        }
        Connection dbConnection = null;
        try {
            dbConnection = getDBConnection();
            ClaimMapping cMapping = (ClaimMapping) claimManager.getClaimMapping(claimURI);
            String property;
            if (cMapping != null) {
                property = cMapping.getMappedAttribute();
            } else {
                property = claimURI;
            }
            String value = getProperty(dbConnection, userName, property, profileName);
            if (value == null) {
View Full Code Here


            dbConnection = getDBConnection();
            Iterator<Map.Entry<String, String>> ite = claims.entrySet().iterator();
            while (ite.hasNext()) {
                Map.Entry<String, String> entry = ite.next();
                String claimURI = entry.getKey();
                ClaimMapping cMapping = (ClaimMapping) claimManager.getClaimMapping(claimURI);
                String property = null;
                if (cMapping != null) {
                    property = cMapping.getMappedAttribute();
                } else {
                    property = claimURI;
                }
                String value = entry.getValue();
                String existingValue = getProperty(dbConnection, userName, property, profileName);
View Full Code Here

                if (EMPTY_ATTRIBUTE_STRING.equals(entry.getValue())) {
                    continue;
                }
                //needs to get attribute name from claim mapping
                String claimURI = entry.getKey();
                ClaimMapping claimMapping = null;
                claimMapping = (ClaimMapping) claimManager.getClaimMapping(claimURI);

                String attributeName = null;
                if (claimMapping != null) {
                    attributeName = claimMapping.getMappedAttribute();
                    if (ATTR_NAME_CN.equals(attributeName)) {
                        isCNExists = true;
                    } else if (ATTR_NAME_SN.equals(attributeName)) {
                        isSNExists = true;
                    }
View Full Code Here

                //if there is no attribute for profile configuration in LDAP, skip updating it.
                if (claimURI.equals(UserCoreConstants.PROFILE_CONFIGURATION)) {
                    continue;
                }
                //get the claimMapping related to this claimURI
                ClaimMapping claimMapping = (ClaimMapping) claimManager.getClaimMapping(claimURI);
                String attributeName = null;

                if (claimMapping != null) {
                    attributeName = claimMapping.getMappedAttribute();
                } else {
                    attributeName = claimURI;
                }
                Attribute currentUpdatedAttribute = new BasicAttribute(attributeName);
                /*if updated attribute value is null, remove its values.*/
 
View Full Code Here

        String profileConfigurationName = null;
        boolean isPofileCnfigurationRequested = false;

        Set<String> propertySet = new HashSet<String>();
        for (String claim : claims) {
            ClaimMapping mapping = null;
            try {
                mapping = (ClaimMapping) claimManager.getClaimMapping(claim);
            } catch (org.wso2.carbon.user.api.UserStoreException e) {
                throw new UserStoreException(e);
            }
            // There can be cases some claim values being requested for claims
            // we don't have.
            if (mapping != null) {
                propertySet.add(mapping.getMappedAttribute());
            }

            if (UserCoreConstants.PROFILE_CONFIGURATION.equals(claim)) {
                isPofileCnfigurationRequested = true;
            }
        }

        propertySet.add(UserCoreConstants.PROFILE_CONFIGURATION);

        String[] properties = propertySet.toArray(new String[propertySet.size()]);
        Map<String, String> uerProperties = this.getUserPropertyValues(userName, properties,
                profileName);
        profileConfigurationName = uerProperties.get(UserCoreConstants.PROFILE_CONFIGURATION);
        if (profileConfigurationName == null) {
            profileConfigurationName = UserCoreConstants.DEFAULT_PROFILE_CONFIGURATION;
        }

        ProfileConfiguration profileConfig;
        try {
            profileConfig = (ProfileConfiguration) profileManager.getProfileConfig(profileConfigurationName);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        }

        List<String> hidden = null;
        if (profileConfig != null) {
            hidden = getMappingAttributeList(profileConfig.getHiddenClaims());
        }

        List<String> overridden = null;
        if (profileConfig != null) {
            overridden = getMappingAttributeList(profileConfig.getOverriddenClaims());
        }

        List<String> getAgain = new ArrayList<String>();
        Map<String, String> finalValues = new HashMap<String, String>();

        if (isPofileCnfigurationRequested) {
            finalValues.put(UserCoreConstants.PROFILE_CONFIGURATION, profileConfigurationName);
        }

        for (String claim : claims) {
            ClaimMapping mapping;
            try {
                mapping = (ClaimMapping) claimManager.getClaimMapping(claim);
            } catch (org.wso2.carbon.user.api.UserStoreException e) {
                throw new UserStoreException(e);
            }
            if (mapping != null) {
                String property = mapping.getMappedAttribute();
                String value = uerProperties.get(property);
                if (hidden != null && hidden.contains(property)) {
                    continue;
                }
View Full Code Here

            prepStmt = dbConnection.prepareStatement(ClaimDBConstants.GET_ALL_CLAIMS_SQL);
            prepStmt.setInt(1, tenantId);
            prepStmt.setInt(2, tenantId);
            rs = prepStmt.executeQuery();
            while (rs.next()) {
                ClaimMapping cm = new ClaimMapping();
                Claim claim = new Claim();
                String value = rs.getString(1);
                claim.setDialectURI(value);
                value = rs.getString(2);
                claim.setClaimUri(value);
                value = rs.getString(3);
                claim.setDisplayTag(value);
                value = rs.getString(4);
                claim.setDescription(value);
                value = rs.getString(5);
                cm.setMappedAttribute(value);
                value = rs.getString(6);
                claim.setRegEx(value);
                short is = rs.getShort(7);
                if (is == 1) {
                    claim.setSupportedByDefault(true);
                }
                is = rs.getShort(8);
                if (is == 1) {
                    claim.setRequired(true);
                }
                claim.setDisplayOrder(rs.getInt(9));
                cm.setClaim(claim);
                lst.add(cm);
            }
        } catch (SQLException e) {
            log.error("Database Error - " + e.getMessage(), e);
            throw new UserStoreException("Database Error - " + e.getMessage(), e);
View Full Code Here

        Map<String, ClaimMapping> claims = new HashMap<String, ClaimMapping>();
        try {
            ClaimDAO claimDAO = new ClaimDAO(ds, tenantId);
            List<ClaimMapping> lst = claimDAO.loadClaimMappings();
            for (Iterator<ClaimMapping> ite = lst.iterator(); ite.hasNext();) {
                ClaimMapping cm = ite.next();
                String uri = cm.getClaim().getClaimUri();
                claims.put(uri, cm);
            }
        } catch (UserStoreException e) {
            log.error(e.getMessage(), e);
        }
View Full Code Here

            claimIterator = dialect.getChildrenWithLocalName(LOCAL_NAME_CLAIM);

            while (claimIterator.hasNext()) {
                OMElement claimElement = null;
                Claim claim = null;
                ClaimMapping claimMapping = null;
                String displayName = null;
                String claimUri = null;
                String attributeId = null;
                String description = null;
                String regEx = null;
                int displayOrder = 0;

                claimElement = claimIterator.next();
                validateSchema(claimElement);

                claim = new Claim();
                claim.setDialectURI(dialectUri);

                claimUri = claimElement.getFirstChildWithName(new QName(LOCAL_NAME_CLAIM_URI))
                        .getText();
                claim.setClaimUri(claimUri);

                if (claimElement.getFirstChildWithName(new QName(LOCAL_NAME_DISPLAY_NAME)) != null) {
                    displayName = claimElement.getFirstChildWithName(
                            new QName(LOCAL_NAME_DISPLAY_NAME)).getText();
                    claim.setDisplayTag(displayName);
                }

                description = claimElement.getFirstChildWithName(new QName(LOCAL_NAME_DESCRIPTION))
                        .getText();
                claim.setDescription(description);

                if (claimElement.getFirstChildWithName(new QName(LOCAL_NAME_REG_EX)) != null) {
                    regEx = claimElement.getFirstChildWithName(new QName(LOCAL_NAME_REG_EX))
                            .getText();
                    claim.setRegEx(regEx);
                }

                if (claimElement.getFirstChildWithName(new QName(LOCAL_NAME_REQUIRED)) != null) {
                    claim.setRequired(true);
                }

                if (claimElement.getFirstChildWithName(new QName(LOCAL_NAME_SUPPORTED_BY_DEFAULT)) != null) {
                    claim.setSupportedByDefault(true);
                }

                if (claimElement.getFirstChildWithName(new QName(LOCAL_NAME_DISPLAY_OREDR)) != null) {
                    displayOrder = Integer.parseInt(claimElement.getFirstChildWithName(
                            new QName(LOCAL_NAME_DISPLAY_OREDR)).getText());
                    claim.setDisplayOrder(displayOrder);
                }

                attributeId = claimElement.getFirstChildWithName(new QName(LOCAL_NAME_ATTR_ID))
                        .getText();

                claimMapping = new ClaimMapping(claim, attributeId);
                claims.put(claimUri, claimMapping);
            }
        }
       
       
View Full Code Here

     * @return
     * @throws Exception
     */
    public ClaimMapping[] getAllSupportedClaimMappings() throws Exception {
        ClaimMapping[] claimMappings = new ClaimMapping[0];
        ClaimMapping claimMapping = null;
        Claim[] claims = null;
        ClaimManager claimManager = null;

        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager == null) {
                // There can be cases - we get a request for an external user store - where we don'
                // have a claims administrator.
                return new ClaimMapping[0];
            }

            claims = (Claim[]) claimManager.getAllSupportClaimsByDefault();
            if (claims != null) {
                claimMappings = new ClaimMapping[claims.length];
                for (int i = 0; i < claims.length; i++) {
                    claimMapping = new ClaimMapping(null, null);
                    claimMapping.setClaim(claims[i]);
                    claimMapping.setMappedAttribute(realm.getClaimManager().getAttributeName(
                            claims[i].getClaimUri()));
                    claimMappings[i] = claimMapping;
                }
            }

View Full Code Here

     * @return
     * @throws Exception
     */
    public ClaimMapping[] getAllClaimMappings() throws Exception {
        ClaimMapping[] claimMappings = new ClaimMapping[0];
        ClaimMapping claimMapping = null;
        Claim[] claims = null;
        ClaimManager claimManager = null;

        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager == null) {
                // There can be cases - we get a request for an external user store - where we don'
                // have a claims administrator.
                return new ClaimMapping[0];
            }

            claims = (Claim[]) claimManager.getAllClaims();
            if (claims != null) {
                claimMappings = new ClaimMapping[claims.length];
                for (int i = 0; i < claims.length; i++) {
                    claimMapping = new ClaimMapping(null, null);
                    claimMapping.setClaim(claims[i]);
                    claimMapping.setMappedAttribute(claimManager.getAttributeName(claims[i]
                            .getClaimUri()));
                    claimMappings[i] = claimMapping;
                }
            }

View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.core.claim.ClaimMapping

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.