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());
}
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;
}
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;
}
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;
}
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());
}
Aggregations