org.springframework.security.ldap.server.ApacheDSContainer Java Examples

The following examples show how to use org.springframework.security.ldap.server.ApacheDSContainer. 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: LdapAuthenticationProviderConfigurer.java    From gravitee-management-rest-api with Apache License 2.0 6 votes vote down vote up
private DefaultSpringSecurityContextSource build() throws Exception {
    DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
            getProviderUrl());
    if (managerDn != null) {
        contextSource.setUserDn(managerDn);
        if (managerPassword == null) {
            throw new IllegalStateException(
                    "managerPassword is required if managerDn is supplied");
        }
        contextSource.setPassword(managerPassword);
    }
    contextSource = postProcess(contextSource);
    if (url != null) {
        return contextSource;
    }
    ApacheDSContainer apacheDsContainer = new ApacheDSContainer(root, ldif);
    apacheDsContainer.setPort(getPort());
    postProcess(apacheDsContainer);
    return contextSource;
}
 
Example #2
Source File: LdapContextSourceFactory.java    From gravitee-management-rest-api with Apache License 2.0 6 votes vote down vote up
private DefaultSpringSecurityContextSource build() throws Exception {
            DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
                    getProviderUrl());
            if (managerDn != null) {
                contextSource.setUserDn(managerDn);
                if (managerPassword == null) {
                    throw new IllegalStateException(
                            "managerPassword is required if managerDn is supplied");
                }
                contextSource.setPassword(managerPassword);
            }
//            contextSource = postProcess(contextSource);
            if (url != null) {
                return contextSource;
            }
            ApacheDSContainer embeddedApacheContainer = new ApacheDSContainer(root, ldif);
            embeddedApacheContainer.setPort(getPort());
            apacheDsContainer = embeddedApacheContainer;
//            postProcess(apacheDsContainer);
            return contextSource;
        }
 
Example #3
Source File: LdapServerResource.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Override
protected void before() throws Throwable {

	originalLdapPort = System.getProperty(LDAP_PORT_PROPERTY);

	temporaryFolder.create();
	apacheDSContainer = new ApacheDSContainer("dc=springframework,dc=org",
			"classpath:org/springframework/cloud/dataflow/server/local/security/" + this.ldapFileName);
	int ldapPort = SocketUtils.findAvailableTcpPort();
	if (enabledSsl) {

		apacheDSContainer.setLdapOverSslEnabled(true);

		final File temporaryKeyStoreFile = new File(temporaryFolder.getRoot(), "dataflow.keystore");
		final File temporaryTrustStoreFile = new File(temporaryFolder.getRoot(), "dataflow.truststore");

		FileCopyUtils.copy(keyStoreResource.getInputStream(), new FileOutputStream(temporaryKeyStoreFile));
		FileCopyUtils.copy(trustStoreResource.getInputStream(), new FileOutputStream(temporaryTrustStoreFile));

		Assert.isTrue(temporaryKeyStoreFile.isFile(), "temporaryKeyStoreFile.isFile can not be null");
		Assert.isTrue(temporaryTrustStoreFile.isFile(), "temporaryTrustStoreFile.isfile can not be null");

		apacheDSContainer.setKeyStoreFile(temporaryKeyStoreFile);
		apacheDSContainer.setCertificatePassord(KEY_STORE_PASSWORD);

		System.setProperty("javax.net.ssl.trustStorePassword", TRUST_STORE_PASSWORD);
		System.setProperty("javax.net.ssl.trustStore", temporaryTrustStoreFile.getAbsolutePath());
		System.setProperty("javax.net.ssl.trustStoreType", "jks");
	}

	apacheDSContainer.setPort(ldapPort);
	apacheDSContainer.afterPropertiesSet();
	workingDir = new File(temporaryFolder.getRoot(), UUID.randomUUID().toString());
	apacheDSContainer.setWorkingDirectory(workingDir);
	apacheDSContainer.start();
	System.setProperty(LDAP_PORT_PROPERTY, Integer.toString(ldapPort));
}