diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/AuthenticationService.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/AuthenticationService.java index 248dbbf4f5a3..a2f11bdc3565 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/AuthenticationService.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/AuthenticationService.java @@ -91,6 +91,8 @@ private AuthServiceResponse processCommonAuthResponse(AuthServiceRequestWrapper AuthServiceResponse authServiceResponse = new AuthServiceResponse(); + /* This order of flow checking should be maintained as some of the + error flows could come with flow status INCOMPLETE.*/ if (isAuthFlowSuccessful(request)) { handleSuccessAuthResponse(request, response, authServiceResponse); } else if (isAuthFlowFailed(request, response)) { diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java index 5ac1aab6471e..e9122d3de5ca 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/FrameworkUtils.java @@ -211,7 +211,7 @@ public class FrameworkUtils { .asList(FrameworkConstants.RequestType.CLAIM_TYPE_SAML_SSO, FrameworkConstants.OAUTH2); public static final String QUERY_SEPARATOR = "&"; - private static final String EQUAL = "="; + public static final String EQUAL = "="; public static final String REQUEST_PARAM_APPLICATION = "application"; private static final String ALREADY_WRITTEN_PROPERTY = "AlreadyWritten"; diff --git a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/auth/service/AuthServiceUtils.java b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/auth/service/AuthServiceUtils.java index 6d3ed19dc870..4b53281df34a 100644 --- a/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/auth/service/AuthServiceUtils.java +++ b/components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/util/auth/service/AuthServiceUtils.java @@ -18,7 +18,9 @@ package org.wso2.carbon.identity.application.authentication.framework.util.auth.service; +import org.apache.commons.lang.StringUtils; import org.wso2.carbon.identity.application.authentication.framework.exception.auth.service.AuthServiceException; +import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -47,11 +49,13 @@ public static Map extractQueryParams(String url) throws AuthServ try { URI uri = new URI(url); String query = uri.getQuery(); - String[] pairs = query.split("&"); - for (String pair : pairs) { - int idx = pair.indexOf("="); - queryParams.put(URLDecoder.decode(pair.substring(0, idx), UTF_8), - URLDecoder.decode(pair.substring(idx + 1), UTF_8)); + if (StringUtils.isNotBlank(query)) { + String[] pairs = query.split(FrameworkUtils.QUERY_SEPARATOR); + for (String pair : pairs) { + int idx = pair.indexOf(FrameworkUtils.EQUAL); + queryParams.put(URLDecoder.decode(pair.substring(0, idx), UTF_8), + URLDecoder.decode(pair.substring(idx + 1), UTF_8)); + } } } catch (URISyntaxException | UnsupportedEncodingException e) { throw new AuthServiceException("Error while extracting query params from provided url.", e);