if (repCred!=null && repCred instanceof PasswordCredentials) { PasswordCredentials pwdCred = (PasswordCredentials) repCred; username = pwdCred.getUsername(); password = pwdCred.getPassword()==null ? "" : new String(pwdCred.getPassword());
repo.addExtraParameter( key.toString(), cfg.getExtraParameters().get(key).toString() ); PasswordCredentials credentials = new PasswordCredentials("", new char[0]); if (cfg.getPassword() != null && cfg.getUsername() != null) { credentials.setPassword(cfg.getPassword().toCharArray()); credentials.setUsername(cfg.getUsername()); repo.setCredentials(credentials); } else { credentials.setPassword(new char[0]);
@SuppressWarnings("unchecked") @Override public void updateRemoteInstance( EditableRemoteRepository remoteRepository, RemoteRepositoryConfiguration configuration ) throws RepositoryException { try { remoteRepository.setName( remoteRepository.getPrimaryLocale(), configuration.getName( ) ); remoteRepository.setBaseUri( new URI( "" ) ); remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), configuration.getDescription( ) ); remoteRepository.setLayout( configuration.getLayout( ) ); remoteRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); remoteRepository.setCheckPath( configuration.getCheckPath( ) ); remoteRepository.setExtraHeaders( configuration.getExtraHeaders( ) ); remoteRepository.setExtraParameters( configuration.getExtraParameters( ) ); remoteRepository.setTimeout( Duration.ofSeconds( configuration.getTimeout( ) ) ); char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) ); rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) ); } catch ( Exception e ) { throw new RepositoryException( "Error", e ); } }
authenticationInfo.setUserName( creds.getUsername()); authenticationInfo.setPassword( new String(creds.getPassword()) );
authenticationInfo.setUserName( creds.getUsername( ) ); authenticationInfo.setPassword( new String( creds.getPassword( ) ) );
if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername());
@Override public RemoteRepositoryConfiguration getRemoteConfiguration( RemoteRepository remoteRepository ) { RemoteRepositoryConfiguration configuration = new RemoteRepositoryConfiguration( ); configuration.setId( remoteRepository.getId( ) ); configuration.setName( remoteRepository.getName( ) ); configuration.setDescription( remoteRepository.getDescription( ) ); configuration.setLayout( remoteRepository.getLayout( ) ); configuration.setRefreshCronExpression( remoteRepository.getSchedulingDefinition( ) ); configuration.setCheckPath( remoteRepository.getCheckPath( ) ); configuration.setExtraHeaders( remoteRepository.getExtraHeaders( ) ); configuration.setExtraParameters( remoteRepository.getExtraParameters( ) ); configuration.setTimeout( (int) remoteRepository.getTimeout( ).getSeconds( ) ); RepositoryCredentials creds = remoteRepository.getLoginCredentials( ); if (creds!=null) { PasswordCredentials pwdCreds = (PasswordCredentials) creds; configuration.setUsername( pwdCreds.getUsername( ) ); configuration.setPassword( new String( pwdCreds.getPassword( ) ) ); } configuration.setUrl( remoteRepository.getLocation( ) == null ? "" : remoteRepository.getLocation().toString( ) ); RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); configuration.setDownloadRemoteIndex( rif.isDownloadRemoteIndex( ) ); configuration.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup( ) ); configuration.setIndexDir( rif.getIndexUri( )==null ? "" : rif.getIndexUri().toString( ) ); configuration.setRemoteDownloadNetworkProxyId( rif.getProxyId( ) ); return configuration; }