use of org.opensaml.saml2.core.Assertion 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 ClaimsCollection getAttributes(String nameId) throws URISyntaxException {
ClaimsCollection claimCollection = new ClaimsCollectionImpl();
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.saml2.core.Assertion in project ddf by codice.
the class AttributeQueryClientTest method testRetrieveResponse.
@Test
public void testRetrieveResponse() {
setResponse(cannedResponse, false);
Assertion assertion = attributeQueryClient.query(USERNAME);
assertThat(assertion, is(notNullValue()));
assertThat(assertion.getIssuer().getValue(), is(equalTo("localhost")));
assertThat(assertion.getSubject().getNameID().getValue(), is(equalTo("admin")));
assertThat(assertion.getAttributeStatements(), is(notNullValue()));
}
use of org.opensaml.saml2.core.Assertion in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateUnsignedAssertion.
@Test(expected = AuthenticationFailureException.class)
public void testValidateUnsignedAssertion() throws Exception {
Assertion assertion = createAssertion(false, true, ISSUER, new DateTime().plusDays(3));
Element securityToken = SAMLUtils.getInstance().getSecurityTokenFromSAMLAssertion(samlObjectToString(assertion));
SimplePrincipalCollection simplePrincipalCollection = new SimplePrincipalCollection();
simplePrincipalCollection.add(new SecurityAssertionSaml(securityToken), "default");
SAMLAuthenticationToken samlAuthenticationToken = new SAMLAuthenticationToken(simplePrincipalCollection, simplePrincipalCollection, "127.0.0.1");
samlAssertionValidator.validate(samlAuthenticationToken);
}
use of org.opensaml.saml2.core.Assertion in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateWithHolderOfKeyAssertion.
@Test
public void testValidateWithHolderOfKeyAssertion() throws Exception {
Assertion assertion = createHolderOfKeyAssertion();
Element securityToken = SAMLUtils.getInstance().getSecurityTokenFromSAMLAssertion(samlObjectToString(assertion));
SimplePrincipalCollection simplePrincipalCollection = new SimplePrincipalCollection();
simplePrincipalCollection.add(new SecurityAssertionSaml(securityToken), "default");
SAMLAuthenticationToken samlAuthenticationToken = new SAMLAuthenticationToken(simplePrincipalCollection, simplePrincipalCollection, "127.0.0.1");
X509Certificate[] certs = { certificate };
samlAuthenticationToken.setX509Certs(certs);
samlAssertionValidator.validate(samlAuthenticationToken);
}
use of org.opensaml.saml2.core.Assertion in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateExpiredAssertion.
@Test(expected = AuthenticationFailureException.class)
public void testValidateExpiredAssertion() throws Exception {
Assertion assertion = createAssertion(false, true, ISSUER, new DateTime().minusSeconds(10));
Element securityToken = SAMLUtils.getInstance().getSecurityTokenFromSAMLAssertion(samlObjectToString(assertion));
SimplePrincipalCollection simplePrincipalCollection = new SimplePrincipalCollection();
simplePrincipalCollection.add(new SecurityAssertionSaml(securityToken), "default");
SAMLAuthenticationToken samlAuthenticationToken = new SAMLAuthenticationToken(simplePrincipalCollection, simplePrincipalCollection, "127.0.0.1");
samlAssertionValidator.validate(samlAuthenticationToken);
}
Aggregations