Java 类org.gradle.api.artifacts.repositories.PasswordCredentials 实例源码

项目:Reer    文件:NTLMCredentials.java   
public NTLMCredentials(PasswordCredentials credentials) {
    String domain;
    String username = credentials.getUsername();
    int slashPos = username.indexOf('\\');
    slashPos = slashPos >= 0 ? slashPos : username.indexOf('/');
    if (slashPos >= 0) {
        domain = username.substring(0, slashPos);
        username = username.substring(slashPos + 1);
    } else {
        domain = System.getProperty("http.auth.ntlm.domain", DEFAULT_DOMAIN);
    }
    this.domain = domain == null ? null : domain.toUpperCase();
    this.username = username;
    this.password = credentials.getPassword();
    this.workstation = determineWorkstationName();
}
项目:Reer    文件:HttpClientConfigurer.java   
private void useCredentials(CredentialsProvider credentialsProvider, String host, int port, Collection<? extends Authentication> authentications) {
    Credentials httpCredentials;

    for (Authentication authentication : authentications) {
        String scheme = getAuthScheme(authentication);
        PasswordCredentials credentials = getPasswordCredentials(authentication);

        if (authentication instanceof AllSchemesAuthentication) {
            NTLMCredentials ntlmCredentials = new NTLMCredentials(credentials);
            httpCredentials = new NTCredentials(ntlmCredentials.getUsername(), ntlmCredentials.getPassword(), ntlmCredentials.getWorkstation(), ntlmCredentials.getDomain());
            credentialsProvider.setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthSchemes.NTLM), httpCredentials);

            LOGGER.debug("Using {} and {} for authenticating against '{}:{}' using {}", credentials, ntlmCredentials, host, port, AuthSchemes.NTLM);
        }

        httpCredentials = new UsernamePasswordCredentials(credentials.getUsername(), credentials.getPassword());
        credentialsProvider.setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, scheme), httpCredentials);
        LOGGER.debug("Using {} for authenticating against '{}:{}' using {}", credentials, host, port, scheme);
    }
}
项目:Reer    文件:S3Client.java   
private ClientConfiguration createConnectionProperties() {
    ClientConfiguration clientConfiguration = new ClientConfiguration();
    Optional<HttpProxySettings.HttpProxy> proxyOptional = s3ConnectionProperties.getProxy();
    if (proxyOptional.isPresent()) {
        HttpProxySettings.HttpProxy proxy = s3ConnectionProperties.getProxy().get();
        clientConfiguration.setProxyHost(proxy.host);
        clientConfiguration.setProxyPort(proxy.port);
        PasswordCredentials credentials = proxy.credentials;
        if (credentials != null) {
            clientConfiguration.setProxyUsername(credentials.getUsername());
            clientConfiguration.setProxyPassword(credentials.getPassword());
        }
    }
    Optional<Integer> maxErrorRetryCount = s3ConnectionProperties.getMaxErrorRetryCount();
    if (maxErrorRetryCount.isPresent()) {
        clientConfiguration.setMaxErrorRetry(maxErrorRetryCount.get());
    }
    return clientConfiguration;
}
项目:Pushjet-Android    文件:MavenRemoteRepositoryFactory.java   
public RemoteRepository create() {
    RemoteRepository remoteRepository = new RemoteRepository();
    remoteRepository.setUrl(artifactRepository.getUrl().toString());

    PasswordCredentials credentials = artifactRepository.getCredentials();
    String username = credentials.getUsername();
    String password = credentials.getPassword();

    if (username != null || password != null) {
        Authentication authentication = new Authentication();
        authentication.setUserName(username);
        authentication.setPassword(password);
        remoteRepository.addAuthentication(authentication);
    }

    return remoteRepository;
}
项目:Pushjet-Android    文件:MavenRemoteRepositoryFactory.java   
public RemoteRepository create() {
    RemoteRepository remoteRepository = new RemoteRepository();
    remoteRepository.setUrl(artifactRepository.getUrl().toString());

    PasswordCredentials credentials = artifactRepository.getCredentials();
    String username = credentials.getUsername();
    String password = credentials.getPassword();

    if (username != null || password != null) {
        Authentication authentication = new Authentication();
        authentication.setUserName(username);
        authentication.setPassword(password);
        remoteRepository.addAuthentication(authentication);
    }

    return remoteRepository;
}
项目:Pushjet-Android    文件:NTLMCredentials.java   
public NTLMCredentials(PasswordCredentials credentials) {
    String domain;
    String username = credentials.getUsername();
    int slashPos = username.indexOf('\\');
    slashPos = slashPos >= 0 ? slashPos : username.indexOf('/');
    if (slashPos >= 0) {
        domain = username.substring(0, slashPos);
        username = username.substring(slashPos + 1);
    } else {
        domain = System.getProperty("http.auth.ntlm.domain", DEFAULT_DOMAIN);
    }
    this.domain = domain == null ? null : domain.toUpperCase();
    this.username = username;
    this.password = credentials.getPassword();
    this.workstation = determineWorkstationName();
}
项目:Reer    文件:AuthenticationSupporter.java   
@Override
public PasswordCredentials getCredentials() {
    if (credentials == null) {
        return setCredentials(PasswordCredentials.class);
    } else if (credentials instanceof PasswordCredentials) {
        return Cast.uncheckedCast(credentials);
    } else {
        throw new IllegalStateException("Can not use getCredentials() method when not using PasswordCredentials; please use getCredentials(Class)");
    }
}
项目:Reer    文件:AuthenticationSupporter.java   
@Override
public void credentials(Action<? super PasswordCredentials> action) {
    if (credentials != null && !(credentials instanceof PasswordCredentials)) {
        throw new IllegalStateException("Can not use credentials(Action) method when not using PasswordCredentials; please use credentials(Class, Action)");
    }
    credentials(PasswordCredentials.class, action);
}
项目:Reer    文件:AuthenticationSupporter.java   
private static <T extends Credentials> Class<? extends T> getCredentialsImplType(Class<T> publicType) {
    if (publicType == PasswordCredentials.class) {
        return Cast.uncheckedCast(DefaultPasswordCredentials.class);
    } else if (publicType == AwsCredentials.class) {
        return Cast.uncheckedCast(DefaultAwsCredentials.class);
    } else {
        throw new IllegalArgumentException(String.format("Unknown credentials type: '%s' (supported types: %s and %s).", publicType.getName(), PasswordCredentials.class.getName(), AwsCredentials.class.getName()));
    }
}
项目:Reer    文件:AuthenticationSupporter.java   
private static <T extends Credentials> Class<? super T> getCredentialsPublicType(Class<T> implType) {
    if (PasswordCredentials.class.isAssignableFrom(implType)) {
        return Cast.uncheckedCast(PasswordCredentials.class);
    } else if (AwsCredentials.class.isAssignableFrom(implType)) {
        return Cast.uncheckedCast(AwsCredentials.class);
    } else {
        throw new IllegalArgumentException(String.format("Unknown credentials implementation type: '%s' (supported types: %s and %s).", implType.getName(), DefaultPasswordCredentials.class.getName(), DefaultAwsCredentials.class.getName()));
    }
}
项目:Reer    文件:SftpConnectorFactory.java   
@Override
public ExternalResourceConnector createResourceConnector(ResourceConnectorSpecification connectionDetails) {
    PasswordCredentials passwordCredentials = connectionDetails.getCredentials(PasswordCredentials.class);
    SftpResourceAccessor accessor = new SftpResourceAccessor(sftpClientFactory, passwordCredentials);
    SftpResourceLister lister = new SftpResourceLister(sftpClientFactory, passwordCredentials);
    SftpResourceUploader uploader = new SftpResourceUploader(sftpClientFactory, passwordCredentials);
    return new DefaultExternalResourceConnector(accessor, lister, uploader);
}
项目:Reer    文件:HttpClientConfigurer.java   
private PasswordCredentials getPasswordCredentials(Authentication authentication) {
    org.gradle.api.credentials.Credentials credentials = ((AuthenticationInternal) authentication).getCredentials();
    if (!(credentials instanceof PasswordCredentials)) {
        throw new IllegalArgumentException(String.format("Credentials must be an instance of: %s", PasswordCredentials.class.getCanonicalName()));
    }

    return Cast.uncheckedCast(credentials);
}
项目:Pushjet-Android    文件:DefaultIvyArtifactRepository.java   
public DefaultIvyArtifactRepository(FileResolver fileResolver, PasswordCredentials credentials, RepositoryTransportFactory transportFactory,
                                    LocallyAvailableResourceFinder<ModuleComponentArtifactMetaData> locallyAvailableResourceFinder, Instantiator instantiator,
                                    ResolverStrategy resolverStrategy, FileStore<ModuleComponentArtifactMetaData> artifactFileStore) {
    super(credentials);
    this.fileResolver = fileResolver;
    this.transportFactory = transportFactory;
    this.locallyAvailableResourceFinder = locallyAvailableResourceFinder;
    this.resolverStrategy = resolverStrategy;
    this.artifactFileStore = artifactFileStore;
    this.additionalPatternsLayout = new AdditionalPatternsRepositoryLayout(fileResolver);
    this.layout = new GradleRepositoryLayout();
    this.metaDataProvider = new MetaDataProvider();
    this.instantiator = instantiator;
}
项目:Pushjet-Android    文件:RepositoryTransportFactory.java   
public RepositoryTransport createTransport(Set<String> schemes, String name, PasswordCredentials credentials) {
    if (!WrapUtil.toSet("http", "https", "file", "sftp").containsAll(schemes)) {
        throw new InvalidUserDataException("You may only specify 'file', 'http', 'https' and 'sftp' URLs for a repository.");
    }
    if (WrapUtil.toSet("http", "https").containsAll(schemes)) {
        return createHttpTransport(name, credentials);
    }
    if (WrapUtil.toSet("file").containsAll(schemes)) {
        return createFileTransport(name);
    }
    if (WrapUtil.toSet("sftp").containsAll(schemes)) {
        return createSftpTransport(name, credentials);
    }
    throw new InvalidUserDataException("You cannot mix different URL schemes for a single repository. Please declare separate repositories.");
}
项目:Pushjet-Android    文件:DefaultMavenArtifactRepository.java   
public DefaultMavenArtifactRepository(FileResolver fileResolver, PasswordCredentials credentials, RepositoryTransportFactory transportFactory,
                                      LocallyAvailableResourceFinder<ModuleComponentArtifactMetaData> locallyAvailableResourceFinder,
                                      FileStore<ModuleComponentArtifactMetaData> artifactFileStore) {
    super(credentials);
    this.fileResolver = fileResolver;
    this.transportFactory = transportFactory;
    this.locallyAvailableResourceFinder = locallyAvailableResourceFinder;
    this.artifactFileStore = artifactFileStore;
}
项目:Pushjet-Android    文件:HttpClientConfigurer.java   
private void configureCredentials(DefaultHttpClient httpClient, PasswordCredentials credentials) {
    if (GUtil.isTrue(credentials.getUsername())) {
        useCredentials(httpClient, credentials, AuthScope.ANY_HOST, AuthScope.ANY_PORT);

        // Use preemptive authorisation if no other authorisation has been established
        httpClient.addRequestInterceptor(new PreemptiveAuth(new BasicScheme()), 0);
    }
}
项目:Pushjet-Android    文件:HttpClientConfigurer.java   
private void useCredentials(DefaultHttpClient httpClient, PasswordCredentials credentials, String host, int port) {
    Credentials basicCredentials = new UsernamePasswordCredentials(credentials.getUsername(), credentials.getPassword());
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port), basicCredentials);

    NTLMCredentials ntlmCredentials = new NTLMCredentials(credentials);
    Credentials ntCredentials = new NTCredentials(ntlmCredentials.getUsername(), ntlmCredentials.getPassword(), ntlmCredentials.getWorkstation(), ntlmCredentials.getDomain());
    httpClient.getCredentialsProvider().setCredentials(new AuthScope(host, port, AuthScope.ANY_REALM, AuthPolicy.NTLM), ntCredentials);

    LOGGER.debug("Using {} and {} for authenticating against '{}:{}'", new Object[]{credentials, ntlmCredentials, host, port});
}
项目:Pushjet-Android    文件:HttpTransport.java   
public HttpTransport(String name, PasswordCredentials credentials, RepositoryArtifactCache repositoryCacheManager,
                     ProgressLoggerFactory progressLoggerFactory, TemporaryFileProvider temporaryFileProvider,
                     CachedExternalResourceIndex<String> cachedExternalResourceIndex, BuildCommencedTimeProvider timeProvider) {
    this.name = name;
    this.repositoryCacheManager = repositoryCacheManager;
    repository = createRepository(credentials, progressLoggerFactory, temporaryFileProvider, cachedExternalResourceIndex, timeProvider);
}
项目:Pushjet-Android    文件:HttpTransport.java   
private ExternalResourceRepository createRepository(PasswordCredentials credentials, ProgressLoggerFactory progressLoggerFactory,
                                                    TemporaryFileProvider temporaryFileProvider, CachedExternalResourceIndex<String> cachedExternalResourceIndex, BuildCommencedTimeProvider timeProvider) {
    HttpClientHelper http = new HttpClientHelper(new DefaultHttpSettings(credentials));
    HttpResourceAccessor accessor = new HttpResourceAccessor(http);
    HttpResourceUploader uploader = new HttpResourceUploader(http);
    ProgressLoggingExternalResourceAccessor loggingAccessor = new ProgressLoggingExternalResourceAccessor(accessor, progressLoggerFactory);
    return new DefaultExternalResourceRepository(
            name,
            accessor,
            new ProgressLoggingExternalResourceUploader(uploader, progressLoggerFactory),
            new HttpResourceLister(accessor),
            temporaryFileProvider,
            new DefaultCacheAwareExternalResourceAccessor(loggingAccessor, cachedExternalResourceIndex, timeProvider)
    );
}
项目:Pushjet-Android    文件:DefaultIvyArtifactRepository.java   
public DefaultIvyArtifactRepository(FileResolver fileResolver, PasswordCredentials credentials, RepositoryTransportFactory transportFactory,
                                    LocallyAvailableResourceFinder<ModuleVersionArtifactMetaData> locallyAvailableResourceFinder, Instantiator instantiator,
                                    ResolverStrategy resolverStrategy) {
    super(credentials);
    this.fileResolver = fileResolver;
    this.transportFactory = transportFactory;
    this.locallyAvailableResourceFinder = locallyAvailableResourceFinder;
    this.resolverStrategy = resolverStrategy;
    this.additionalPatternsLayout = new AdditionalPatternsRepositoryLayout(fileResolver);
    this.layout = new GradleRepositoryLayout();
    this.metaDataProvider = new MetaDataProvider();
    this.instantiator = instantiator;
}
项目:Pushjet-Android    文件:DefaultMavenArtifactRepository.java   
public DefaultMavenArtifactRepository(FileResolver fileResolver, PasswordCredentials credentials, RepositoryTransportFactory transportFactory,
                                      LocallyAvailableResourceFinder<ModuleVersionArtifactMetaData> locallyAvailableResourceFinder,
                                      ResolverStrategy resolverStrategy) {
    super(credentials);
    this.fileResolver = fileResolver;
    this.transportFactory = transportFactory;
    this.locallyAvailableResourceFinder = locallyAvailableResourceFinder;
    this.resolverStrategy = resolverStrategy;
}
项目:Reer    文件:AbstractPluginRepository.java   
@Override
public PasswordCredentials getCredentials() {
    return authenticationSupport.getCredentials();
}
项目:Reer    文件:AbstractPluginRepository.java   
@Override
public void credentials(Action<? super PasswordCredentials> action) {
    checkMutable();
    authenticationSupport.credentials(action);
}
项目:Reer    文件:AbstractAuthenticationSupportedRepository.java   
@Override
public PasswordCredentials getCredentials() {
    return delegate.getCredentials();
}
项目:Reer    文件:AbstractAuthenticationSupportedRepository.java   
@Override
public void credentials(Action<? super PasswordCredentials> action) {
    delegate.credentials(action);
}
项目:Reer    文件:SftpResourceUploader.java   
public SftpResourceUploader(SftpClientFactory sftpClientFactory, PasswordCredentials credentials) {
    this.sftpClientFactory = sftpClientFactory;
    this.credentials = credentials;
}
项目:Reer    文件:SftpResourceAccessor.java   
public SftpResourceAccessor(SftpClientFactory sftpClientFactory, PasswordCredentials credentials) {
    this.sftpClientFactory = sftpClientFactory;
    this.credentials = credentials;
}
项目:Reer    文件:SftpResource.java   
public SftpResource(SftpClientFactory clientFactory, ExternalResourceMetaData metaData, URI uri, PasswordCredentials credentials) {
    this.clientFactory = clientFactory;
    this.metaData = metaData;
    this.uri = uri;
    this.credentials = credentials;
}
项目:Reer    文件:SftpResourceLister.java   
public SftpResourceLister(SftpClientFactory sftpClientFactory, PasswordCredentials credentials) {
    this.sftpClientFactory = sftpClientFactory;
    this.credentials = credentials;
}
项目:Reer    文件:SftpHost.java   
public SftpHost(URI uri, PasswordCredentials credentials) {
    hostname = uri.getHost();
    port = uri.getPort();
    username = credentials.getUsername();
    password = credentials.getPassword();
}
项目:Reer    文件:SftpClientFactory.java   
public LockableSftpClient createSftpClient(URI uri, PasswordCredentials credentials) {
    synchronized (lock) {
        SftpHost sftpHost = new SftpHost(uri, credentials);
        return acquireClient(sftpHost);
    }
}
项目:Reer    文件:DefaultDigestAuthentication.java   
public DefaultDigestAuthentication(String name) {
    super(name, DigestAuthentication.class, PasswordCredentials.class);
}
项目:Reer    文件:DefaultBasicAuthentication.java   
public DefaultBasicAuthentication(String name) {
    super(name, BasicAuthentication.class, PasswordCredentials.class);
}
项目:Pushjet-Android    文件:DefaultMavenLocalArtifactRepository.java   
public DefaultMavenLocalArtifactRepository(FileResolver fileResolver, PasswordCredentials credentials, RepositoryTransportFactory transportFactory,
                                    LocallyAvailableResourceFinder<ModuleComponentArtifactMetaData> locallyAvailableResourceFinder,
                                    FileStore<ModuleComponentArtifactMetaData> artifactFileStore) {
    super(fileResolver, credentials, transportFactory, locallyAvailableResourceFinder, artifactFileStore);
}
项目:Pushjet-Android    文件:DefaultBaseRepositoryFactory.java   
private PasswordCredentials createPasswordCredentials() {
    return instantiator.newInstance(DefaultPasswordCredentials.class);
}
项目:Pushjet-Android    文件:RepositoryTransportFactory.java   
private RepositoryTransport createHttpTransport(String name, PasswordCredentials credentials) {
    return new HttpTransport(name, convertPasswordCredentials(credentials), progressLoggerFactory, temporaryFileProvider, cachedExternalResourceIndex, timeProvider, cacheLockingManager);
}
项目:Pushjet-Android    文件:RepositoryTransportFactory.java   
private RepositoryTransport createSftpTransport(String name, PasswordCredentials credentials) {
    return new SftpTransport(name, convertPasswordCredentials(credentials), progressLoggerFactory, temporaryFileProvider, cachedExternalResourceIndex, timeProvider, sftpClientFactory, cacheLockingManager);
}
项目:Pushjet-Android    文件:RepositoryTransportFactory.java   
public RepositoryTransport createTransport(String scheme, String name, PasswordCredentials credentials) {
    Set<String> schemes = new HashSet<String>();
    schemes.add(scheme);
    return createTransport(schemes, name, credentials);
}
项目:Pushjet-Android    文件:RepositoryTransportFactory.java   
private org.gradle.internal.resource.PasswordCredentials convertPasswordCredentials(PasswordCredentials credentials) {
    return new org.gradle.internal.resource.PasswordCredentials(credentials.getUsername(), credentials.getPassword());
}
项目:Pushjet-Android    文件:AbstractAuthenticationSupportedRepository.java   
AbstractAuthenticationSupportedRepository(PasswordCredentials credentials) {
    this.passwordCredentials = credentials;
}