@Before public void setUp() throws Exception { binding = new SamlAssertionBinding(new BasicParserPool()); }
private XMLObject unmarshallObject(String xmlString) throws UnmarshallingException, XMLParserException, UnsupportedEncodingException { BasicParserPool parser = new BasicParserPool(); parser.setNamespaceAware(true); /* Base64URL encoded */ byte bytes[] = xmlString.getBytes("utf-8"); if (bytes == null || bytes.length == 0) throw new InsufficientAuthenticationException("Invalid assertion encoding"); Reader reader = new InputStreamReader(new ByteArrayInputStream(bytes)); Document doc = parser.parse(reader); Element samlElement = doc.getDocumentElement(); UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory(); Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(samlElement); if (unmarshaller == null) { throw new InsufficientAuthenticationException("Unsuccessful to unmarshal assertion string"); } return unmarshaller.unmarshall(samlElement); }
protected SAMLMessageDecoder samlMessageDecoder() { final BasicParserPool basicParserPool = new BasicParserPool(); basicParserPool.setMaxPoolSize(maxParserPoolSize); return new HTTPPostSimpleSignDecoder(basicParserPool); }
private StaticBasicParserPool staticBasicParserPool() { StaticBasicParserPool parserPool = new StaticBasicParserPool(); try { parserPool.initialize(); } catch (XMLParserException e) { e.printStackTrace(); } return parserPool; }
/** * Initialize the pool. * * @throws XMLParserException thrown if pool can not be initialized, * or if it is already initialized * **/ public synchronized void initialize() throws XMLParserException { if (initialized) { throw new XMLParserException("Parser pool was already initialized"); } initializeFactory(); initialized = true; }
/** {@inheritDoc} */ public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { return new LSInputImpl(publicId, systemId, resolver(publicId, systemId)); }
/** * Sets whether the builders ignore comments. * * @param ignore The ignoreComments to set. */ public void setIgnoreComments(boolean ignore) { checkValidModifyState(); ignoreComments = ignore; }
/** {@inheritDoc} */ public void setEntityResolver(EntityResolver er) { checkValidState(); return; }
/** {@inheritDoc} */ public void setEntityResolver(EntityResolver er) { checkValidState(); return; }
@Test public void testDoGetMetadata() throws Exception { String metadataString = new Scanner(new File("../uaa/src/main/resources/idp.xml")).useDelimiter("\\Z").next(); ConfigMetadataProvider provider = new ConfigMetadataProvider(IdentityZone.getUaa().getId(), "testalias", metadataString); ConfigMetadataProvider provider2 = new ConfigMetadataProvider(IdentityZone.getUaa().getId(), "testalias", metadataString); DefaultBootstrap.bootstrap(); provider.setParserPool(new BasicParserPool()); XMLObject xmlObject = provider.doGetMetadata(); assertNotNull(xmlObject); assertEquals("http://openam.example.com:8181/openam", ((EntityDescriptorImpl) xmlObject).getEntityID()); assertEquals(provider, provider2); } }
/** * Initialize the pool. * * @throws XMLParserException thrown if pool can not be initialized, * or if it is already initialized * **/ public synchronized void initialize() throws XMLParserException { if (initialized) { throw new XMLParserException("Parser pool was already initialized"); } initializeFactory(); initialized = true; }
/** {@inheritDoc} */ public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { return new LSInputImpl(publicId, systemId, resolver(publicId, systemId)); }
/** * Sets whether the builders are XInclude aware. * * @param isXIncludeAware whether the builders are XInclude aware */ public void setXincludeAware(boolean isXIncludeAware) { checkValidModifyState(); xincludeAware = isXIncludeAware; }
@Before public void setup() throws Exception { samlTestUtils.initialize(); configurator = new SamlServiceProviderConfigurator(); configurator.setParserPool(new BasicParserPool()); generator = samlTestUtils.mockIdpMetadataGenerator(); providerProvisioning = mock(SamlServiceProviderProvisioning.class); configurator.setProviderProvisioning(providerProvisioning); metadataManager = new NonSnarlIdpMetadataManager(configurator); metadataManager.setGenerator(generator); metadataManager.setKeyManager(new ZoneAwareKeyManager()); }
/** * Sets whether the builders ignore element content whitespace. * * @param ignore whether the builders ignore element content whitespace */ public void setIgnoreElementContentWhitespace(boolean ignore) { checkValidModifyState(); ignoreElementContentWhitespace = ignore; }
@Before public void setupSamlSpConfAndSlowHttpServer() throws Exception { samlTestUtils.initialize(); conf = new SamlServiceProviderConfigurator(); providerProvisioning = mock(SamlServiceProviderProvisioning.class); conf.setProviderProvisioning(providerProvisioning); conf.setParserPool(new BasicParserPool()); slowHttpServer = new SlowHttpServer(); TimeService mockTimeService = mock(TimeService.class); when(mockTimeService.getCurrentTimeMillis()).thenAnswer(e -> System.currentTimeMillis()); RestTemplateConfig restTemplateConfig = new RestTemplateConfig(); restTemplateConfig.timeout = 120; FixedHttpMetaDataProvider fixedHttpMetaDataProvider = new FixedHttpMetaDataProvider(); fixedHttpMetaDataProvider.setNonTrustingRestTemplate(restTemplateConfig.nonTrustingRestTemplate()); fixedHttpMetaDataProvider.setTrustingRestTemplate(restTemplateConfig.trustingRestTemplate()); fixedHttpMetaDataProvider.setCache(new ExpiringUrlCache(Duration.ofMinutes(10), mockTimeService, 2)); conf.setFixedHttpMetaDataProvider(fixedHttpMetaDataProvider); }
/** * Sets whether the builders are validating. * * @param isValidating whether the builders are validating */ public void setDTDValidating(boolean isValidating) { checkValidModifyState(); dtdValidating = isValidating; }
DefaultBootstrap.bootstrap(); HTTPRedirectDeflateDecoder decode = new HTTPRedirectDeflateDecoder(new BasicParserPool()); BasicSAMLMessageContext<LogoutRequest, ?, ?> messageContext = new BasicSAMLMessageContext<LogoutRequest, SAMLObject, SAMLObject>(); messageContext.setInboundMessageTransport(new HttpServletRequestAdapter(request)); decode.decode(messageContext); XMLObjectBuilderFactory builderFactory = org.opensaml.Configuration.getBuilderFactory(); LogoutRequestBuilder logoutRequestBuilder = (LogoutRequestBuilder) builderFactory.getBuilder(LogoutRequest.DEFAULT_ELEMENT_NAME); LogoutRequest logoutRequest = logoutRequestBuilder.buildObject(); logoutRequest = (LogoutRequest) messageContext.getInboundMessage();
@BeforeEach public void setUp() throws Exception { bootstrap = new BootstrapSamlIdentityProviderData(); configurator = new SamlIdentityProviderConfigurator(); configurator.setParserPool(new BasicParserPool()); singleAdd = new SamlIdentityProviderDefinition() .setMetaDataLocation(String.format(BootstrapSamlIdentityProviderDataTests.xmlWithoutID, new RandomValueStringGenerator().generate())) .setIdpEntityAlias(singleAddAlias) .setNameID("sample-nameID") .setAssertionConsumerIndex(1) .setMetadataTrustCheck(true) .setLinkText("sample-link-test") .setIconUrl("sample-icon-url") .setZoneId("uaa"); singleAddWithoutHeader = new SamlIdentityProviderDefinition() .setMetaDataLocation(String.format(xmlWithoutHeader, new RandomValueStringGenerator().generate())) .setIdpEntityAlias(singleAddAlias) .setNameID("sample-nameID") .setAssertionConsumerIndex(1) .setMetadataTrustCheck(true) .setLinkText("sample-link-test") .setIconUrl("sample-icon-url") .setZoneId("uaa"); configurator.setIdentityProviderProvisioning(provisioning); fixedHttpMetaDataProvider = mock(FixedHttpMetaDataProvider.class); configurator.setFixedHttpMetaDataProvider(fixedHttpMetaDataProvider); }
_idpMetaDataProvider.setParserPool(new BasicParserPool()); _idpMetaDataProvider.initialize(); _timer.scheduleAtFixedRate(new MetadataRefreshTask(), 0, _refreshInterval * 1000);