Skip to content
Snippets Groups Projects
Commit f92b91dc authored by Michael Simon's avatar Michael Simon
Browse files

add logging for SAML Response status

parent 5fbf2b9c
No related branches found
No related tags found
No related merge requests found
...@@ -44,6 +44,7 @@ import org.slf4j.Logger; ...@@ -44,6 +44,7 @@ import org.slf4j.Logger;
import edu.kit.scc.webreg.entity.SamlMetadataEntity; import edu.kit.scc.webreg.entity.SamlMetadataEntity;
import edu.kit.scc.webreg.exc.SamlAuthenticationException; import edu.kit.scc.webreg.exc.SamlAuthenticationException;
import edu.kit.scc.webreg.service.saml.Saml2ResponseValidationService; import edu.kit.scc.webreg.service.saml.Saml2ResponseValidationService;
import edu.kit.scc.webreg.service.saml.SamlHelper;
public class Saml2ResponseValidationServiceImpl implements public class Saml2ResponseValidationServiceImpl implements
Saml2ResponseValidationService { Saml2ResponseValidationService {
...@@ -51,6 +52,9 @@ public class Saml2ResponseValidationServiceImpl implements ...@@ -51,6 +52,9 @@ public class Saml2ResponseValidationServiceImpl implements
@Inject @Inject
private Logger logger; private Logger logger;
@Inject
private SamlHelper samlHelper;
@Override @Override
public void verifyIssuer(SamlMetadataEntity metadataEntity, public void verifyIssuer(SamlMetadataEntity metadataEntity,
Response samlResponse) throws SamlAuthenticationException { Response samlResponse) throws SamlAuthenticationException {
...@@ -90,9 +94,15 @@ public class Saml2ResponseValidationServiceImpl implements ...@@ -90,9 +94,15 @@ public class Saml2ResponseValidationServiceImpl implements
public void verifyStatus(Response samlResponse) public void verifyStatus(Response samlResponse)
throws SamlAuthenticationException { throws SamlAuthenticationException {
if (samlResponse.getStatus() == null || samlResponse.getStatus().getStatusCode() == null)
throw new SamlAuthenticationException("SAML Response does not contain a status code");
Status status = samlResponse.getStatus(); Status status = samlResponse.getStatus();
if (! status.getStatusCode().getValue().equals(StatusCode.SUCCESS_URI)) if (! status.getStatusCode().getValue().equals(StatusCode.SUCCESS_URI)) {
String s = samlHelper.prettyPrint(status);
logger.info("SAML Response Status: {}", s);
throw new SamlAuthenticationException("SAML Response: Login was not successful " + status.getStatusCode().getValue()); throw new SamlAuthenticationException("SAML Response: Login was not successful " + status.getStatusCode().getValue());
}
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment