Skip to content

Commit 8173169

Browse files
author
Han Chen
committed
allow load certificate by base 64
1 parent 559287f commit 8173169

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/main/java/com/onelogin/AccountSettings.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ public void setIdpSsoTargetUrl(String idp_sso_target_url) {
3131
* @param certificate an base64 encoded string.
3232
*/
3333
public void loadCertificate(String certificate) throws CertificateException {
34-
CertificateFactory fty = CertificateFactory.getInstance("X.509");
35-
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
36-
this.idp_cert = fty.generateCertificate(bais);
34+
loadCertificate(certificate, false);
3735
}
3836

39-
37+
public void loadCertificate(String certificate, boolean isBase64) throws CertificateException {
38+
CertificateFactory fty = CertificateFactory.getInstance("X.509");
39+
byte[] cert = certificate.getBytes();
40+
if (isBase64) {
41+
cert = Base64.decodeBase64(cert);
42+
}
43+
ByteArrayInputStream bais = new ByteArrayInputStream(cert);
44+
this.idp_cert = fty.generateCertificate(bais);
45+
}
46+
4047
public Certificate getIdpCert() throws CertificateException {
4148
if(this.idp_cert == null){
4249
loadCertificate(this.certificate);

0 commit comments

Comments
 (0)