HOKSAMLAssertionBuilder extends SAMLAssertionBuilder { protected Conditions createConditions(final CallbackProperties properties) { DateTime issueInstant = new DateTime(); DateTime beginValidTime = properties.getSamlConditionsNotBefore(); DateTime endValidTime = properties.getSamlConditionsNotAfter(); if (beginValidTime != null && endValidTime != null) { if (isConditionsDefaultValueEnabled() || beginValidTime.isAfter(endValidTime)) { beginValidTime = setBeginValidTime(beginValidTime, issueInstant); endValidTime = setEndValidTime(endValidTime, issueInstant); } return componentBuilder.createConditions(beginValidTime, endValidTime); } return null; } HOKSAMLAssertionBuilder();   HOKSAMLAssertionBuilder(final CertificateManager certificateManager); @Override Element build(final CallbackProperties properties, String certificateAlias); List<Statement> createAttributeStatements(final CallbackProperties properties, final Subject subject); void addOptionalStatement(List<Statement> statements, Statement statement); void addOptionalAttributeStatements(List<Statement> statements, List<AttributeStatement> statementList); AuthnStatement createAuthenicationStatements(final CallbackProperties properties); AuthzDecisionStatement createAuthorizationDecisionStatement(final CallbackProperties properties,
        final Subject subject); Evidence createEvidence(final CallbackProperties properties, final Subject subject); Evidence buildEvidence(CallbackProperties properties, List<AttributeStatement> statements, Subject subject); AttributeStatement createSubjectIdAttributeStatement(final CallbackProperties properties); static String appendPrefixHomeCommunityID(final String homeCommunityId); static String checkPrefixBeforeAppend(final String checkValue, final String checkPrefix); static List<Object> checkHcidPrefixInList(final List<Object> valueList);  }
@Test public void testSamlConditionsNotBeforeAndNotAfterPresent() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = new HOKSAMLAssertionBuilder() { @Override protected boolean isConditionsDefaultValueEnabled() { return true; } }; final DateTime conditionNotBefore = new DateTime(); final DateTime conditionNotAfter = new DateTime(); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); final Conditions conditions = builder.createConditions(callbackProps); assertNotNull(conditions); assertTrue(conditionNotBefore.isBefore(conditions.getNotOnOrAfter())); }
@Test public void testSamlConditionsNotBeforeIsNull() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = new HOKSAMLAssertionBuilder() { @Override protected boolean isConditionsDefaultValueEnabled() { return false; } }; final DateTime conditionNotAfter = new DateTime(); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(null); final Conditions conditions = builder.createConditions(callbackProps); assertNull(conditions); }
@Test public void testSamlConditionsNotAfterIsNull() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = getNonDefaultConditionBuilder(); final DateTime conditionNotBefore = new DateTime(); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(null); final Conditions conditions = builder.createConditions(callbackProps); assertNull(conditions); }
@Test public void testSamlConditionsPropertyOffBeginInvalid() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = getNonDefaultConditionBuilder(); final DateTime now = new DateTime(); final DateTime conditionNotBefore = now.plusYears(2); final DateTime conditionNotAfter = now.plusYears(3); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); final Conditions conditions = builder.createConditions(callbackProps); assertNotNull(conditions); assertEquals(conditions.getNotBefore().getMillis(), conditionNotBefore.getMillis()); assertEquals(conditions.getNotOnOrAfter().getMillis(), conditionNotAfter.getMillis()); }
@Test public void testSamlConditionsPropertyOffAfterInvalid() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = getNonDefaultConditionBuilder(); final DateTime now = new DateTime(); final DateTime conditionNotBefore = now.minusYears(3); final DateTime conditionNotAfter = now.minusYears(2); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); final Conditions conditions = builder.createConditions(callbackProps); assertNotNull(conditions); assertEquals(conditions.getNotBefore().getMillis(), conditionNotBefore.getMillis()); assertEquals(conditions.getNotOnOrAfter().getMillis(), conditionNotAfter.getMillis()); }
@Test public void testSamlConditionsPropertyOnInvalidBefore() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = getDefaultConditionBuilder(); final DateTime now = new DateTime(); final DateTime conditionNotBefore = now.plusYears(2); final DateTime conditionNotAfter = now.plusYears(3); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); final Conditions conditions = builder.createConditions(callbackProps); assertNotNull(conditions); assertNotEquals(conditions.getNotBefore().getMillis(), conditionNotBefore.getMillis()); }
@Test public void testSamlConditionsPropertyOnInvalidAfter() { final CallbackProperties callbackProps = mock(CallbackProperties.class); final HOKSAMLAssertionBuilder builder = getDefaultConditionBuilder(); final DateTime now = new DateTime(); final DateTime conditionNotBefore = now.minusYears(3); final DateTime conditionNotAfter = now.minusYears(2); when(callbackProps.getSamlConditionsNotBefore()).thenReturn(conditionNotBefore); when(callbackProps.getSamlConditionsNotAfter()).thenReturn(conditionNotAfter); final Conditions conditions = builder.createConditions(callbackProps); assertNotNull(conditions); assertNotEquals(conditions.getNotOnOrAfter().getMillis(), conditionNotAfter.getMillis()); }