@Test void testRedirectAttemptParamsInMiddleCustomName() { String state = "http: String newState = oidcSupportCustomParam.increaseRedirectCounter(state); assertThat(state, not(newState)); assertThat(newState, endsWith(PARAM_NAME + "=12&b=second")); }
String increaseRedirectCounter(String state) { if (state.contains("?")) { Pattern attemptPattern = Pattern.compile(".*?(" + oidcConfig.redirectAttemptParam() + "=\\d+).*"); Matcher matcher = attemptPattern.matcher(state); if (matcher.matches()) { String attempts = matcher.group(1); int equals = attempts.lastIndexOf('='); String count = attempts.substring(equals + 1); int countNumber = Integer.parseInt(count); countNumber++; return state.replace(attempts, oidcConfig.redirectAttemptParam() + "=" + countNumber); } else { return state + "&" + oidcConfig.redirectAttemptParam() + "=1"; } } else { return state + "?" + oidcConfig.redirectAttemptParam() + "=1"; } }
OidcSupport implements Service { String increaseRedirectCounter(String state) { if (state.contains("?")) { Pattern attemptPattern = Pattern.compile(".*?(" + oidcConfig.redirectAttemptParam() + "=\\d+).*"); Matcher matcher = attemptPattern.matcher(state); if (matcher.matches()) { String attempts = matcher.group(1); int equals = attempts.lastIndexOf('='); String count = attempts.substring(equals + 1); int countNumber = Integer.parseInt(count); countNumber++; return state.replace(attempts, oidcConfig.redirectAttemptParam() + "=" + countNumber); } else { return state + "&" + oidcConfig.redirectAttemptParam() + "=1"; } } else { return state + "?" + oidcConfig.redirectAttemptParam() + "=1"; } } }
OidcSupport implements Service { String increaseRedirectCounter(String state) { if (state.contains("?")) { Pattern attemptPattern = Pattern.compile(".*?(" + oidcConfig.redirectAttemptParam() + "=\\d+).*"); Matcher matcher = attemptPattern.matcher(state); if (matcher.matches()) { String attempts = matcher.group(1); int equals = attempts.lastIndexOf('='); String count = attempts.substring(equals + 1); int countNumber = Integer.parseInt(count); countNumber++; return state.replace(attempts, oidcConfig.redirectAttemptParam() + "=" + countNumber); } else { return state + "&" + oidcConfig.redirectAttemptParam() + "=1"; } } else { return state + "?" + oidcConfig.redirectAttemptParam() + "=1"; } } private  OidcSupport(OidcConfig oidcConfig); }
OidcSupport implements Service { String increaseRedirectCounter(String state) { if (state.contains("?")) { Pattern attemptPattern = Pattern.compile(".*?(" + oidcConfig.redirectAttemptParam() + "=\\d+).*"); Matcher matcher = attemptPattern.matcher(state); if (matcher.matches()) { String attempts = matcher.group(1); int equals = attempts.lastIndexOf('='); String count = attempts.substring(equals + 1); int countNumber = Integer.parseInt(count); countNumber++; return state.replace(attempts, oidcConfig.redirectAttemptParam() + "=" + countNumber); } else { return state + "&" + oidcConfig.redirectAttemptParam() + "=1"; } } else { return state + "?" + oidcConfig.redirectAttemptParam() + "=1"; } } private  OidcSupport(OidcConfig oidcConfig); static OidcSupport create(Config config, String providerName); @Override void update(Routing.Rules rules); static OidcSupport create(Config config); static OidcSupport create(OidcConfig oidcConfig); }
OidcSupport implements Service { String increaseRedirectCounter(String state) { if (state.contains("?")) { Pattern attemptPattern = Pattern.compile(".*?(" + oidcConfig.redirectAttemptParam() + "=\\d+).*"); Matcher matcher = attemptPattern.matcher(state); if (matcher.matches()) { String attempts = matcher.group(1); int equals = attempts.lastIndexOf('='); String count = attempts.substring(equals + 1); int countNumber = Integer.parseInt(count); countNumber++; return state.replace(attempts, oidcConfig.redirectAttemptParam() + "=" + countNumber); } else { return state + "&" + oidcConfig.redirectAttemptParam() + "=1"; } } else { return state + "?" + oidcConfig.redirectAttemptParam() + "=1"; } } private  OidcSupport(OidcConfig oidcConfig); static OidcSupport create(Config config, String providerName); @Override void update(Routing.Rules rules); static OidcSupport create(Config config); static OidcSupport create(OidcConfig oidcConfig);  }