Skip to content
Closed
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
35 changes: 22 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
<xwiki.enforcer.enforce-no-old-xwiki-commons.skip>${xwiki.enforcer.skip}</xwiki.enforcer.enforce-no-old-xwiki-commons.skip>
<xwiki.enforcer.enforce-upper-bounds.skip>${xwiki.enforcer.skip}</xwiki.enforcer.enforce-upper-bounds.skip>
<xwiki.enforcer.enforce-java.skip>${xwiki.enforcer.skip}</xwiki.enforcer.enforce-java.skip>
<xwiki.enforcer.enforce-apache-http5.skip>${xwiki.enforcer.skip}</xwiki.enforcer.enforce-apache-http5.skip>
<!-- Allow Apache HttpClient 3 as transitive dependency for now because it's needed in integration tests -->
<xwiki.enforcer.enforce-apache-http5.searchTransitive>false</xwiki.enforcer.enforce-apache-http5.searchTransitive>
<xwiki.license.skip>false</xwiki.license.skip>

<!-- Enable by default auto release on Jira -->
Expand Down Expand Up @@ -465,19 +468,6 @@
<artifactId>httpasyncclient</artifactId>
<version>4.1.5</version>
</dependency>
<!-- Old httpclient -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<!-- We want to choose the SLF4J binding only when XWiki is packaged. -->
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
Expand Down Expand Up @@ -1815,6 +1805,25 @@
</rules>
</configuration>
</execution>
<!-- Check that we're using Apache HTTP 5 and not 3 -->
<execution>
<id>enforce-apache-http5</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${xwiki.enforcer.enforce-apache-http5.skip}</skip>
<rules>
<bannedDependencies>
<searchTransitive>${xwiki.enforcer.enforce-apache-http5.searchTransitive}</searchTransitive>
<message>Best practice is to use Apache HTTPClient 5.x</message>
<excludes>
<exclude>commons-httpclient:commons-httpclient</exclude>
</excludes>
</bannedDependencies>
</rules>
</configuration>
</execution>
<!-- Check that we are using the latest version of Jakarta Activation -->
<execution>
<id>enforce-jakarta.activation-api</id>
Expand Down
1 change: 1 addition & 0 deletions xwiki-commons-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<module>xwiki-commons-extension</module>
<module>xwiki-commons-filter</module>
<module>xwiki-commons-groovy</module>
<module>xwiki-commons-http</module>
<module>xwiki-commons-job</module>
<module>xwiki-commons-logging</module>
<module>xwiki-commons-management</module>
Expand Down
54 changes: 54 additions & 0 deletions xwiki-commons-core/xwiki-commons-http/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-core</artifactId>
<version>18.0.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-commons-http</artifactId>
<name>XWiki Commons - HTTP</name>
<packaging>jar</packaging>
<description>Offers HTTP-related helpers</description>
<properties>
<xwiki.jacoco.instructionRatio>0.00</xwiki.jacoco.instructionRatio>
<!-- Name to display by the Extension Manager -->
<xwiki.extension.name>HTTP helpers</xwiki.extension.name>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.xwiki.commons</groupId>
<artifactId>xwiki-commons-stability</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.http;

import java.io.IOException;

import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.net.URLCodec;
import org.apache.hc.core5.net.PercentCodec;
import org.xwiki.stability.Unstable;

/**
* Provide various helpers around URIs.
*
* @version $Id$
* @since 17.10.0RC1
* @since 17.4.8
* @since 16.10.15
*/
@Unstable
public final class URIUtils
{
private static final URLCodec FORMENCODED_CODEC = new URLCodec();

// For retro compatibility reasons it's safer to use a decoder which convert + into white spaces
private static final PercentCodec URI_CODEC = new PercentCodec();

private URIUtils()
{

}

/**
* @param decoded the string to escape according to URI path specification
* @return the UTF-8 escaped path element
*/
public static String encodePathSegment(String decoded)
{
return URI_CODEC.encode(decoded);
}

/**
* @param encoded the encoded string to parse
* @return the decoded version of the string
* @throws IOException when failing to parse the path
*/
public static String decode(String encoded) throws IOException
{
try {
return FORMENCODED_CODEC.decode(encoded);
} catch (DecoderException e) {
throw new IOException("Failed to decode string [" + encoded + "]", e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.http.internal;

/**
* Represent user credentials used in the context of a test.
*
* @version $Id$
* @since 17.10.0RC1
* @since 17.4.8
* @since 16.10.15
*/
public class XWikiCredentials
{
private final String login;

private final String password;

/**
* @param login the login
* @param password the password
*/
public XWikiCredentials(String login, String password)
{
this.login = login;
this.password = password;
}

/**
* @return the login
*/
public String getUserName()
{
return this.login;
}

/**
* @return the password
*/
public String getPassword()
{
return this.password;
}
}
Loading