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

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


        return claimMappings;
    }

    public ClaimMapping getClaimMapping(String claimURI) throws Exception {
        ClaimMapping claimMapping = null;
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
View Full Code Here


     * @throws Exception
     */
    public ClaimMapping[] getAllSupportedClaimMappings(String dialectUri)
            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 = getAllSupportedClaims(dialectUri);
            if (claims != null && claims.length > 0) {
                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

     * @param claimUri
     * @throws Exception
     */
    public void removeClaimMapping(String dialectUri, String claimUri)
            throws Exception {
        ClaimMapping mapping = null;
        Claim claim = 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.
                claim = new Claim();
                claim.setClaimUri(claimUri);
                claim.setDialectURI(dialectUri);
                mapping = new ClaimMapping(claim, null);
                claimManager.deleteClaimMapping(mapping);
            }
        } catch (UserStoreException e) {
            log.error("Error occurred while removing new claim mapping", e);
            getException("Error occurred while removing new claim mapping", e);
View Full Code Here

     * @param dialectUri
     * @throws Exception
     */
    public void removeClaimDialect(String dialectUri) throws Exception {
        Claim[] claims = null;
        ClaimMapping mapping = null;
        ClaimManager claimManager = null;
        try {
            UserRealm realm = getRealm();
            claimManager = realm.getClaimManager();
            if (claimManager != null) {
                claims = (Claim[]) claimManager.getAllClaims(dialectUri);
                for (int i = 0; i < claims.length; i++) {
                    mapping = new ClaimMapping(claims[i], null);
                    claimManager.deleteClaimMapping(mapping);
                }
            }
        } catch (UserStoreException e) {
            log.error("Error occurred while removing new claim dialect", e);
View Full Code Here

        claim1.setDialectURI("http://wso2.org/claims");
        claim1.setDisplayTag("About Me");
        //claim1.setRegEx("ty&*RegEx");
        claim1.setRequired(true);
        claim1.setSupportedByDefault(true);
        ClaimMapping cm1 = new ClaimMapping();
        cm1.setClaim(claim1);
        cm1.setMappedAttribute("attr1");
        claims.put("http://wso2.org/claims/aboutme", cm1);

        Claim claim2 = new Claim();
        claim2.setClaimUri(CLAIM_URI2);
        claim2.setDescription("Given Name");
        claim2.setDialectURI("http://wso2.org/claims");
        claim2.setDisplayTag("Given Name");
        claim2.setRegEx("ty&*RegEx2");
        claim2.setRequired(true);
        claim2.setSupportedByDefault(true);
        ClaimMapping cm2 = new ClaimMapping();
        cm2.setClaim(claim2);
        cm2.setMappedAttribute("attr2");
        claims.put("http://wso2.org/claims/givenname", cm2);

        Claim claim4 = new Claim();
        claim4.setClaimUri(CLAIM_URI4);
        claim4.setDescription("Email");
        claim4.setDialectURI("http://wso2.org/claims");
        claim4.setDisplayTag("Email");
        //claim4.setRegEx("ty&*RegEx2");
        claim4.setRequired(true);
        claim4.setSupportedByDefault(true);
        ClaimMapping cm4 = new ClaimMapping();
        cm4.setClaim(claim4);
        cm4.setMappedAttribute("attr4");
        claims.put("http://wso2.org/claims/emailaddress", cm4);

        Claim claim5 = new Claim();
        claim5.setClaimUri(CLAIM_URI5);
        claim5.setDescription("Phone Number");
        claim5.setDialectURI("http://wso2.org/claims");
        claim5.setDisplayTag("Phone Number");
        //claim5.setRegEx("ty&*RegEx2");
        claim5.setRequired(true);
        claim5.setSupportedByDefault(true);
        ClaimMapping cm5 = new ClaimMapping();
        cm5.setClaim(claim5);
        cm5.setMappedAttribute("attr5");
        claims.put("http://wso2.org/claims/telephone", cm5);

        Claim claim3 = new Claim();
        claim3.setClaimUri(CLAIM_URI3);
        claim3.setDescription("The description is nutts3");
        claim3.setDialectURI("http://wso2.org/");
        claim3.setDisplayTag("Given Name3");
        claim3.setRegEx("ty&*RegEx3");
        claim3.setRequired(true);
        claim3.setSupportedByDefault(true);
        ClaimMapping cm3 = new ClaimMapping();
        cm3.setClaim(claim3);
        cm3.setMappedAttribute("attr3");
        claims.put("http://wso2.org/givenname3", cm3);

        return claims;

    }
View Full Code Here

     * @throws Exception
     */
    public void upateClaimMapping(ClaimMappingDTO claimMappingDTO) throws Exception {
        /*Convert the simple structure of ClaimMapping received, to the complex structure
        of ClaimMapping which is used in the back end. */
        ClaimMapping claimMapping =convertClaimMappingDTOToClaimMapping(claimMappingDTO);
        ClaimManagerHandler.getInstance().upateClaimMapping(claimMapping);
    }
View Full Code Here

     * @throws Exception
     */
    public void addNewClaimMapping(ClaimMappingDTO claimMappingDTO) throws Exception {
        /*Convert the simple structure of ClaimMapping received, to the complex structure
        of ClaimMapping which is used in the back end. */
        ClaimMapping claimMapping =convertClaimMappingDTOToClaimMapping(claimMappingDTO);
        ClaimManagerHandler handler = ClaimManagerHandler.getInstance();
        ClaimMapping currentMapping = handler.getClaimMapping(
                claimMapping.getClaim().getClaimUri());
        if (currentMapping != null) {
            throw new UserStoreException(
                    "Duplicate claim exist in the system. Please pick a different Claim Uri");
        }
View Full Code Here

    private ClaimMapping[] convertClaimMappingDTOArrayToClaimMappingArray(
            ClaimMappingDTO[] claimMappingDTOs){
        List<ClaimMapping> claimMappings=new ArrayList<ClaimMapping>();
        for(ClaimMappingDTO claimMappingDTO:claimMappingDTOs){
            ClaimMapping claimMapping=convertClaimMappingDTOToClaimMapping(claimMappingDTO);
            claimMappings.add(claimMapping);
        }
        return claimMappings.toArray(new ClaimMapping[claimMappings.size()]);

    }
View Full Code Here

        claimMappingDTO.setMappedAttribute(claimMapping.getMappedAttribute());
        return claimMappingDTO;
    }

    private ClaimMapping convertClaimMappingDTOToClaimMapping(ClaimMappingDTO claimMappingDTO){
        ClaimMapping claimMapping=new ClaimMapping();
        claimMapping.setClaim(convertClaimDTOToClaim(claimMappingDTO.getClaim()));
        claimMapping.setMappedAttribute(claimMappingDTO.getMappedAttribute());
        return claimMapping;

    }
View Full Code Here

        claim1.setDialectURI("http://wso2.org/");
        claim1.setDisplayTag("Given Name");
        claim1.setRegEx("ty&*RegEx");
        claim1.setRequired(true);
        claim1.setSupportedByDefault(true);
        ClaimMapping cm1 = new ClaimMapping();
        cm1.setClaim(claim1);
        cm1.setMappedAttribute("attr1");
        claims.put("http://wso2.org/givenname", cm1);

        Claim claim2 = new Claim();
        claim2.setClaimUri(CLAIM_URI2);
        claim2.setDescription("The description is nutts2");
        claim2.setDialectURI("http://wso2.org2/");
        claim2.setDisplayTag("Given Name2");
        claim2.setRegEx("ty&*RegEx2");
        claim2.setRequired(true);
        claim2.setSupportedByDefault(true);
        ClaimMapping cm2 = new ClaimMapping();
        cm2.setClaim(claim2);
        cm2.setMappedAttribute("attr2");
        claims.put("http://wso2.org2/givenname2", cm2);

        Claim claim3 = new Claim();
        claim3.setClaimUri(CLAIM_URI3);
        claim3.setDescription("The description is nutts3");
        claim3.setDialectURI("http://wso2.org/");
        claim3.setDisplayTag("Given Name3");
        claim3.setRegEx("ty&*RegEx3");
        claim3.setRequired(true);
        claim3.setSupportedByDefault(true);
        ClaimMapping cm3 = new ClaimMapping();
        cm3.setClaim(claim3);
        cm3.setMappedAttribute("attr3");
        claims.put("http://wso2.org/givenname3", cm3);
    
        return claims;
       
    }
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.