use of ddf.security.assertion.saml.impl.SecurityAssertionSaml in project ddf by codice.
the class SecurityAssertionSamlTest method testIsPresentlyValidAfterNotOnOrAfter.
@Test
public void testIsPresentlyValidAfterNotOnOrAfter() throws Exception {
Element issuedAssertion = this.readDocument("/saml.xml").getDocumentElement();
// Change the NotOnOrAfter Date on the SAML Assertion to be before "now"
issuedAssertion.getElementsByTagName("saml2:Conditions").item(0).getAttributes().getNamedItem("NotOnOrAfter").setNodeValue(getNowWithOffset(-1));
SecurityAssertionSaml assertion = getSecurityAssertion(issuedAssertion);
assertFalse(assertion.isPresentlyValid());
}
use of ddf.security.assertion.saml.impl.SecurityAssertionSaml in project ddf by codice.
the class SecurityAssertionSamlTest method testIsPresentlyValidBeforeNotBefore.
@Test
public void testIsPresentlyValidBeforeNotBefore() throws Exception {
Element issuedAssertion = this.readDocument("/saml.xml").getDocumentElement();
// Change the NotBefore Date on the SAML Assertion to be after "now"
issuedAssertion.getElementsByTagName("saml2:Conditions").item(0).getAttributes().getNamedItem("NotBefore").setNodeValue(getNowWithOffset(1));
SecurityAssertionSaml assertion = getSecurityAssertion(issuedAssertion);
assertFalse(assertion.isPresentlyValid());
}
use of ddf.security.assertion.saml.impl.SecurityAssertionSaml in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateInvalidSignature.
@Test(expected = AuthenticationFailureException.class)
public void testValidateInvalidSignature() throws Exception {
Assertion assertion = createAssertion(false, false, "WRONG", 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);
}
use of ddf.security.assertion.saml.impl.SecurityAssertionSaml in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateIncorrectSamlVersion.
@Test(expected = AuthenticationFailureException.class)
public void testValidateIncorrectSamlVersion() throws Exception {
org.opensaml.saml.saml1.core.Assertion assertion = new org.opensaml.saml.saml1.core.impl.AssertionBuilder().buildObject();
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 ddf.security.assertion.saml.impl.SecurityAssertionSaml in project ddf by codice.
the class SamlAssertionValidatorImplTest method testValidateBearerAssertion.
@Test
public void testValidateBearerAssertion() throws Exception {
Assertion assertion = createAssertion(true, 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");
X509Certificate[] certs = { certificate };
samlAuthenticationToken.setX509Certs(certs);
samlAssertionValidator.validate(samlAuthenticationToken);
}
Aggregations