WebSSOProfileConsumerImpl extends AbstractProfileBase implements WebSSOProfileConsumer { protected void verifyAuthnContext(RequestedAuthnContext requestedAuthnContext, AuthnContext receivedContext, SAMLMessageContext context) throws InsufficientAuthenticationException { log.debug("Verifying received AuthnContext {} against requested {}", receivedContext, requestedAuthnContext); if (requestedAuthnContext != null && AuthnContextComparisonTypeEnumeration.EXACT.equals(requestedAuthnContext.getComparison())) { String classRef = null, declRef = null; if (receivedContext.getAuthnContextClassRef() != null) { classRef = receivedContext.getAuthnContextClassRef().getAuthnContextClassRef(); } if (requestedAuthnContext.getAuthnContextClassRefs() != null) { for (AuthnContextClassRef classRefRequested : requestedAuthnContext.getAuthnContextClassRefs()) { if (classRefRequested.getAuthnContextClassRef().equals(classRef)) { log.debug("AuthContext matched with value {}", classRef); return; } } } if (receivedContext.getAuthnContextDeclRef() != null) { declRef = receivedContext.getAuthnContextDeclRef().getAuthnContextDeclRef(); } if (requestedAuthnContext.getAuthnContextDeclRefs() != null) { for (AuthnContextDeclRef declRefRequested : requestedAuthnContext.getAuthnContextDeclRefs()) { if (declRefRequested.getAuthnContextDeclRef().equals(declRef)) { log.debug("AuthContext matched with value {}", declRef); return; } } } throw new InsufficientAuthenticationException("Response doesn't contain any of the requested authentication context class or declaration references"); } } WebSSOProfileConsumerImpl();  WebSSOProfileConsumerImpl(SAMLProcessor processor, MetadataManager manager); @Override String getProfileIdentifier(); SAMLCredential processAuthenticationResponse(SAMLMessageContext context); long getMaxAuthenticationAge(); void setMaxAuthenticationAge(long maxAuthenticationAge); boolean isIncludeAllAttributes(); void setIncludeAllAttributes(boolean includeAllAttributes); boolean isReleaseDOM(); void setReleaseDOM(boolean releaseDOM);  }
@Test public void testAuthnExactComparison() throws Exception { RequestedAuthnContext requestedAuthnContext = helper.getRequestedAuthnContext(AuthnContextComparisonTypeEnumeration.EXACT, Arrays.asList("test", "test2")); AuthnContext authnContext = helper.getAuthnContext(helper.getClassRef("test2"), null); profile.verifyAuthnContext(requestedAuthnContext, authnContext, null); }
@Test(expected = InsufficientAuthenticationException.class) public void testAuthnExactComparison_none() throws Exception { RequestedAuthnContext requestedAuthnContext = helper.getRequestedAuthnContext(AuthnContextComparisonTypeEnumeration.EXACT, Arrays.asList("test", "test2")); AuthnContext authnContext = helper.getAuthnContext(helper.getClassRef("test5"), null); profile.verifyAuthnContext(requestedAuthnContext, authnContext, null); }