Skip to content

Commit 5d37bd1

Browse files
committed
Some pr comments applied.
1 parent faf55e5 commit 5d37bd1

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class AccountSettings {
1212
private String certificate;
13-
private Certificate cert;
13+
private Certificate idp_cert;
1414
private String idp_sso_target_url;
1515

1616
public String getCertificate() {
@@ -30,18 +30,18 @@ public void setIdpSsoTargetUrl(String idp_sso_target_url) {
3030
* Loads certificate from a base64 encoded string
3131
* @param certificate an base64 encoded string.
3232
*/
33-
public void loadCertificate() throws CertificateException {
33+
public void loadCertificate(String certificate) throws CertificateException {
3434
CertificateFactory fty = CertificateFactory.getInstance("X.509");
3535
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
36-
cert = fty.generateCertificate(bais);
36+
this.idp_cert = fty.generateCertificate(bais);
3737
}
3838

3939

40-
public Certificate getCert() throws CertificateException {
41-
if(cert == null){
42-
loadCertificate();
40+
public Certificate getIdpCert() throws CertificateException {
41+
if(this.idp_cert == null){
42+
loadCertificate(this.certificate);
4343
}
44-
return cert;
44+
return this.idp_cert;
4545
}
4646

4747
/**
@@ -52,7 +52,7 @@ public Certificate getCert() throws CertificateException {
5252
public Certificate getCert(byte[] certificate) throws CertificateException {
5353
CertificateFactory fty = CertificateFactory.getInstance("X.509");
5454
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate));
55-
cert = fty.generateCertificate(bais);
56-
return cert;
55+
idp_cert = fty.generateCertificate(bais);
56+
return idp_cert;
5757
}
5858
}

src/main/java/com/onelogin/saml/Response.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Response(AccountSettings accountSettings) throws CertificateException {
4949
}
5050

5151
public Response(AccountSettings accountSettings, String response) throws Exception {
52-
this(accountSettings);
52+
this(accountSettings);
5353
loadXmlFromBase64(response);
5454
}
5555

@@ -59,7 +59,7 @@ public void loadXmlFromBase64(String responseStr) throws Exception {
5959
this.response = new String(decodedB);
6060
this.document = Utils.loadXML(this.response);
6161
if(this.document == null){
62-
62+
throw new Exception("SAML Response could not be processed");
6363
}
6464
}
6565

@@ -200,7 +200,7 @@ public boolean isValid(String... requestId){
200200
if(signedElements.isEmpty()){
201201
throw new Exception("No Signature found. SAML Response rejected");
202202
}else{
203-
Certificate cert = this.accountSettings.getCert();
203+
Certificate cert = this.accountSettings.getIdpCert();
204204

205205
// Only validates the first signed element
206206
if (!Utils.validateSign(signNodes.item(0), cert)) {

0 commit comments

Comments
 (0)