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 35e0f54
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ private AuthServiceResponse processCommonAuthResponse(AuthServiceRequestWrapper

if (isAuthFlowSuccessful(request)) {
handleSuccessAuthResponse(request, response, authServiceResponse);
} else if (isAuthFlowFailed(request, response)) {
handleFailedAuthResponse(request, response, authServiceResponse);
} else if (isAuthFlowIncomplete(request)) {
handleIntermediateAuthResponse(request, response, authServiceResponse);
} else if (isAuthFlowFailed(request, response)) {
handleFailedAuthResponse(request, response, authServiceResponse);
} else {
throw new AuthServiceException("Unknown authentication flow status: " + request.getAuthFlowStatus());
}
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 35e0f54

Please sign in to comment.