Skip to content

Commit

Permalink
Fix possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
janakamarasena committed Oct 26, 2023
1 parent 58e8afc commit 4834b37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,11 +49,13 @@ public static Map<String, String> 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);
Expand Down

0 comments on commit 4834b37

Please sign in to comment.