Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove direct usage of commons-httpclient 3.1 #2826

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ libraries.xmlSecurity = "org.apache.santuario:xmlsec:4.0.2"
libraries.orgJson = "org.json:json:20240303"
libraries.owaspEsapi = "org.owasp.esapi:esapi:2.5.3.1"
libraries.jodaTime = "joda-time:joda-time:2.12.7"
libraries.commonsHttpClient = "commons-httpclient:commons-httpclient:3.1"
libraries.apacheHttpClient = "org.apache.httpcomponents:httpclient:4.5.14"

// gradle plugins
Expand Down
1 change: 0 additions & 1 deletion server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
exclude(module: "xalan")
}
implementation(libraries.jodaTime)
implementation(libraries.commonsHttpClient)
implementation(libraries.xmlSecurity)
implementation(libraries.springSessionJdbc)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.cloudfoundry.identity.uaa.provider.oauth;

import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails;
import org.cloudfoundry.identity.uaa.login.AccountSavingAuthenticationSuccessHandler;
Expand Down Expand Up @@ -92,7 +92,7 @@ private boolean containsCredentials(final HttpServletRequest request) {
private boolean authenticationWasSuccessful(
final HttpServletRequest request,
final HttpServletResponse response) throws IOException {
final String origin = URIUtil.getName(String.valueOf(request.getRequestURL()));
final String origin = FilenameUtils.getName(request.getRequestURI());
final String code = request.getParameter("code");
final String idToken = request.getParameter("id_token");
final String accessToken = request.getParameter("access_token");
Expand Down
5 changes: 3 additions & 2 deletions uaa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ dependencies {
testImplementation(libraries.springSessionJdbc)
testImplementation(libraries.springTest)
testImplementation(libraries.springSecurityLdap)
testImplementation(libraries.springSecuritySaml)
testImplementation(libraries.springSecuritySaml) {
exclude(module: "commons-httpclient")
}
testImplementation(libraries.springSecurityTest)
testImplementation(libraries.springBootStarterMail)
testImplementation(libraries.mockito)
Expand All @@ -95,7 +97,6 @@ dependencies {
testImplementation(libraries.greenmail)
testImplementation(libraries.jodaTime)
testImplementation(libraries.commonsIo)
testImplementation(libraries.commonsHttpClient)
testImplementation(libraries.owaspEsapi)
testImplementation(libraries.apacheHttpClient)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.util.ArrayList;
Expand All @@ -22,7 +23,6 @@
import java.util.TreeSet;
import javax.servlet.http.HttpSession;

import org.cloudfoundry.identity.uaa.client.UaaClientDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
Expand All @@ -38,7 +38,6 @@
import org.springframework.security.oauth2.common.util.OAuth2Utils;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.cloudfoundry.identity.uaa.client.UaaClientDetails;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import org.springframework.security.web.savedrequest.SavedRequest;
import org.springframework.test.context.TestPropertySource;
Expand All @@ -55,12 +54,12 @@

import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.httpclient.util.URIUtil;
import org.cloudfoundry.identity.uaa.DefaultTestContext;
import org.cloudfoundry.identity.uaa.account.UserInfoResponse;
import org.cloudfoundry.identity.uaa.authentication.UaaAuthentication;
import org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationDetails;
import org.cloudfoundry.identity.uaa.authentication.UaaPrincipal;
import org.cloudfoundry.identity.uaa.client.UaaClientDetails;
import org.cloudfoundry.identity.uaa.constants.OriginKeys;
import org.cloudfoundry.identity.uaa.login.util.RandomValueStringGenerator;
import org.cloudfoundry.identity.uaa.mock.util.OAuthToken;
Expand Down Expand Up @@ -1542,7 +1541,7 @@ void invalidScopeErrorMessageIsNotShowingAllClientScopes() throws Exception {

UriComponents locationComponents = UriComponentsBuilder.fromUri(URI.create(mvcResult.getResponse().getHeader("Location"))).build();
MultiValueMap<String, String> queryParams = locationComponents.getQueryParams();
String errorMessage = URIUtil.encodeQuery("scim.write is invalid. Please use a valid scope name in the request");
String errorMessage = UriUtils.encodeQuery("scim.write is invalid. Please use a valid scope name in the request", Charset.defaultCharset());
assertFalse(queryParams.containsKey("scope"));
assertEquals(errorMessage, queryParams.getFirst("error_description"));
}
Expand Down Expand Up @@ -1571,7 +1570,7 @@ void invalidScopeErrorMessageIsNotShowingAllUserScopes() throws Exception {

UriComponents locationComponents = UriComponentsBuilder.fromUri(URI.create(mvcResult.getResponse().getHeader("Location"))).build();
MultiValueMap<String, String> queryParams = locationComponents.getQueryParams();
String errorMessage = URIUtil.encodeQuery("[something.else] is invalid. This user is not allowed any of the requested scopes");
String errorMessage = UriUtils.encodeQuery("[something.else] is invalid. This user is not allowed any of the requested scopes", Charset.defaultCharset());
assertFalse(queryParams.containsKey("scope"));
assertEquals(errorMessage, queryParams.getFirst("error_description"));
}
Expand Down
Loading