/** * 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(); } }
text = text.replaceFirst(String.format("%s:%s@", authentication.getUsername(), authentication.getPassword()), "");
text = text.replaceFirst(String.format("%s:%s@", authentication.getUsername(), authentication.getPassword()), "");
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( '@' ); } }
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( '@' ); } }
private ProxyServer getProxy( RemoteRepository repository, String credentialEncoding ) { ProxyServer proxyServer = null; Proxy p = repository.getProxy(); if ( p != null ) { Authentication a = p.getAuthentication(); boolean useSSL = repository.getProtocol().equalsIgnoreCase( "https" ) || repository.getProtocol().equalsIgnoreCase( "dav:https" ); if ( a == null ) { proxyServer = new ProxyServer( useSSL ? Protocol.HTTPS : Protocol.HTTP, p.getHost(), p.getPort() ); } else { proxyServer = new ProxyServer( useSSL ? Protocol.HTTPS : Protocol.HTTP, p.getHost(), p.getPort(), a.getUsername(), a.getPassword() ); proxyServer.setEncoding( credentialEncoding ); } } return proxyServer; }
private ProxyServer getProxy( RemoteRepository repository, String credentialEncoding ) { ProxyServer proxyServer = null; Proxy p = repository.getProxy(); if ( p != null ) { Authentication a = p.getAuthentication(); boolean useSSL = repository.getProtocol().equalsIgnoreCase( "https" ) || repository.getProtocol().equalsIgnoreCase( "dav:https" ); if ( a == null ) { proxyServer = new ProxyServer( useSSL ? Protocol.HTTPS : Protocol.HTTP, p.getHost(), p.getPort() ); } else { proxyServer = new ProxyServer( useSSL ? Protocol.HTTPS : Protocol.HTTP, p.getHost(), p.getPort(), a.getUsername(), a.getPassword() ); proxyServer.setEncoding( credentialEncoding ); } } return proxyServer; }
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 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 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; }
private ProxyInfoProvider getProxy( RemoteRepository repository ) { ProxyInfoProvider proxy = null; Proxy p = repository.getProxy(); if ( p != null ) { final ProxyInfo prox = new ProxyInfo(); prox.setType( p.getType() ); prox.setHost( p.getHost() ); prox.setPort( p.getPort() ); if ( p.getAuthentication() != null ) { prox.setUserName( p.getAuthentication().getUsername() ); prox.setPassword( p.getAuthentication().getPassword() ); } proxy = new ProxyInfoProvider() { public ProxyInfo getProxyInfo( String protocol ) { return prox; } }; } return proxy; }