Skip to content

Commit fcfdb34

Browse files
author
Han Chen
committed
error msg change and getAttribute() change
1 parent 65ce16e commit fcfdb34

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void loadXmlFromBase64(String responseStr) throws Exception {
7676
this.response = new String(decodedB);
7777
this.document = Utils.loadXML(this.response);
7878
if(this.document == null){
79-
throw new Exception("SAML Response could not be processed");
79+
throw new Exception("SAML Response could not be processed, invalid or empty SAML");
8080
}
8181
}
8282

@@ -253,8 +253,10 @@ public String getNameId() throws Exception {
253253

254254
public String getAttribute(String name) {
255255
HashMap<String, ArrayList<String>> attributes = getAttributes();
256+
256257
if (!attributes.isEmpty()) {
257-
return attributes.get(name).toString();
258+
ArrayList<String> attrVal = attributes.get(name);
259+
return attrVal == null || attrVal.size() == 0 ? null : attrVal.get(0).toString();
258260
}
259261
return null;
260262
}

0 commit comments

Comments
 (0)