Skip to content

Commit e25e39b

Browse files
committed
Add KeyStore managment info on README. Add another Auth constructor with just a KeyStoreSetting
1 parent f185046 commit e25e39b

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,27 @@ onelogin.saml2.contacts.support.email_address = support@example.com
359359
# onelogin.saml2.unique_id_prefix = _
360360
```
361361

362+
##### KeyStores
363+
364+
The Auth constructor supports the ability to read SP public cert/private key from a KeyStore. A KeyStoreSettings object must be provided with the KeyStore, the Alias and the storePass if any.
365+
366+
```java
367+
import java.io.FileInputStream;
368+
import java.security.KeyStore;
369+
import com.onelogin.saml2.Auth
370+
import com.onelogin.saml2.model.KeyStoreSettings
371+
372+
String keyStoreFile = "oneloginTestKeystore.jks";
373+
String alias = "onelogintest";
374+
String storePass = "changeit";
375+
376+
KeyStore ks = KeyStore.getInstance("JKS");
377+
ks.load(new FileInputStream(keyStoreFile), password.toCharArray());
378+
379+
KeyStoreSettings keyStoreSettings = new keyStoreSettings(ks, alias, storePass);
380+
Auth auth = new Auth(KeyStoreSettings keyStoreSetting);
381+
```
382+
362383
##### Dynamic Settings
363384
It is possible to build settings programmatically. You can load your values from different sources such as files, databases, or generated values.
364385

toolkit/src/main/java/com/onelogin/saml2/Auth.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,19 @@ public Auth() throws IOException, SettingsException, Error {
162162
this(new SettingsBuilder().fromFile("onelogin.saml.properties").build(), null, null);
163163
}
164164

165+
/**
166+
* Initializes the SP SAML instance.
167+
*
168+
* @param keyStoreSetting KeyStoreSettings is a KeyStore which have the Private/Public keys
169+
*
170+
* @throws IOException
171+
* @throws SettingsException
172+
* @throws Error
173+
*/
174+
public Auth(KeyStoreSettings keyStoreSetting) throws IOException, SettingsException, Error {
175+
this("onelogin.saml.properties", keyStoreSetting);
176+
}
177+
165178
/**
166179
* Initializes the SP SAML instance.
167180
*

0 commit comments

Comments
 (0)