-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change ArtifactResponse extracting method #70
Conversation
@@ -353,6 +353,77 @@ private TestConstants() { | |||
|
|||
public static final String SAML_ART = "AAQAAM1OZiCJt3Va5A1W4dyuSepX9Q6clxUTA4vGKbi/bFCqu6Vm+NTZMDE="; | |||
|
|||
public static final String SAML_ART_RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is not used in the testcases. If so, shall we remove this?
|
||
public class SAMLSSOArtifactResolutionServiceTest { | ||
|
||
private static ArtifactResolve artifactResolve; | ||
private static ArtifactResponse artifactResponse; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need of these changes in this class.
return artifactResponse; | ||
ArtifactResponse artifactResponse = extractArtifactResponse(artifactResponseString); | ||
|
||
if (artifactResponse != null && isArtifactResponseValid(artifactResolve, artifactResponse)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Null check is already added inside isArtifactResponseValid() [1], no need to add it in here.
throws ArtifactResolutionException { | ||
|
||
ArtifactResponse artifactResponse = null; | ||
InputStream stream = new ByteArrayInputStream(artifactResponseString.getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially validate whether artifactResponseString is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation added before calling the method.
artifactResolve.getArtifact().getArtifact() + " Issuer: " + artifactResolve.getIssuer().getValue()); | ||
} | ||
ArtifactResponse artifactResponse = extractArtifactResponse(artifactResponseString); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unnecessary line.
ArtifactResponse artifactResponse = (ArtifactResponse) SSOUtils.unmarshall(artifactResponseReceived); | ||
if (isArtifactResponseValid(artifactResolve, artifactResponse)) { | ||
return artifactResponse; | ||
if (artifactResponseString == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any probability for this string to be empty
} else { | ||
throw new ArtifactResolutionException("Artifact Response is not valid."); | ||
throw new ArtifactResolutionException("Didn't receive valid artifact response."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So based on this if else block if the very first element is not an artifact response an error will be thown.
Is this the expectation. Can artifact response be nested ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the spec, the SOAP message should wrap the Artifact Response object. Following is an example given in the spec.
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<samlp:ArtifactResponse
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns="urn:oasis:names:tc:SAML:2.0:assertion"
ID="_FQvGknDfws2Z" Version="2.0"
InResponseTo="_6c3a4f8b9c2d"
IssueInstant="2004-01-21T19:00:49Z">
<Issuer>https://wso2is.com</Issuer>
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</samlp:Status>
<samlp:Response ID="d2b7c388cec36fa7c39c28fd298644a8"
IssueInstant="2004-01-21T19:00:49Z"
Version="2.0">
...
</samlp:Response>
</samlp:ArtifactResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Proposed changes in this pull request
Refers wso2/product-is#3401
Resolves wso2/product-is#3580
When should this PR be merged
ASAP
Follow up actions
Checklist (for reviewing)
General
Functionality
Code
Tests
Security
Documentation