Skip to content

Commit e132e52

Browse files
committed
Fix KeyStoreSettings : Change KeyStore password to KeyEntry Password
1 parent e25e39b commit e132e52

6 files changed

Lines changed: 23 additions & 21 deletions

File tree

core/src/main/java/com/onelogin/saml2/model/KeyStoreSettings.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public class KeyStoreSettings {
1919
private final String spAlias;
2020

2121
/**
22-
* Password for KeyStore
22+
* Password for KeyEntry in KeyStore
2323
*/
24-
private final String storePass;
24+
private final String spKeyPass;
2525

2626
/**
2727
* Constructor
@@ -32,13 +32,13 @@ public class KeyStoreSettings {
3232
* @param spAlias
3333
* Alias for SP key entry
3434
*
35-
* @param storePass
36-
* password to access KeyStore
35+
* @param spKeyPass
36+
* password to access Private KeyEntry in KeyStore
3737
*/
38-
public KeyStoreSettings(KeyStore keyStore, String spAlias, String storePass) {
38+
public KeyStoreSettings(KeyStore keyStore, String spAlias, String spKeyPass) {
3939
this.keyStore = keyStore;
4040
this.spAlias = spAlias;
41-
this.storePass = storePass;
41+
this.spKeyPass = spKeyPass;
4242
}
4343

4444
/**
@@ -56,10 +56,10 @@ public final String getSpAlias() {
5656
}
5757

5858
/**
59-
* @return the storePass
59+
* @return the spKeyPass
6060
*/
61-
public final String getStorePass() {
62-
return storePass;
61+
public final String getSpKeyPass() {
62+
return spKeyPass;
6363
}
6464

6565
}

core/src/main/java/com/onelogin/saml2/settings/SettingsBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class SettingsBuilder {
7070
// KeyStore
7171
public final static String KEYSTORE_KEY = "onelogin.saml2.keystore.store";
7272
public final static String KEYSTORE_ALIAS = "onelogin.saml2.keystore.alias";
73-
public final static String KEYSTORE_PASSWORD = "onelogin.saml2.keystore.password";
73+
public final static String KEYSTORE_KEY_PASSWORD = "onelogin.saml2.keystore.key.password";
7474

7575
// IDP
7676
public final static String IDP_ENTITYID_PROPERTY_KEY = "onelogin.saml2.idp.entityid";
@@ -471,15 +471,15 @@ private void loadSpSetting() {
471471
saml2Setting.setSpNameIDFormat(spNameIDFormat);
472472

473473
boolean keyStoreEnabled = this.samlData.get(KEYSTORE_KEY) != null && this.samlData.get(KEYSTORE_ALIAS) != null
474-
&& this.samlData.get(KEYSTORE_PASSWORD) != null;
474+
&& this.samlData.get(KEYSTORE_KEY_PASSWORD) != null;
475475

476476
X509Certificate spX509cert;
477477
PrivateKey spPrivateKey;
478478

479479
if (keyStoreEnabled) {
480480
KeyStore ks = (KeyStore) this.samlData.get(KEYSTORE_KEY);
481481
String alias = (String) this.samlData.get(KEYSTORE_ALIAS);
482-
String password = (String) this.samlData.get(KEYSTORE_PASSWORD);
482+
String password = (String) this.samlData.get(KEYSTORE_KEY_PASSWORD);
483483

484484
spX509cert = getCertificateFromKeyStore(ks, alias, password);
485485
spPrivateKey = getPrivateKeyFromKeyStore(ks, alias, password);
@@ -758,7 +758,7 @@ private void parseProperties(Properties properties) {
758758
private void parseKeyStore(KeyStoreSettings setting) {
759759
this.samlData.put(KEYSTORE_KEY, setting.getKeyStore());
760760
this.samlData.put(KEYSTORE_ALIAS, setting.getSpAlias());
761-
this.samlData.put(KEYSTORE_PASSWORD, setting.getStorePass());
761+
this.samlData.put(KEYSTORE_KEY_PASSWORD, setting.getSpKeyPass());
762762
}
763763

764764
/**

core/src/test/java/com/onelogin/saml2/test/settings/SettingBuilderTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,14 @@ public void testLoadFromFileNotExist() throws IOException, SettingsException, Er
7878
* @throws IOException
7979
*/
8080
private KeyStoreSettings getKeyStoreSettings() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
81-
String password = "changeit";
81+
String storePassword = "changeit";
8282
String keyStoreFile = "src/test/resources/keystore/oneloginTestKeystore.jks";
83-
String alias = "onelogintest";
83+
String alias = "keywithpassword";
84+
String keyPassword = "keypassword";
8485

8586
KeyStore ks = KeyStore.getInstance("JKS");
86-
ks.load(new FileInputStream(keyStoreFile), password.toCharArray());
87-
return new KeyStoreSettings(ks, alias, password);
87+
ks.load(new FileInputStream(keyStoreFile), storePassword.toCharArray());
88+
return new KeyStoreSettings(ks, alias, keyPassword);
8889
}
8990

9091
/**
-566 Bytes
Binary file not shown.

toolkit/src/test/java/com/onelogin/saml2/test/AuthTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ private String getSAMLRequestFromURL(String url) throws URISyntaxException, Unsu
9595
* @throws IOException
9696
*/
9797
private KeyStoreSettings getKeyStoreSettings() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, FileNotFoundException, IOException {
98-
String password = "changeit";
98+
String storePassword = "changeit";
9999
String keyStoreFile = "src/test/resources/keystore/oneloginTestKeystore.jks";
100-
String alias = "onelogintest";
100+
String alias = "keywithpassword";
101+
String keyPassword = "keypassword";
101102

102103
KeyStore ks = KeyStore.getInstance("JKS");
103-
ks.load(new FileInputStream(keyStoreFile), password.toCharArray());
104-
return new KeyStoreSettings(ks, alias, password);
104+
ks.load(new FileInputStream(keyStoreFile), storePassword.toCharArray());
105+
return new KeyStoreSettings(ks, alias, keyPassword);
105106
}
106107

107108
/**
-566 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)