Search in sources :

Example 1 with AttributeQuery

use of org.opensaml.saml.saml2.core.AttributeQuery in project ddf by codice.

the class SamlProtocolTest method testCreateAttributeQueryWithDestination.

@Test
public void testCreateAttributeQueryWithDestination() {
    AttributeQuery attributeQuery = SamlProtocol.createAttributeQuery(SamlProtocol.createIssuer("myissuer"), SamlProtocol.createSubject(SamlProtocol.createNameID("mynameid")), "mydestination");
    assertEquals("myissuer", attributeQuery.getIssuer().getValue());
    assertEquals("mynameid", attributeQuery.getSubject().getNameID().getValue());
    assertEquals("mydestination", attributeQuery.getDestination());
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Test(org.junit.Test)

Example 2 with AttributeQuery

use of org.opensaml.saml.saml2.core.AttributeQuery in project ddf by codice.

the class SamlProtocol method createAttributeQuery.

public static AttributeQuery createAttributeQuery(Issuer issuer, Subject subject, String destination) {
    AttributeQuery attributeQuery = attributeQueryBuilder.buildObject();
    attributeQuery.setID(UUID.randomUUID().toString());
    attributeQuery.setIssueInstant(new DateTime());
    attributeQuery.setIssuer(issuer);
    attributeQuery.setSubject(subject);
    attributeQuery.setVersion(SAMLVersion.VERSION_20);
    if (StringUtils.isNotBlank(destination)) {
        attributeQuery.setDestination(destination);
    }
    return attributeQuery;
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) DateTime(org.joda.time.DateTime)

Example 3 with AttributeQuery

use of org.opensaml.saml.saml2.core.AttributeQuery in project ddf by codice.

the class AttributeQueryClaimsHandler method getAttributes.

/**
     * Gets the attributes for the supplied user from the external attribute store.
     * Returns null if the AttributeQueryClient is null.
     *
     * @param nameId used for the request.
     * @return The collection of attributes retrieved from the external attribute store.
     * @throws URISyntaxException
     */
protected ProcessedClaimCollection getAttributes(String nameId) throws URISyntaxException {
    ProcessedClaimCollection claimCollection = new ProcessedClaimCollection();
    LOGGER.debug("Sending AttributeQuery Request.");
    AttributeQueryClient attributeQueryClient;
    Assertion assertion;
    try {
        attributeQueryClient = createAttributeQueryClient(simpleSign, externalAttributeStoreUrl, issuer, destination);
        if (attributeQueryClient == null) {
            return null;
        }
        assertion = attributeQueryClient.query(nameId);
        if (assertion != null) {
            createClaims(claimCollection, assertion);
        }
    } catch (AttributeQueryException ex) {
        LOGGER.info("Error occurred in AttributeQueryClient, did not retrieve response. Set log level for \"org.codice.ddf.security.claims.attributequery.common\" to DEBUG for more information.");
        LOGGER.debug("Error occurred in AttributeQueryClient, did not retrieve response.", ex);
    }
    return claimCollection;
}
Also used : ProcessedClaimCollection(org.apache.cxf.sts.claims.ProcessedClaimCollection) Assertion(org.opensaml.saml.saml2.core.Assertion)

Example 4 with AttributeQuery

use of org.opensaml.saml.saml2.core.AttributeQuery in project ddf by codice.

the class AttributeQueryClient method createRequest.

private AttributeQuery createRequest(String username) {
    LOGGER.debug("Creating SAML Protocol AttributeQuery for user: {}.", username);
    AttributeQuery attributeQuery = SamlProtocol.createAttributeQuery(SamlProtocol.createIssuer(issuer), SamlProtocol.createSubject(SamlProtocol.createNameID(username)), destination);
    LOGGER.debug("SAML Protocol AttributeQuery created for user: {}.", username);
    return attributeQuery;
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery)

Example 5 with AttributeQuery

use of org.opensaml.saml.saml2.core.AttributeQuery in project ddf by codice.

the class SamlProtocolTest method testCreateAttributeQueryWithoutDestination.

@Test
public void testCreateAttributeQueryWithoutDestination() {
    AttributeQuery attributeQuery = SamlProtocol.createAttributeQuery(SamlProtocol.createIssuer("myissuer"), SamlProtocol.createSubject(SamlProtocol.createNameID("mynameid")));
    assertEquals("myissuer", attributeQuery.getIssuer().getValue());
    assertEquals("mynameid", attributeQuery.getSubject().getNameID().getValue());
    assertNull(attributeQuery.getDestination());
}
Also used : AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Test(org.junit.Test)

Aggregations

AttributeQuery (org.opensaml.saml.saml2.core.AttributeQuery)4 Test (org.junit.Test)2 ProcessedClaimCollection (org.apache.cxf.sts.claims.ProcessedClaimCollection)1 DateTime (org.joda.time.DateTime)1 Assertion (org.opensaml.saml.saml2.core.Assertion)1