org.opensaml.xml.parse.ParserPool Java Examples
The following examples show how to use
org.opensaml.xml.parse.ParserPool.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SamlManagerTest.java From blackduck-alert with Apache License 2.0 | 6 votes |
@Test public void testUpdateSamlDisabled() throws Exception { SAMLContext context = Mockito.mock(SAMLContext.class); ParserPool parserPool = Mockito.mock(ParserPool.class); ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class); MetadataManager metadataManager = Mockito.mock(MetadataManager.class); MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class); ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class); FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class); Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration); Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.FALSE.booleanValue()); SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context); samlManager.updateSAMLConfiguration(Boolean.FALSE.booleanValue(), "metadataURL", "entityId", "baseURL"); Mockito.verify(metadataGenerator).setEntityId(null); Mockito.verify(metadataGenerator).setEntityBaseURL(null); Mockito.verify(metadataManager).setProviders(Mockito.anyList()); Mockito.verify(metadataManager).setDefaultIDP(null); Mockito.verify(metadataManager).setHostedSPName(null); Mockito.verify(metadataManager).afterPropertiesSet(); }
Example #2
Source File: SamlManagerTest.java From blackduck-alert with Apache License 2.0 | 6 votes |
@Test public void testUpdateSamlEnabled() throws Exception { SAMLContext context = Mockito.mock(SAMLContext.class); ParserPool parserPool = Mockito.mock(ParserPool.class); ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class); MetadataManager metadataManager = Mockito.mock(MetadataManager.class); MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class); ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class); FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class); Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration); Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.TRUE.booleanValue()); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("metadataURL"); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("entityId"); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("baseURL"); SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context); samlManager.updateSAMLConfiguration(Boolean.TRUE.booleanValue(), "metadataURL", "entityId", "baseURL"); Mockito.verify(metadataGenerator).setEntityId(Mockito.anyString()); Mockito.verify(metadataGenerator).setEntityBaseURL(Mockito.anyString()); // these methods are called to clear the existing metadata and then set it if true. Mockito.verify(metadataManager, Mockito.times(2)).setProviders(Mockito.anyList()); Mockito.verify(metadataManager, Mockito.times(2)).afterPropertiesSet(); }
Example #3
Source File: SAMLStartupComponentTest.java From blackduck-alert with Apache License 2.0 | 6 votes |
@Test public void testInitialize() throws Exception { SAMLContext context = Mockito.mock(SAMLContext.class); ParserPool parserPool = Mockito.mock(ParserPool.class); ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class); MetadataManager metadataManager = Mockito.mock(MetadataManager.class); MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class); ConfigurationModel currentConfiguration = Mockito.mock(ConfigurationModel.class); FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class); Mockito.when(context.getCurrentConfiguration()).thenReturn(currentConfiguration); Mockito.when(context.isSAMLEnabled(Mockito.any(ConfigurationModel.class))).thenReturn(Boolean.TRUE.booleanValue()); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("metadataURL"); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("entityId"); Mockito.when(context.getFieldValueOrEmpty(Mockito.any(ConfigurationModel.class), Mockito.anyString())).thenReturn("baseURL"); SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context); SAMLStartupComponent startupComponent = new SAMLStartupComponent(context, samlManager); startupComponent.initializeComponent(); Mockito.verify(metadataGenerator).setEntityId(Mockito.anyString()); Mockito.verify(metadataGenerator).setEntityBaseURL(Mockito.anyString()); Mockito.verify(metadataManager, Mockito.times(2)).setProviders(Mockito.anyList()); Mockito.verify(metadataManager, Mockito.times(2)).afterPropertiesSet(); }
Example #4
Source File: SAMLStartupComponentTest.java From blackduck-alert with Apache License 2.0 | 6 votes |
@Test public void testInitializeException() throws Exception { SAMLContext context = Mockito.mock(SAMLContext.class); ParserPool parserPool = Mockito.mock(ParserPool.class); ExtendedMetadata extendedMetadata = Mockito.mock(ExtendedMetadata.class); MetadataManager metadataManager = Mockito.mock(MetadataManager.class); MetadataGenerator metadataGenerator = Mockito.mock(MetadataGenerator.class); FilePersistenceUtil filePersistenceUtil = Mockito.mock(FilePersistenceUtil.class); Mockito.when(context.getCurrentConfiguration()).thenThrow(new AlertDatabaseConstraintException("Test exception")); SAMLManager samlManager = new SAMLManager(parserPool, extendedMetadata, metadataManager, metadataGenerator, filePersistenceUtil, context); SAMLStartupComponent startupComponent = new SAMLStartupComponent(context, samlManager); startupComponent.initializeComponent(); Mockito.verify(metadataGenerator, Mockito.times(0)).setEntityId(Mockito.anyString()); Mockito.verify(metadataGenerator, Mockito.times(0)).setEntityBaseURL(Mockito.anyString()); Mockito.verify(metadataManager, Mockito.times(0)).setProviders(Mockito.anyList()); Mockito.verify(metadataManager, Mockito.times(0)).afterPropertiesSet(); }
Example #5
Source File: MetadataManagerConfigurerTest.java From spring-boot-security-saml with MIT License | 6 votes |
@Before public void setup() { properties = mock(SAMLSSOProperties.class); metadataManagerProperties = spy(new MetadataManagerProperties()); extendedMetadataDelegateProperties = spy(new ExtendedMetadataDelegateProperties()); idpConfiguration = spy(new IdentityProvidersProperties()); extendedMetadata = spy(new ExtendedMetadata()); when(properties.getMetadataManager()).thenReturn(metadataManagerProperties); when(properties.getExtendedDelegate()).thenReturn(extendedMetadataDelegateProperties); when(properties.getIdp()).thenReturn(idpConfiguration); builder = mock(ServiceProviderBuilder.class); when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties); when(builder.getSharedObject(ExtendedMetadata.class)).thenReturn(extendedMetadata); resourceLoader = new DefaultResourceLoader(); when(builder.getSharedObject(ResourceLoader.class)).thenReturn(resourceLoader); parserPool = mock(ParserPool.class); when(builder.getSharedObject(ParserPool.class)).thenReturn(parserPool); }
Example #6
Source File: WebSecurityConfig.java From spring-tsers-auth with Apache License 2.0 | 5 votes |
@Bean @Qualifier("idp-ssocircle") public ExtendedMetadataDelegate ssoCircleExtendedMetadataProvider() throws MetadataProviderException { AbstractMetadataProvider provider = new AbstractMetadataProvider() { @Override protected XMLObject doGetMetadata() throws MetadataProviderException { DefaultResourceLoader loader = new DefaultResourceLoader(); Resource storeFile = loader.getResource("classPath:/saml/idp-metadata.xml"); ParserPool parser = parserPool(); try { Document mdDocument = parser.parse(storeFile.getInputStream()); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(mdDocument.getDocumentElement()); return unmarshaller.unmarshall(mdDocument.getDocumentElement()); } catch (Exception e) { e.printStackTrace(); throw new MetadataProviderException(); } } }; ExtendedMetadataDelegate extendedMetadataDelegate = new ExtendedMetadataDelegate(provider, extendedMetadata()); extendedMetadataDelegate.setMetadataTrustCheck(false); extendedMetadataDelegate.setMetadataRequireSignature(false); return extendedMetadataDelegate; }
Example #7
Source File: SAMLProcessorConfigurerTest.java From spring-boot-security-saml with MIT License | 5 votes |
@Before public void setup() { properties = mock(SAMLSSOProperties.class); samlProcessorConfig = spy(new SAMLProcessorProperties()); when(properties.getSamlProcessor()).thenReturn(samlProcessorConfig); builder = mock(ServiceProviderBuilder.class); parserPool = mock(ParserPool.class); when(builder.getSharedObject(ParserPool.class)).thenReturn(parserPool); when(builder.getSharedObject(SAMLSSOProperties.class)).thenReturn(properties); }
Example #8
Source File: XMLObjectHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Unmarshall a Document from a Reader. * * @param parserPool the ParserPool instance to use * @param reader the Reader to unmarshall * @return the unmarshalled XMLObject * @throws XMLParserException if there is a problem parsing the input data * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM */ public static XMLObject unmarshallFromReader(ParserPool parserPool, Reader reader) throws XMLParserException, UnmarshallingException { Logger log = getLogger(); log.debug("Parsing Reader into DOM document"); Document messageDoc = parserPool.parse(reader); Element messageElem = messageDoc.getDocumentElement(); if (log.isTraceEnabled()) { log.trace("Resultant DOM message was:"); log.trace(XMLHelper.nodeToString(messageElem)); } log.debug("Unmarshalling DOM parsed from Reader"); Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem); if (unmarshaller == null) { log.error("Unable to unmarshall Reader, no unmarshaller registered for element " + XMLHelper.getNodeQName(messageElem)); throw new UnmarshallingException( "Unable to unmarshall Reader, no unmarshaller registered for element " + XMLHelper.getNodeQName(messageElem)); } XMLObject message = unmarshaller.unmarshall(messageElem); log.debug("Reader succesfully unmarshalled"); return message; }
Example #9
Source File: XMLObjectHelper.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Unmarshall a Document from an InputSteam. * * @param parserPool the ParserPool instance to use * @param inputStream the InputStream to unmarshall * @return the unmarshalled XMLObject * @throws XMLParserException if there is a problem parsing the input data * @throws UnmarshallingException if there is a problem unmarshalling the parsed DOM */ public static XMLObject unmarshallFromInputStream(ParserPool parserPool, InputStream inputStream) throws XMLParserException, UnmarshallingException { Logger log = getLogger(); log.debug("Parsing InputStream into DOM document"); Document messageDoc = parserPool.parse(inputStream); Element messageElem = messageDoc.getDocumentElement(); if (log.isTraceEnabled()) { log.trace("Resultant DOM message was:"); log.trace(XMLHelper.nodeToString(messageElem)); } log.debug("Unmarshalling DOM parsed from InputStream"); Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(messageElem); if (unmarshaller == null) { log.error("Unable to unmarshall InputStream, no unmarshaller registered for element " + XMLHelper.getNodeQName(messageElem)); throw new UnmarshallingException( "Unable to unmarshall InputStream, no unmarshaller registered for element " + XMLHelper.getNodeQName(messageElem)); } XMLObject message = unmarshaller.unmarshall(messageElem); log.debug("InputStream succesfully unmarshalled"); return message; }
Example #10
Source File: SAMLServiceProviderSecurityConfiguration.java From spring-boot-security-saml with MIT License | 5 votes |
@Override public void afterPropertiesSet() { //All existing beans are thrown as shared objects to the ServiceProviderSecurityBuilder, which will wire all //beans/objects related to spring security SAML. serviceProviderBuilder.setSharedObject(ParserPool.class, ParserPoolHolder.getPool()); serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerImpl.class, (WebSSOProfileConsumerImpl) webSSOProfileConsumer); serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer); serviceProviderBuilder.setSharedObject(ServiceProviderEndpoints.class, new ServiceProviderEndpoints()); serviceProviderBuilder.setSharedObject(ResourceLoader.class, resourceLoader); serviceProviderBuilder.setSharedObject(SAMLSSOProperties.class, sAMLSsoProperties); serviceProviderBuilder.setSharedObject(ExtendedMetadata.class, extendedMetadata); serviceProviderBuilder.setSharedObject(LocalExtendedMetadata.class, localExtendedMetadata); serviceProviderBuilder.setSharedObject(SAMLAuthenticationProvider.class, samlAuthenticationProvider); serviceProviderBuilder.setSharedObject(SAMLContextProvider.class, samlContextProvider); serviceProviderBuilder.setSharedObject(KeyManager.class, keyManager); serviceProviderBuilder.setSharedObject(MetadataManager.class, metadataManager); serviceProviderBuilder.setSharedObject(MetadataGenerator.class, metadataGenerator); serviceProviderBuilder.setSharedObject(SAMLProcessor.class, samlProcessor); serviceProviderBuilder.setSharedObject(WebSSOProfile.class, webSSOProfile); serviceProviderBuilder.setSharedObject(WebSSOProfileECPImpl.class, ecpProfile); serviceProviderBuilder.setSharedObject(WebSSOProfileHoKImpl.class, hokWebSSOProfile); serviceProviderBuilder.setSharedObject(SingleLogoutProfile.class, sloProfile); serviceProviderBuilder.setSharedObject(WebSSOProfileConsumer.class, webSSOProfileConsumer); serviceProviderBuilder.setSharedObject(WebSSOProfileConsumerHoKImpl.class, hokWebSSOProfileConsumer); serviceProviderBuilder.setSharedObject(SAMLLogger.class, samlLogger); serviceProviderBuilder.setSharedObject(ApplicationEventPublisher.class, eventPublisher); }
Example #11
Source File: HttpSOAPClient.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor. * * @param client Client used to make outbound HTTP requests. This client SHOULD employ a * {@link org.apache.commons.httpclient.MultiThreadedHttpConnectionManager} and may be shared with other * objects. * @param parser pool of XML parsers used to parse incoming responses */ public HttpSOAPClient(HttpClient client, ParserPool parser) { if (client == null) { throw new IllegalArgumentException("HtppClient may not be null"); } httpClient = client; if (parser == null) { throw new IllegalArgumentException("ParserPool may not be null"); } parserPool = parser; }
Example #12
Source File: BaseMessageDecoder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Sets the parser pool used to deserialize incomming messages. * * @param pool parser pool used to deserialize incomming messages */ protected void setParserPool(ParserPool pool) { if (pool == null) { throw new IllegalArgumentException("Parser pool may not be null"); } parserPool = pool; }
Example #13
Source File: BaseMessageDecoder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor. * * @param pool parser pool used to deserialize messages */ public BaseMessageDecoder(ParserPool pool) { if (pool == null) { throw new IllegalArgumentException("Parser pool may not be null"); } parserPool = pool; }
Example #14
Source File: SAMLManager.java From blackduck-alert with Apache License 2.0 | 5 votes |
public SAMLManager(ParserPool parserPool, ExtendedMetadata extendedMetadata, MetadataManager metadataManager, MetadataGenerator metadataGenerator, FilePersistenceUtil filePersistenceUtil, SAMLContext samlContext) { this.parserPool = parserPool; this.extendedMetadata = extendedMetadata; this.metadataManager = metadataManager; this.metadataGenerator = metadataGenerator; this.filePersistenceUtil = filePersistenceUtil; this.samlContext = samlContext; }
Example #15
Source File: SAMLProcessorConfigurer.java From spring-boot-security-saml with MIT License | 4 votes |
@Override public void init(ServiceProviderBuilder builder) throws Exception { sAMLProcessorBean = builder.getSharedObject(SAMLProcessor.class); processorConfig = builder.getSharedObject(SAMLSSOProperties.class).getSamlProcessor(); parserPool = builder.getSharedObject(ParserPool.class); }
Example #16
Source File: SAMLServiceProviderSecurityConfiguration.java From spring-boot-security-saml with MIT License | 4 votes |
@Bean(initMethod = "initialize") @ConditionalOnMissingBean public ParserPool parserPool() { return new StaticBasicParserPool(); }
Example #17
Source File: WebSecurityConfig.java From spring-boot-security-saml-sample with Apache License 2.0 | 4 votes |
@Bean public HTTPArtifactBinding artifactBinding(ParserPool parserPool, VelocityEngine velocityEngine) { return new HTTPArtifactBinding(parserPool, velocityEngine, artifactResolutionProfile()); }
Example #18
Source File: MetadataManagerConfigurer.java From spring-boot-security-saml with MIT License | 4 votes |
private MetadataProvider setParserPool(MetadataProvider provider) { if (provider instanceof AbstractMetadataProvider) { ((AbstractMetadataProvider) provider).setParserPool(getBuilder().getSharedObject(ParserPool.class)); } return provider; }
Example #19
Source File: WebSecurityConfig.java From spring-tsers-auth with Apache License 2.0 | 4 votes |
@Bean public HTTPArtifactBinding artifactBinding(ParserPool parserPool, VelocityEngine velocityEngine) { return new HTTPArtifactBinding(parserPool, velocityEngine, artifactResolutionProfile()); }
Example #20
Source File: OpenHTTPPostDecoder.java From MaxKey with Apache License 2.0 | 4 votes |
public OpenHTTPPostDecoder(ParserPool pool) { super(pool); }
Example #21
Source File: OpenHTTPPostSimpleSignDecoder.java From MaxKey with Apache License 2.0 | 4 votes |
public OpenHTTPPostSimpleSignDecoder(ParserPool pool) { super(pool); }
Example #22
Source File: OpenHTTPRedirectDecoder.java From MaxKey with Apache License 2.0 | 4 votes |
public OpenHTTPRedirectDecoder(ParserPool pool) { super(pool); }
Example #23
Source File: SAMLConfigurer.java From spring-security-saml-dsl with MIT License | 4 votes |
private HTTPPostBinding httpPostBinding(ParserPool parserPool) { return new HTTPPostBinding(parserPool, VelocityFactory.getEngine()); }
Example #24
Source File: SAMLConfigurer.java From spring-security-saml-dsl with MIT License | 4 votes |
private HTTPRedirectDeflateBinding httpRedirectDeflateBinding(ParserPool parserPool) { return new HTTPRedirectDeflateBinding(parserPool); }
Example #25
Source File: SAML2HTTPPostSimpleSignRule.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Constructor. * * @param engine the trust engine to use * @param parserPool the parser pool used to parse the KeyInfo request parameter * @param keyInfoCredResolver the KeyInfo credential resovler to use to extract credentials from the KeyInfo request * parameter */ public SAML2HTTPPostSimpleSignRule(SignatureTrustEngine engine, ParserPool parserPool, KeyInfoCredentialResolver keyInfoCredResolver) { super(engine); parser = parserPool; keyInfoResolver = keyInfoCredResolver; }
Example #26
Source File: BaseHandlerChainAwareMessageDecoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param pool parser pool used to deserialize messages */ public BaseHandlerChainAwareMessageDecoder(ParserPool pool) { super(pool); }
Example #27
Source File: BaseSAMLMessageDecoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param pool parser pool used to deserialize messages */ public BaseSAMLMessageDecoder(ParserPool pool) { super(pool); setURIComparator(new BasicURLComparator()); }
Example #28
Source File: BaseMessageDecoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Gets the parser pool used to deserialize incomming messages. * * @return parser pool used to deserialize incomming messages */ protected ParserPool getParserPool() { return parserPool; }
Example #29
Source File: HTTPSOAP11Decoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param pool parser pool used to deserialize messages */ public HTTPSOAP11Decoder(ParserPool pool) { super(pool); }
Example #30
Source File: SOAP11Decoder.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Constructor. * * @param pool parser pool used to deserialize messages */ public SOAP11Decoder(ParserPool pool) { super(pool); }