Package org.eclipse.aether.repository
Class AuthenticationDigest
- java.lang.Object
-
- org.eclipse.aether.repository.AuthenticationDigest
-
public final class AuthenticationDigest extends java.lang.Object
A helper to calculate a fingerprint/digest for the authentication data of a repository/proxy. Such a fingerprint can be used to detect changes in the authentication data across JVM restarts without exposing sensitive information.
-
-
Field Summary
Fields Modifier and Type Field Description private java.security.MessageDigest
digest
private Proxy
proxy
private RemoteRepository
repository
private RepositorySystemSession
session
-
Constructor Summary
Constructors Modifier Constructor Description private
AuthenticationDigest(RepositorySystemSession session, RemoteRepository repository, Proxy proxy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
digest()
static java.lang.String
forProxy(RepositorySystemSession session, RemoteRepository repository)
Gets the fingerprint for the authentication of the specified repository's proxy.static java.lang.String
forRepository(RepositorySystemSession session, RemoteRepository repository)
Gets the fingerprint for the authentication of the specified repository.Proxy
getProxy()
Gets the proxy (if any) to be authenticated with.RemoteRepository
getRepository()
Gets the repository requiring authentication.RepositorySystemSession
getSession()
Gets the repository system session during which the authentication fingerprint is calculated.private static java.security.MessageDigest
newDigest()
void
update(byte... bytes)
Updates the digest with the specified bytes.void
update(char... chars)
Updates the digest with the specified characters.void
update(java.lang.String... strings)
Updates the digest with the specified strings.
-
-
-
Field Detail
-
digest
private final java.security.MessageDigest digest
-
session
private final RepositorySystemSession session
-
repository
private final RemoteRepository repository
-
proxy
private final Proxy proxy
-
-
Constructor Detail
-
AuthenticationDigest
private AuthenticationDigest(RepositorySystemSession session, RemoteRepository repository, Proxy proxy)
-
-
Method Detail
-
forRepository
public static java.lang.String forRepository(RepositorySystemSession session, RemoteRepository repository)
Gets the fingerprint for the authentication of the specified repository.- Parameters:
session
- The repository system session during which the fingerprint is requested, must not benull
.repository
- The repository whose authentication is to be fingerprinted, must not benull
.- Returns:
- The fingerprint of the repository authentication or an empty string if no authentication is configured,
never
null
.
-
forProxy
public static java.lang.String forProxy(RepositorySystemSession session, RemoteRepository repository)
Gets the fingerprint for the authentication of the specified repository's proxy.- Parameters:
session
- The repository system session during which the fingerprint is requested, must not benull
.repository
- The repository whose proxy authentication is to be fingerprinted, must not benull
.- Returns:
- The fingerprint of the proxy authentication or an empty string if no proxy is present or if no proxy
authentication is configured, never
null
.
-
newDigest
private static java.security.MessageDigest newDigest()
-
getSession
public RepositorySystemSession getSession()
Gets the repository system session during which the authentication fingerprint is calculated.- Returns:
- The repository system session, never
null
.
-
getRepository
public RemoteRepository getRepository()
Gets the repository requiring authentication. IfgetProxy()
is notnull
, the data gathered by this authentication digest does not apply to the repository's host but rather the proxy.- Returns:
- The repository to be contacted, never
null
.
-
getProxy
public Proxy getProxy()
Gets the proxy (if any) to be authenticated with.- Returns:
- The proxy or
null
if authenticating directly with the repository's host.
-
update
public void update(java.lang.String... strings)
Updates the digest with the specified strings.- Parameters:
strings
- The strings to update the digest with, may benull
or containnull
elements.
-
update
public void update(char... chars)
Updates the digest with the specified characters.- Parameters:
chars
- The characters to update the digest with, may benull
.
-
update
public void update(byte... bytes)
Updates the digest with the specified bytes.- Parameters:
bytes
- The bytes to update the digest with, may benull
.
-
digest
private java.lang.String digest()
-
-