public Authentication getAuthentication() { Authentication auth = null; if (this.username != null && this.password != null) { auth = new Authentication(this.username, this.password); } return auth; }
/** * Sets the username to use for authentication. * * @param username The username, may be {@code null}. * @return The new authentication, never {@code null}. */ public Authentication setUsername( String username ) { if ( eq( this.username, username ) ) { return this; } return new Authentication( username, privateKeyFile, password, passphrase ); }
private Realm getRealm( RemoteRepository repository, String credentialEncoding ) { Realm realm = null; Authentication a = repository.getAuthentication(); if ( a != null && a.getUsername() != null ) { realm = new Realm.RealmBuilder().setPrincipal( a.getUsername() ).setPassword( a.getPassword() ).setUsePreemptiveAuth( false ).setEnconding( credentialEncoding ).build(); } return realm; }
/** * Creates a new authentication with the specified properties. * @param auth The authentication object. */ @SuppressWarnings("PMD.NullAssignment") public RepositoryAuthentication(final Authentication auth) { this.username = auth.getUsername(); if (auth.getPassword() == null) { this.password = null; } else { this.password = auth.getPassword().toCharArray(); } this.privatekeyfile = auth.getPrivateKeyFile(); if (auth.getPassphrase() == null) { this.passphrase = null; } else { this.passphrase = auth.getPassphrase().toCharArray(); } }
Identity identity = injector.getInstance(Identity.class); Authentication auth = new Authentication(); Identity authenticated = auth.authenticate("login","password"); identity.setUid(authenticated.getUid()); identity.setName(authenticated.getName());
@Override public String toString() { return getUsername(); }
/** * Sets the path to the private key file to use for authentication. * * @param privateKeyFile The path to the private key file, may be {@code null}. * @return The new authentication, never {@code null}. */ public Authentication setPrivateKeyFile( String privateKeyFile ) { if ( eq( this.privateKeyFile, privateKeyFile ) ) { return this; } return new Authentication( username, privateKeyFile, password, passphrase ); }
private Realm getRealm( RemoteRepository repository, String credentialEncoding ) { Realm realm = null; Authentication a = repository.getAuthentication(); if ( a != null && a.getUsername() != null ) { realm = new Realm.RealmBuilder().setPrincipal( a.getUsername() ).setPassword( a.getPassword() ).setUsePreemptiveAuth( false ).setEnconding( credentialEncoding ).build(); } return realm; }
private void appendAuth( StringBuilder buffer, Authentication auth ) { if ( auth != null ) { SimpleDigest digest = new SimpleDigest(); digest.update( auth.getUsername() ); digest.update( auth.getPassword() ); digest.update( auth.getPrivateKeyFile() ); digest.update( auth.getPassphrase() ); buffer.append( digest.digest() ).append( '@' ); } }
@Override public String toString() { return getUsername(); }
public Proxy getProxy() { if (isNotBlank(proxyHost) && proxyPort != null) { if (isNotBlank(proxyLogin)) { return new Proxy(proxyProtocol, proxyHost, proxyPort, new Authentication(proxyLogin, proxyPassword)); } else { return new Proxy(proxyProtocol, proxyHost, proxyPort, null); } } return null; }
/** * Sets the username to use for authentication. * * @param username The username, may be {@code null}. * @return The new authentication, never {@code null}. */ public Authentication setUsername( String username ) { if ( eq( this.username, username ) ) { return this; } return new Authentication( username, privateKeyFile, password, passphrase ); }
text = text.replaceFirst(String.format("%s:%s@", authentication.getUsername(), authentication.getPassword()), "");
private void appendAuth( StringBuilder buffer, Authentication auth ) { if ( auth != null ) { SimpleDigest digest = new SimpleDigest(); digest.update( auth.getUsername() ); digest.update( auth.getPassword() ); digest.update( auth.getPrivateKeyFile() ); digest.update( auth.getPassphrase() ); buffer.append( digest.digest() ).append( '@' ); } }
@Override public String toString() { return getUsername(); }
public void setProxy(URL proxyUrl, String proxyUser, String proxyPassword) { Authentication auth = new Authentication(proxyUser, proxyPassword); Proxy proxy = new Proxy(proxyUrl.getProtocol(), proxyUrl.getHost(), proxyUrl.getPort(), auth); synchronized (repos) { for (RemoteRepository repo : repos) { repo.setProxy(proxy); } } }
/** * Sets the path to the private key file to use for authentication. * * @param privateKeyFile The path to the private key file, may be {@code null}. * @return The new authentication, never {@code null}. */ public Authentication setPrivateKeyFile( String privateKeyFile ) { if ( eq( this.privateKeyFile, privateKeyFile ) ) { return this; } return new Authentication( username, privateKeyFile, password, passphrase ); }
text = text.replaceFirst(String.format("%s:%s@", authentication.getUsername(), authentication.getPassword()), "");
private AuthenticationInfo getAuthenticationInfo( RemoteRepository repository ) { AuthenticationInfo auth = null; Authentication a = repository.getAuthentication(); if ( a != null ) { auth = new AuthenticationInfo(); auth.setUserName( a.getUsername() ); auth.setPassword( a.getPassword() ); auth.setPrivateKey( a.getPrivateKeyFile() ); auth.setPassphrase( a.getPassphrase() ); } return auth; }
if ( auth != null ) buffer.append( " as " ).append( auth.getUsername() ); if ( auth != null ) buffer.append( " as " ).append( auth.getUsername() );