Search in sources :

Example 46 with Assertion

use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.

the class IdpAssertionMetricsCollectorTest method shouldNotRegisterIdpAlreadyExist.

@Test
public void shouldNotRegisterIdpAlreadyExist() {
    MetricRegistry metricRegistry = mock(MetricRegistry.class);
    SortedMap<String, Gauge> gaugeMock = mock(SortedMap.class);
    when(gaugeMock.containsKey(any())).thenReturn(true);
    when(metricRegistry.getGauges()).thenReturn(gaugeMock);
    Assertion assertion = anAssertion().withIssuer(anIssuer().withIssuerId("testIdP").build()).buildUnencrypted();
    IdpAssertionMetricsCollector idpAssertionMetricsCollector = new IdpAssertionMetricsCollector(metricRegistry);
    idpAssertionMetricsCollector.update(assertion);
    verify(metricRegistry, times(0)).register(any(), any());
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) Gauge(com.codahale.metrics.Gauge) Test(org.junit.Test)

Example 47 with Assertion

use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.

the class NotOnOrAfterLoggerTest method shouldLogNotOnOrAfterWithIdp.

@Test
public void shouldLogNotOnOrAfterWithIdp() {
    DateTime notOnOrAfter = DateTime.now().withZone(DateTimeZone.UTC).plusHours(1);
    Assertion assertion = anAssertionWithNotOnOrAfter(notOnOrAfter);
    String typeOfAssertion = "assertionType";
    NotOnOrAfterLogger.logAssertionNotOnOrAfter(assertion, typeOfAssertion);
    String expectedMessage = String.format("NotOnOrAfter in %s from %s is set to %s", typeOfAssertion, ISSUER_IDP, notOnOrAfter.toString(dateTimeFormatter));
    verifyLog(mockAppender, captorLoggingEvent, expectedMessage);
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 48 with Assertion

use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.

the class UnknownMethodAlgorithmLoggerTest method shouldNotReportStrongAlgorithmsInIDPAssertion.

@Test
public void shouldNotReportStrongAlgorithmsInIDPAssertion() throws Exception {
    Assertion authnStatementAssertion = anAssertion().withIssuer(anIssuer().withIssuerId(ISSUER_IDP).build()).buildUnencrypted();
    UnknownMethodAlgorithmLogger.probeAssertionForMethodAlgorithm(authnStatementAssertion, AUTHN_STATEMENT);
    verify(mockAppender, times(0)).doAppend(captorLoggingEvent.capture());
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Test(org.junit.Test)

Example 49 with Assertion

use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.

the class UnknownMethodAlgorithmLoggerTest method shouldReportUnknownSignatureAlgorithmInIDPAssertion.

@Test
public void shouldReportUnknownSignatureAlgorithmInIDPAssertion() throws Exception {
    Assertion authnStatementAssertion = anAssertion().withIssuer(anIssuer().withIssuerId(ISSUER_IDP).build()).withSignature(signatureWithUnknownSignatureAlgorithm.get()).buildUnencrypted();
    UnknownMethodAlgorithmLogger.probeAssertionForMethodAlgorithm(authnStatementAssertion, AUTHN_STATEMENT);
    verifyLog(mockAppender, captorLoggingEvent, 1, String.format(UnknownMethodAlgorithmLogger.SIGNATURE_ALGORITHM_MESSAGE, IDP, SIGNATURE_RSASHA1_ID, AUTHN_STATEMENT + Assertion.DEFAULT_ELEMENT_LOCAL_NAME));
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Test(org.junit.Test)

Example 50 with Assertion

use of org.opensaml.saml.saml1.core.Assertion in project verify-hub by alphagov.

the class UnknownMethodAlgorithmLoggerTest method shouldReportUnknownSignatureAndDigestAlgorithmsInIDPAssertion.

@Test
public void shouldReportUnknownSignatureAndDigestAlgorithmsInIDPAssertion() throws Exception {
    Assertion authnStatementAssertion = anAssertion().withId(ID).withIssuer(anIssuer().withIssuerId(ISSUER_IDP).build()).withSignature(signatureWithUnknownSignatureAndDigestAlgorithms.get()).buildUnencrypted();
    UnknownMethodAlgorithmLogger.probeAssertionForMethodAlgorithm(authnStatementAssertion, AUTHN_STATEMENT);
    verifyLog(mockAppender, captorLoggingEvent, 1, String.format(UnknownMethodAlgorithmLogger.SIGNATURE_AND_DIGEST_ALGORITHMS_MESSAGE, IDP, SIGNATURE_RSASHA1_ID, DIGEST_SHA1_ID, AUTHN_STATEMENT + Assertion.DEFAULT_ELEMENT_LOCAL_NAME));
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Test(org.junit.Test)

Aggregations

Assertion (org.opensaml.saml.saml2.core.Assertion)33 Test (org.junit.Test)16 Assertion (org.opensaml.saml.saml1.core.Assertion)13 AssertionBuilder.anAssertion (uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion)9 Response (org.opensaml.saml.saml2.core.Response)8 DateTime (org.joda.time.DateTime)6 Assertion (org.opensaml.saml2.core.Assertion)6 Element (org.w3c.dom.Element)6 PassthroughAssertion (uk.gov.ida.saml.core.domain.PassthroughAssertion)6 Subject (org.opensaml.saml.saml2.core.Subject)5 MetricRegistry (com.codahale.metrics.MetricRegistry)4 ZonedDateTime (java.time.ZonedDateTime)4 ArrayList (java.util.ArrayList)4 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)4 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)4 Credential (org.apache.wss4j.dom.validate.Credential)4 Service (org.apereo.cas.authentication.principal.Service)4 RegisteredService (org.apereo.cas.services.RegisteredService)4 WsFederationCredential (org.apereo.cas.support.wsfederation.authentication.principal.WsFederationCredential)4 XMLObject (org.opensaml.core.xml.XMLObject)4