@BeforeClass public static void initVM() throws Exception { Security.addProvider(new BouncyCastleProvider()); DefaultBootstrap.bootstrap(); }
public static synchronized void bootstrap() throws ConfigurationException { DefaultBootstrap.bootstrap(); DefaultBootstrap.initializeXMLTooling(paosXmlToolingConfig); }
/** * Initializes the OpenSAML library, loading default configurations. * * @throws ConfigurationException thrown if there is a problem initializing the OpenSAML library */ public static synchronized void bootstrap() throws ConfigurationException { initializeXMLSecurity(); initializeXMLTooling(); initializeArtifactBuilderFactories(); initializeGlobalSecurityConfiguration(); initializeParserPool(); initializeESAPI(); initializeHttpClient(); }
/** * Initializes the XMLTooling library with a default set of object providers. * * @throws ConfigurationException thrown if there is a problem loading the configuration files */ protected static void initializeXMLTooling() throws ConfigurationException { initializeXMLTooling(xmlToolingConfigs); }
/** * Initializes the OWASPI ESAPI library. */ protected static void initializeESAPI() { Logger log = getLogger(); String systemPropertyKey = "org.owasp.esapi.SecurityConfiguration"; String opensamlConfigImpl = ESAPISecurityConfig.class.getName(); String currentValue = System.getProperty(systemPropertyKey); if (currentValue == null || currentValue.isEmpty()) { log.debug("Setting ESAPI SecurityConfiguration impl to OpenSAML internal class: {}", opensamlConfigImpl); System.setProperty(systemPropertyKey, opensamlConfigImpl); // We still need to call ESAPI.initialize() despite setting the system property, b/c within the ESAPI class // the property is only evaluated once in a static initializer and stored. The initialize method however // does overwrite the statically-set value from the system property. But still set the system property for // consistency, so other callers can see what has been set. ESAPI.initialize(opensamlConfigImpl); } else { log.debug("ESAPI SecurityConfiguration impl was already set non-null and non-empty via system property, leaving existing value in place: {}", currentValue); } }
/** * Initializes the Apache XMLSecurity libary. * * @throws ConfigurationException thrown is there is a problem initializing the library */ protected static void initializeXMLSecurity() throws ConfigurationException { Logger log = getLogger(); String lineBreakPropName = "org.apache.xml.security.ignoreLineBreaks"; // Don't override if it was set explicitly if (System.getProperty(lineBreakPropName) == null) { System.setProperty(lineBreakPropName, "true"); } if (!Init.isInitialized()) { log.debug("Initializing Apache XMLSecurity library"); Init.init(); } }
@BeforeAll public static void initializeOpenSAML() throws Exception { if (!org.apache.xml.security.Init.isInitialized()) { DefaultBootstrap.bootstrap(); } }
/** * Initializes the XMLTooling library with an explicitly supplied set of object providers. * * @param providerConfigs list of provider configuration files located on the classpath * * @throws ConfigurationException thrown if there is a problem loading the configuration files */ protected static void initializeXMLTooling(String[] providerConfigs) throws ConfigurationException { Logger log = getLogger(); Class clazz = Configuration.class; XMLConfigurator configurator = new XMLConfigurator(); for (String config : providerConfigs) { log.debug("Loading XMLTooling configuration {}", config); configurator.load(clazz.getResourceAsStream(config)); } }
@BeforeClass public static void bootstrap() throws Exception { Security.addProvider(new BouncyCastleProvider()); DefaultBootstrap.bootstrap(); NamedKeyInfoGeneratorManager keyInfoGeneratorManager = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager(); keyInfoGeneratorManager.getManager(SAML_METADATA_KEY_INFO_GENERATOR); }
/** * Initializes the artifact factories for SAML 1 and SAML 2 artifacts. * * @throws ConfigurationException thrown if there is a problem initializing the artifact factory */ protected static void initializeArtifactBuilderFactories() throws ConfigurationException { Logger log = getLogger(); log.debug("Initializing SAML Artifact builder factories"); Configuration.setSAML1ArtifactBuilderFactory(new SAML1ArtifactBuilderFactory()); Configuration.setSAML2ArtifactBuilderFactory(new SAML2ArtifactBuilderFactory()); }
@BeforeClass public static void bootstrap() throws Exception { Security.addProvider(new BouncyCastleProvider()); DefaultBootstrap.bootstrap(); NamedKeyInfoGeneratorManager keyInfoGeneratorManager = Configuration.getGlobalSecurityConfiguration().getKeyInfoGeneratorManager(); keyInfoGeneratorManager.getManager(SAMLConstants.SAML_METADATA_KEY_INFO_GENERATOR); }
@Before public void setup() { try { DefaultBootstrap.bootstrap(); } catch (ConfigurationException e) { } tokenServices = mock(AuthorizationServerTokenServices.class);
@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); } }
public Response processSAMLResponse(String responseMessage) { Response responseObject = null; try { DefaultBootstrap.bootstrap(); responseObject = SAMLUtils.decodeSAMLResponse(responseMessage); } catch (ConfigurationException | FactoryConfigurationError | ParserConfigurationException | SAXException | IOException | UnmarshallingException e) { s_logger.error("SAMLResponse processing error: " + e.getMessage()); } return responseObject; }
public void initialize() throws ConfigurationException { IdentityZone.getUaa().getConfig().getSamlConfig().setPrivateKey(PROVIDER_PRIVATE_KEY); IdentityZone.getUaa().getConfig().getSamlConfig().setPrivateKeyPassword(PROVIDER_PRIVATE_KEY_PASSWORD); IdentityZone.getUaa().getConfig().getSamlConfig().setCertificate(PROVIDER_CERTIFICATE); AddBcProvider.noop(); DefaultBootstrap.bootstrap(); initializeSimple(); }
public OpenSAMLContext(Properties properties, Provisioner provisioner) { // Bootstrap openSAML try { DefaultBootstrap.bootstrap(); } catch (ConfigurationException e) { throw new RuntimeException(e); } replayCacheDuration = Long.parseLong(properties.getProperty("replayCacheDuration", "14400000")); maxParserPoolSize = Integer.parseInt(properties.getProperty("maxParserPoolSize", "2")); entityId = properties.getProperty("entityId", "no-property-named-entityId"); clockSkew = Integer.parseInt(properties.getProperty("clockSkew", "90")); newExpires = Integer.parseInt(properties.getProperty("newExpires", "300")); assertionConsumerURI = properties.getProperty("assertionConsumerURI", DEFAULT_ASSERTION_CONSUMER_URI); idpEntityId = properties.getProperty("idpEntityId", "no-property-named-idpEntityId"); idpCertificate = properties.getProperty("idpCertificate", "no-property-named-idpCertificate"); idpUrl = properties.getProperty("idpUrl", "no-property-named-idpUrl"); spPrivateKey = properties.getProperty("spPrivateKey", "no-property-named-spPrivateKey"); spCertificate = properties.getProperty("spCertificate", "no-property-named-spCertificate"); this.provisioner = provisioner; samlMessageHandler = new SAMLMessageHandlerImpl(samlMessageDecoder(), securityPolicyResolver()); samlMessageHandler.setEntityId(entityId); samlMessageHandler.setVelocityEngine(velocityEngine()); samlMessageHandler.setNeedsSigning(true); validatorSuite = new SAML2ValidatorSuite(); }
DefaultBootstrap.bootstrap(); if (idpMetaDataUrl.startsWith("http")) { _idpMetaDataProvider = new HTTPMetadataProvider(_timer, client, idpMetaDataUrl);
public static String buildAuthnRequestUrl(final String authnId, final SAMLProviderMetadata spMetadata, final SAMLProviderMetadata idpMetadata, final String signatureAlgorithm) { String redirectUrl = ""; try { DefaultBootstrap.bootstrap(); AuthnRequest authnRequest = SAMLUtils.buildAuthnRequestObject(authnId, spMetadata.getEntityId(), idpMetadata.getSsoUrl(), spMetadata.getSsoUrl()); PrivateKey privateKey = null; if (spMetadata.getKeyPair() != null) { privateKey = spMetadata.getKeyPair().getPrivate(); } redirectUrl = idpMetadata.getSsoUrl() + "?" + SAMLUtils.generateSAMLRequestSignature("SAMLRequest=" + SAMLUtils.encodeSAMLRequest(authnRequest), privateKey, signatureAlgorithm); } catch (ConfigurationException | FactoryConfigurationError | MarshallingException | IOException | NoSuchAlgorithmException | InvalidKeyException | java.security.SignatureException e) { s_logger.error("SAML AuthnRequest message building error: " + e.getMessage()); } return redirectUrl; }
DefaultBootstrap.bootstrap(); } catch (ConfigurationException | FactoryConfigurationError e) { s_logger.error("OpenSAML Bootstrapping error: " + e.getMessage());
public static void doBootstrap() { if (!isBootStrapped) { try { DefaultBootstrap.bootstrap(); isBootStrapped = true; } catch (ConfigurationException e) { log.error("Error in bootstrapping the OpenSAML2 library", e); } } }