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

[MNG-5583] per endpoint support for PKI authentication #67

Closed
wants to merge 7 commits into from
Expand Up @@ -19,6 +19,19 @@
* under the License.
*/

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import static java.lang.Math.max;
import static java.lang.Math.min;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.List;
import org.apache.maven.wagon.authentication.AuthenticationException;
import org.apache.maven.wagon.authentication.AuthenticationInfo;
import org.apache.maven.wagon.authorization.AuthorizationException;
Expand All @@ -36,21 +49,6 @@
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.IOUtil;

import java.io.File;
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.List;

import static java.lang.Math.max;
import static java.lang.Math.min;

/**
* Implementation of common facilities for Wagon providers.
*
Expand Down
Expand Up @@ -24,9 +24,10 @@
/**
* This class holds the set of properties used when instance of the <code>Wagon</code>
* will use during login operation.
* <br>May 2020, added PKI settings, see MNG-5583
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
*
*
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
*/
public class AuthenticationInfo
implements Serializable
Expand All @@ -51,7 +52,300 @@ public class AuthenticationInfo
* The absolute path to private key file
*/
private String privateKey;

/**
*
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
*
* The path to the trust store. If not defined, the JRE's cacert store is
* used.
*
*
*/
private String trustStore;

/**
*
*
* The password to the trust store.
*
*
*/
private String trustStorePassword;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field contains a password. We must convert it to char[] later on, so can't we store it as a char[]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream model does not allow that. Given that other password fields are strings too, this is acceptable, but not ideal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree with @michael-o otherwise i would have used char[]


/**
*
*
* The type of trust store, default is JKS
*
* .
*/
private String trustStoreType;

/**
*
*
* The path to the keystore used for authentication purposes, or null
*
* .
*/
private String keyStore;

/**
*
*
* Keystore password, can be null
*
* .
*/
private String keyStorePassword;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field contains a password. We must convert it to char[] later on, so can't we store it as a char[]?


/**
*
*
* Keystore if the key store has multiple key pairs, this can be used to
* explicitly select a specific certificate via it's alias. If null, the
* most appropriate certificate is automatically selected by the SSL Factory
*
* .
*/
private String keyAlias;

/**
*
*
* The password to unlock the key, can be null
*
* .
*/
private String keyPassword;
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved

/**
*
*
* The key store type, defaults to JKS
*
* .
*/
private String keyStoreType;

/**
*
*
* The path to the trust store. If not defined, the JRE's cacert store is
* used.
*
*
* @return path, name or null
*/
public String getTrustStore()
{
return trustStore;
}

/**
*
*
* The path to the trust store. If not defined, the JRE's cacert store is
* used.
*
*
* @param trustStore path name or null
*/
public void setTrustStore( String trustStore )
{
this.trustStore = trustStore;
}

/**
*
*
* The password to the trust store.
*
*
* @return password or null
*/
public String getTrustStorePassword()
{
return trustStorePassword;
}

/**
*
*
* The password to the trust store.
*
*
* @param trustStorePassword password or null
*/
public void setTrustStorePassword( String trustStorePassword )
{
this.trustStorePassword = trustStorePassword;
}

/**
*
*
* The type of trust store, default is JKS
*
* .
*
* @return type
*/
public String getTrustStoreType()
{
return trustStoreType;
}

/**
*
*
* The type of trust store, default is JKS
*
* .
*
* @param trustStoreType key store type
*/
public void setTrustStoreType( String trustStoreType )
{
this.trustStoreType = trustStoreType;
}

/**
*
*
* The path to the keystore used for authentication purposes, or null
*
* .
*
* @return path, named keystore (such as MY) or null
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
*/
public String getKeyStore()
{
return keyStore;
}

/**
*
*
* The path to the keystore used for authentication purposes, or null
*
* .
*
* @param keyStore keystore path, name or null
*/
public void setKeyStore( String keyStore )
{
this.keyStore = keyStore;
}

/**
*
*
* Keystore password, can be null
*
* .
*
* @return password or null
*/
public String getKeyStorePassword()
{
return keyStorePassword;
}

/**
*
*
* Keystore password, can be null
*
* .
*
* @param keyStorePassword password or null
*/
public void setKeyStorePassword( String keyStorePassword )
{
this.keyStorePassword = keyStorePassword;
}

/**
*
*
* Keystore if the key store has multiple key pairs, this can be used to
* explicitly select a specific certificate via it's alias. If null, the
* most appropriate certificate is automatically selected by the SSL Factory
*
* .
*
* @return the alias or null
*/
public String getKeyAlias()
{
return keyAlias;
}

/**
*
*
* Keystore if the key store has multiple key pairs, this can be used to
* explicitly select a specific certificate via it's alias. If null, the
* most appropriate certificate is automatically selected by the SSL Factory
*
* .
*
* @param keyAlias alias
*/
public void setKeyAlias( String keyAlias )
{
this.keyAlias = keyAlias;
}

/**
*
*
* The password to unlock the key, can be null
*
* .
*/
public String getKeyPassword()
{
return keyPassword;
}

/**
*
*
* The password to unlock the key, can be null
*
* .
*/
public void setKeyPassword( String keyPassword )
{
this.keyPassword = keyPassword;
}

/**
*
*
* The key store type, defaults to JKS
*
* .
*/
public String getKeyStoreType()
{
return keyStoreType;
}

/**
*
*
* The key store type, defaults to JKS
*
* .
*/
public void setKeyStoreType( String keyStoreType )
{
this.keyStoreType = keyStoreType;
}

/**
* Get the passphrase of the private key file. The passphrase is used only
* when host/protocol supports authentication via exchange of
Expand Down
Expand Up @@ -19,13 +19,12 @@
* under the License.
*/

import java.io.Serializable;
import java.util.Properties;
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
import org.apache.maven.wagon.PathUtils;
import org.apache.maven.wagon.WagonConstants;
import org.codehaus.plexus.util.StringUtils;

import java.io.Serializable;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

import java.util.Properties;

/**
* This class is an abstraction of the location from/to resources
* can be transfered.
Expand Down Expand Up @@ -53,7 +52,7 @@ public class Repository

private String url;

private RepositoryPermissions permissions;
private RepositoryPermissions permissions;
spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Properties influencing wagon behaviour
Expand All @@ -65,7 +64,7 @@ public class Repository
private String username = null;

private String password = null;

spyhunter99 marked this conversation as resolved.
Show resolved Hide resolved
/**
* @deprecated use {@link #Repository(String, String)}
*/
Expand Down