CONNECTSamlAssertionValidator extends SamlAssertionValidator { protected Collection<Saml2ExchangeAuthFrameworkValidator> getSaml2SpecValidators() { try { final Boolean allowNoSubjectAssertion = propertyAccessor .getPropertyBoolean(NhincConstants.SAML_PROPERTY_FILE, SamlConstants.ALLOW_NO_SUBJECT_ASSERTION_PROP); if (allowNoSubjectAssertion) { return getSaml2AllowNoSubjectAssertionSpecValidators(); } else { return getSaml2DefaultAssertionSpecValidators(); } } catch (final Exception e) { LOG.warn("Failed to get SAML 2 assertion validator. " + e.getMessage(), e); return CollectionUtils.EMPTY_COLLECTION; } } CONNECTSamlAssertionValidator();  CONNECTSamlAssertionValidator(final PropertyAccessor propertyAccessor); @Override Credential validate(final Credential credential, final RequestData data); void checkAttributes(SamlAssertionWrapper assertion);  }
@Test public void testGetSaml2SpecValidator() throws PropertyAccessException { final PropertyAccessor propAccessor = mock(PropertyAccessor.class); final CONNECTSamlAssertionValidator connectValidator = new CONNECTSamlAssertionValidator(propAccessor) { @Override protected Collection<Saml2ExchangeAuthFrameworkValidator> getSaml2DefaultAssertionSpecValidators() { return null; } @Override protected boolean validateAttributes() { return false; } }; when(propAccessor.getPropertyBoolean(NhincConstants.SAML_PROPERTY_FILE, SamlConstants.ALLOW_NO_SUBJECT_ASSERTION_PROP)).thenReturn(true, false); Collection<Saml2ExchangeAuthFrameworkValidator> validators = connectValidator.getSaml2SpecValidators(); Saml2ExchangeAuthFrameworkValidator validator = null; for (final Saml2ExchangeAuthFrameworkValidator v : validators) { if (v instanceof Saml2ExchangeAuthFrameworkValidator) { validator = v; } } assertNotNull(validator); validators = connectValidator.getSaml2SpecValidators(); assertNull(validators); }