Package org.apache.cxf.sts.claims

Examples of org.apache.cxf.sts.claims.LdapClaimsHandler



    @org.junit.Test
    @org.junit.Ignore
    public void testRetrieveClaims() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        ClaimCollection requestedClaims = createRequestClaimCollection();

        List<URI> expectedClaims = new ArrayList<URI>();
        expectedClaims.add(ClaimTypes.FIRSTNAME);
        expectedClaims.add(ClaimTypes.LASTNAME);
        expectedClaims.add(ClaimTypes.EMAILADDRESS);
      
        ClaimsParameters params = new ClaimsParameters();
        params.setPrincipal(new CustomTokenPrincipal(user));
        ProcessedClaimCollection retrievedClaims =
            claimsHandler.retrieveClaimValues(requestedClaims, params);

        Assert.isTrue(
                      retrievedClaims.size() == expectedClaims.size(),
                      "Retrieved number of claims [" + retrievedClaims.size()
                      + "] doesn't match with expected [" + expectedClaims.size() + "]"
View Full Code Here



    @org.junit.Test(expected = STSException.class)
    @org.junit.Ignore
    public void testRetrieveClaimsWithUnsupportedMandatoryClaimType() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        ClaimCollection requestedClaims = createRequestClaimCollection();
        // add unsupported but mandatory claim
        Claim claim = new Claim();
        claim.setClaimType(ClaimTypes.GENDER);
        claim.setOptional(false);
        requestedClaims.add(claim);

        ClaimsParameters params = new ClaimsParameters();
        params.setPrincipal(new CustomTokenPrincipal(user));
        claimsHandler.retrieveClaimValues(requestedClaims, params);
    }
View Full Code Here

    }

    @org.junit.Test
    @org.junit.Ignore
    public void testRetrieveClaimsWithUnsupportedOptionalClaimType() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        ClaimCollection requestedClaims = createRequestClaimCollection();
        // add unsupported but optional unsupported claim
        Claim claim = new Claim();
        claim.setClaimType(ClaimTypes.GENDER);
        claim.setOptional(true);
        requestedClaims.add(claim);

        // Gender is not expected to be returned because not supported
        List<URI> expectedClaims = new ArrayList<URI>();
        expectedClaims.add(ClaimTypes.FIRSTNAME);
        expectedClaims.add(ClaimTypes.LASTNAME);
        expectedClaims.add(ClaimTypes.EMAILADDRESS);
       
        ClaimsParameters params = new ClaimsParameters();
        params.setPrincipal(new CustomTokenPrincipal(user));
        ProcessedClaimCollection retrievedClaims =
            claimsHandler.retrieveClaimValues(requestedClaims, params);

        Assert.isTrue(
                      retrievedClaims.size() == expectedClaims.size(),
                      "Retrieved number of claims [" + retrievedClaims.size()
                      + "] doesn't match with expected [" + expectedClaims.size() + "]"
View Full Code Here

    public void testSupportedClaims() throws Exception {

        Map<String, String> mapping
            = CastUtils.cast((Map<?, ?>)appContext.getBean("claimsToLdapAttributeMapping"));

        LdapClaimsHandler cHandler = new LdapClaimsHandler();
        cHandler.setClaimsLdapAttributeMapping(mapping);

        List<URI> supportedClaims = cHandler.getSupportedClaimTypes();

        Assert.isTrue(
                      mapping.size() == supportedClaims.size(),
                      "Supported claims and claims/ldap attribute mapping size different"
        );
View Full Code Here


    @org.junit.Test
    @org.junit.Ignore
    public void testRetrieveClaims() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        RequestClaimCollection requestedClaims = createRequestClaimCollection();

        List<URI> expectedClaims = new ArrayList<URI>();
        expectedClaims.add(ClaimTypes.FIRSTNAME);
        expectedClaims.add(ClaimTypes.LASTNAME);
        expectedClaims.add(ClaimTypes.EMAILADDRESS);

        ClaimCollection retrievedClaims =
            claimsHandler.retrieveClaimValues(new CustomTokenPrincipal(user), requestedClaims);

        Assert.isTrue(
                      retrievedClaims.size() == expectedClaims.size(),
                      "Retrieved number of claims [" + retrievedClaims.size()
                      + "] doesn't match with expected [" + expectedClaims.size() + "]"
View Full Code Here


    @org.junit.Test(expected = STSException.class)
    @org.junit.Ignore
    public void testRetrieveClaimsWithUnsupportedMandatoryClaimType() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        RequestClaimCollection requestedClaims = createRequestClaimCollection();
        // add unsupported but mandatory claim
        RequestClaim claim = new RequestClaim();
        claim.setClaimType(ClaimTypes.GENDER);
        claim.setOptional(false);
        requestedClaims.add(claim);

        claimsHandler.retrieveClaimValues(new CustomTokenPrincipal(user), requestedClaims);

    }
View Full Code Here

    }

    @org.junit.Test
    @org.junit.Ignore
    public void testRetrieveClaimsWithUnsupportedOptionalClaimType() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        RequestClaimCollection requestedClaims = createRequestClaimCollection();
        // add unsupported but optional unsupported claim
        RequestClaim claim = new RequestClaim();
        claim.setClaimType(ClaimTypes.GENDER);
        claim.setOptional(true);
        requestedClaims.add(claim);

        // Gender is not expected to be returned because not supported
        List<URI> expectedClaims = new ArrayList<URI>();
        expectedClaims.add(ClaimTypes.FIRSTNAME);
        expectedClaims.add(ClaimTypes.LASTNAME);
        expectedClaims.add(ClaimTypes.EMAILADDRESS);

        ClaimCollection retrievedClaims =
            claimsHandler.retrieveClaimValues(new CustomTokenPrincipal(user), requestedClaims);

        Assert.isTrue(
                      retrievedClaims.size() == expectedClaims.size(),
                      "Retrieved number of claims [" + retrievedClaims.size()
                      + "] doesn't match with expected [" + expectedClaims.size() + "]"
View Full Code Here

    public void testSupportedClaims() throws Exception {

        @SuppressWarnings("unchecked")
        Map<String, String> mapping = (Map)appContext.getBean("claimsToLdapAttributeMapping");

        LdapClaimsHandler cHandler = new LdapClaimsHandler();
        cHandler.setClaimsLdapAttributeMapping(mapping);

        List<URI> supportedClaims = cHandler.getSupportedClaimTypes();

        Assert.isTrue(
                      mapping.size() == supportedClaims.size(),
                      "Supported claims and claims/ldap attribute mapping size different"
        );
View Full Code Here


    @org.junit.Test
    @org.junit.Ignore
    public void testRetrieveClaims() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        RequestClaimCollection requestedClaims = createRequestClaimCollection();

        List<URI> expectedClaims = new ArrayList<URI>();
        expectedClaims.add(ClaimTypes.FIRSTNAME);
        expectedClaims.add(ClaimTypes.LASTNAME);
        expectedClaims.add(ClaimTypes.EMAILADDRESS);
      
        ClaimsParameters params = new ClaimsParameters();
        params.setPrincipal(new CustomTokenPrincipal(user));
        ClaimCollection retrievedClaims =
            claimsHandler.retrieveClaimValues(requestedClaims, params);

        Assert.isTrue(
                      retrievedClaims.size() == expectedClaims.size(),
                      "Retrieved number of claims [" + retrievedClaims.size()
                      + "] doesn't match with expected [" + expectedClaims.size() + "]"
View Full Code Here


    @org.junit.Test(expected = STSException.class)
    @org.junit.Ignore
    public void testRetrieveClaimsWithUnsupportedMandatoryClaimType() throws Exception {
        LdapClaimsHandler claimsHandler = (LdapClaimsHandler)appContext.getBean("testClaimsHandler");

        String user = props.getProperty("claimUser");
        Assert.notNull(user, "Property 'claimUser' not configured");

        RequestClaimCollection requestedClaims = createRequestClaimCollection();
        // add unsupported but mandatory claim
        RequestClaim claim = new RequestClaim();
        claim.setClaimType(ClaimTypes.GENDER);
        claim.setOptional(false);
        requestedClaims.add(claim);

        ClaimsParameters params = new ClaimsParameters();
        params.setPrincipal(new CustomTokenPrincipal(user));
        claimsHandler.retrieveClaimValues(requestedClaims, params);
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.sts.claims.LdapClaimsHandler

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.