[java-identity-provider] 02/02: IDP-2069 Null handling

Rod Widdowson rdw at steadingsoftware.com
Thu Mar 2 11:04:10 UTC 2023


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=52479beb34463ae072f7fb6f5df34cf29887d668

commit 52479beb34463ae072f7fb6f5df34cf29887d668
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Mar 1 19:51:49 2023 +0000

    IDP-2069 Null handling
    
    https://shibboleth.atlassian.net/browse/IDP-2069
    
    Fix return issues
---
 .../saml2/profile/impl/ContinueSAMLAuthentication.java   | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ContinueSAMLAuthentication.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ContinueSAMLAuthentication.java
index 24be85811..08954e636 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ContinueSAMLAuthentication.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ContinueSAMLAuthentication.java
@@ -88,25 +88,33 @@ public class ContinueSAMLAuthentication extends AbstractAuthenticationAction {
             log.info("{} SAML authentication attempt signaled an error: {}", getLogPrefix(),
                     authnError);
             ActionSupport.buildEvent(profileRequestContext, authnError);
-        } else if (imc == null) {
+            return;
+        } 
+        if (imc == null) {
             log.info("{} No inbound SAML Response found", getLogPrefix());
             ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_CREDENTIALS);
-        } else if (!(imc.getMessage() instanceof Response)) {
+            return;
+        } 
+        final Response response = (Response) imc.getMessage();
+        if (response == null || !(response instanceof Response)) {
             log.info("{} Inbound message was not a SAML Response", getLogPrefix());
             ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
+            return;
         }
         
-        final Response response = (Response) imc.getMessage();
         final Status status = response.getStatus() ;
         final StatusCode statusCode = status == null ? null : status.getStatusCode(); 
         if (status == null || statusCode == null || statusCode.getValue() == null) {
             log.info("{} SAML response did not contain a StatusCode", getLogPrefix());
             authenticationContext.removeSubcontext(SAMLAuthnContext.class);
             ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
-        } else if (!StatusCode.SUCCESS.equals(statusCode.getValue())) {
+            return;
+        }
+        if (!StatusCode.SUCCESS.equals(statusCode.getValue())) {
             log.info("{} SAML response contained error status: {}", getLogPrefix(), statusCode.getValue());
             authenticationContext.removeSubcontext(SAMLAuthnContext.class);
             ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
+            return;
         }
     }
     

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list