125
125
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .LogConstants .ActionIDs .INITIATE_OUTBOUND_AUTH_REQUEST ;
126
126
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .LogConstants .ActionIDs .PROCESS_AUTHENTICATION_RESPONSE ;
127
127
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .LogConstants .OUTBOUND_AUTH_OIDC_SERVICE ;
128
+ import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .MULTI_OPTION_URI ;
128
129
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .OIDC_FEDERATION_NONCE ;
130
+ import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .QUERY_PARAM_KEY_VALUE_DELIMITER ;
129
131
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .REDIRECT_URL_SUFFIX ;
130
132
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .SCOPE_PARAM_SUFFIX ;
131
133
import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .STATE_PARAM_SUFFIX ;
134
+ import static org .wso2 .carbon .identity .application .authenticator .oidc .OIDCAuthenticatorConstants .URI_QUERY_PARAM_DELIMITER ;
132
135
import static org .wso2 .carbon .identity .base .IdentityConstants .FEDERATED_IDP_SESSION_ID ;
133
136
134
137
/**
@@ -2033,10 +2036,10 @@ private String interpretQueryString(AuthenticationContext context, String queryS
2033
2036
Matcher matcher = pattern .matcher (queryString );
2034
2037
while (matcher .find ()) {
2035
2038
String name = matcher .group (1 );
2036
- String [] values = parameters . get ( name );
2037
- String value = "" ;
2038
- if ( values != null && values . length > 0 ) {
2039
- value = values [ 0 ] ;
2039
+ String value = getParameterFromParamMap ( parameters , name );
2040
+ if ( StringUtils . isBlank ( value )) {
2041
+ String multiOptionURI = getParameterFromParamMap ( parameters , MULTI_OPTION_URI );
2042
+ value = getParameterFromURIString ( multiOptionURI , name ) ;
2040
2043
}
2041
2044
if (LOG .isDebugEnabled ()) {
2042
2045
LOG .debug ("InterpretQueryString name: " + name + ", value: " + value );
@@ -2049,6 +2052,48 @@ private String interpretQueryString(AuthenticationContext context, String queryS
2049
2052
return queryString ;
2050
2053
}
2051
2054
2055
+ /**
2056
+ * Gets the value of the parameter corresponding to the given parameter
2057
+ * name from the request's parameter map.
2058
+ *
2059
+ * @param parameters The parameter map of the request.
2060
+ * @param parameterName The name of the parameter to be retrieved.
2061
+ * @return The value of the parameter if it is present in the parameter map.
2062
+ * If it is not present, an empty String is returned instead.
2063
+ */
2064
+ private String getParameterFromParamMap (Map <String , String []> parameters , String parameterName ) {
2065
+
2066
+ String [] parameterValueMap = parameters .get (parameterName );
2067
+ if (parameterValueMap != null && parameterValueMap .length > 0 ) {
2068
+ return parameterValueMap [0 ];
2069
+ }
2070
+ return StringUtils .EMPTY ;
2071
+ }
2072
+
2073
+ /**
2074
+ * Parses the given URI String to get the parameter value corresponding to the
2075
+ * given parameter name.
2076
+ *
2077
+ * @param uriString The URI String to be parsed.
2078
+ * @param parameterName The name of the parameter to be retrieved.
2079
+ * @return The value of the parameter if it is present in the URI String.
2080
+ * If it is not present, an empty String is returned instead.
2081
+ */
2082
+ private String getParameterFromURIString (String uriString , String parameterName ) {
2083
+
2084
+ if (StringUtils .isNotBlank (uriString )) {
2085
+ String [] queryParams = uriString .split (URI_QUERY_PARAM_DELIMITER , -1 );
2086
+ for (String queryParam : queryParams ) {
2087
+ String [] queryParamComponents = queryParam .split (QUERY_PARAM_KEY_VALUE_DELIMITER );
2088
+ if (queryParamComponents .length == 2 && queryParamComponents [0 ].equalsIgnoreCase (parameterName )) {
2089
+ return queryParamComponents [1 ];
2090
+ }
2091
+ }
2092
+ }
2093
+ return StringUtils .EMPTY ;
2094
+ }
2095
+
2096
+
2052
2097
/**
2053
2098
* Evaluate the query string for additional query params with actual key and value.
2054
2099
*
0 commit comments