SAMLContextProviderImpl implements SAMLContextProvider, InitializingBean { public SAMLMessageContext getLocalEntity(HttpServletRequest request, HttpServletResponse response) throws MetadataProviderException { SAMLMessageContext context = new SAMLMessageContext(); populateGenericContext(request, response, context); populateLocalEntityId(context, request.getRequestURI()); populateLocalContext(context); return context; }  SAMLMessageContext getLocalEntity(HttpServletRequest request, HttpServletResponse response); SAMLMessageContext getLocalAndPeerEntity(HttpServletRequest request, HttpServletResponse response); @Autowired void setMetadata(MetadataManager metadata); @Autowired void setKeyManager(KeyManager keyManager); void setPkixResolver(PKIXValidationInformationResolver pkixResolver); void setPkixTrustEvaluator(PKIXTrustEvaluator pkixTrustEvaluator); void setMetadataResolver(MetadataCredentialResolver metadataResolver); @Autowired(required = false) void setStorageFactory(SAMLMessageStorageFactory storageFactory); void afterPropertiesSet();  }
@Test public void testPopulateLocalEntityNullPath() throws Exception { setLocalContextParameters(request, "", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals(metadata.getHostedSPName(), context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); assertEquals(context.getLocalSSLHostnameVerifier(), HostnameVerifier.DEFAULT); verifyMock(); }
@Test public void testPopulateLocalEntityNoAlias() throws Exception { setLocalContextParameters(request, "/SSO", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals(metadata.getHostedSPName(), context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test public void testPopulateLocalEntityAliasNoRole() throws Exception { setLocalContextParameters(request, "/SSO/alias/myAlias", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("testSP2", context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); assertEquals(context.getLocalSSLHostnameVerifier(), HostnameVerifier.STRICT); verifyMock(); }
@Test public void testPopulateLocalEntityAliasSPRole() throws Exception { setLocalContextParameters(request, "/SSO/alias/myAlias/sp", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("testSP2", context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test public void testPopulateLocalEntityAliasDefaultRole() throws Exception { setLocalContextParameters(request, "/SSO/alias/myAlias/invalid", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("testSP2", context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test(expected = MetadataProviderException.class) public void testPopulateLocalEntityAliasInvalidRole() throws Exception { setLocalContextParameters(request, "/SSO/alias/myAlias/idp", null); replayMock(); contextProvider.getLocalEntity(request, response); }
@Test public void testPopulateLocalEntityAliasIDPRole() throws Exception { setLocalContextParameters(request, "/SSO/alias/myIdpAlias/iDp", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("http: assertEquals(IDPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test(expected = MetadataProviderException.class) public void testPopulateLocalEntityComplexAliasIDPRole_missingRole_SP() throws Exception { setLocalContextParameters(request, "/saml/SSO/test/alias/myIdpAlias/test", null); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("http: assertEquals(IDPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test public void testPopulateCredentialLocalEntity() throws Exception { setLocalContextParameters(request, "/", "testSP2"); replayMock(); SAMLMessageContext context = contextProvider.getLocalEntity(request, response); assertEquals("testSP2", context.getLocalEntityId()); assertEquals(SPSSODescriptor.DEFAULT_ELEMENT_NAME, context.getLocalEntityRole()); verifyMock(); }
@Test(expected = MetadataProviderException.class) public void testPopulateCredentialLocalEntity_invalidName() throws Exception { setLocalContextParameters(request, "/", "ABC"); replayMock(); contextProvider.getLocalEntity(request, response); verifyMock(); }