Skip to content

Commit

Permalink
allow empty ldap keystore path
Browse files Browse the repository at this point in the history
  • Loading branch information
inancdokurel committed Apr 11, 2023
1 parent 6f714a2 commit 46da8e3
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/main/java/net/researchgate/azkaban/LdapUserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,38 @@ public LdapUserManager(Props props) {
ldapEmbeddedGroups = props.getBoolean(LDAP_EMBEDDED_GROUPS, false);
String ldapKeystorePath = props.getString(LDAP_KEYSTORE);
String ldapKeystorePassword = props.getString(LDAP_KEYSTORE_PASSWORD);
if((startTLS || useSsl) && ldapKeystorePath == null){
throw new IllegalArgumentException("startTLS or useSsl require keystorepath");
}
if (ldapKeystorePath != null) {
try {
ldapKeystore = KeyStore.getInstance(KeyStore.getDefaultType());
if (ldapKeystorePassword!=null){
ldapKeystore.load(new FileInputStream(ldapKeystorePath), ldapKeystorePassword.toCharArray());
}else {
ldapKeystore.load(new FileInputStream(ldapKeystorePath),null);
}
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ldapKeystore);

for (TrustManager tm : tmf.getTrustManagers()) {
if (tm instanceof X509TrustManager) {
keystoreTrustManager = (X509TrustManager) tm;
break;
if(startTLS || useSsl){
if(ldapKeystorePath == null){
throw new IllegalArgumentException("startTLS or useSsl require keystorepath");
}
if (ldapKeystorePath != null) {
try {
ldapKeystore = KeyStore.getInstance(KeyStore.getDefaultType());
if (ldapKeystorePassword!=null){
ldapKeystore.load(new FileInputStream(ldapKeystorePath), ldapKeystorePassword.toCharArray());
}else {
ldapKeystore.load(new FileInputStream(ldapKeystorePath),null);
}
TrustManagerFactory tmf = TrustManagerFactory
.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ldapKeystore);

for (TrustManager tm : tmf.getTrustManagers()) {
if (tm instanceof X509TrustManager) {
keystoreTrustManager = (X509TrustManager) tm;
break;
}
}
if(keystoreTrustManager==null){
throw new IllegalStateException("keystoreTrustManager could not be initialized");
}
}
if(keystoreTrustManager==null){
throw new IllegalStateException("keystoreTrustManager could not be initialized");
}

} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException e) {
logger.error("could not load keystore",e);
} catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException e) {
logger.error("could not load keystore",e);
}
}
}

// Support local salt account for admin privileges
localSaltAccount = props.getString(LOCAL_SALT_ACCOUNT).trim();
localSaltPassword = props.getString(LOCAL_SALT_PASSWORD);
Expand Down

0 comments on commit 46da8e3

Please sign in to comment.