List of usage examples for org.apache.http.auth NTCredentials NTCredentials
public NTCredentials(final String usernamePassword)
From source file:com.microsoft.alm.common.connection.ServerContextLookupOperationTest.java
@Before public void init() throws Exception { serverContextList = new ArrayList<ServerContext>(); Properties systemProperties = System.getProperties(); for (int i = 0;; i++) { String userId = systemProperties.getProperty("userId" + i); if (userId == null) { break; }// www . ja v a 2 s .co m String password = systemProperties.getProperty("password" + i); if (password == null) { break; } String url = systemProperties.getProperty("url" + i); if (url == null) { break; } URI uri = new URI(url); ServerContext serverContext; if (url.endsWith("visualstudio.com")) { final AuthenticationInfo authenticationInfo = new AuthenticationInfo(userId, password, uri.toString(), userId); serverContext = new MockServerContext(ServerContext.Type.VSO_DEPLOYMENT, authenticationInfo, uri, null, null, null); } else { final AuthenticationInfo authenticationInfo = AuthHelper.createAuthenticationInfo(url, new NTCredentials(userId + ":" + password)); serverContext = new MockServerContext(ServerContext.Type.TFS, authenticationInfo, uri, null, null, null); } serverContextList.add(serverContext); } Assert.assertFalse(serverContextList.isEmpty()); }
From source file:org.callimachusproject.auth.DetachedRealm.java
private void setCredential(String username, String authority, String passwordFile, ObjectConnection con) throws IOException, RepositoryException, UnsupportedEncodingException { BlobObject file = con.getBlobObject(passwordFile); String encoded = file.getCharContent(true).toString(); String password = new String(Base64.decodeBase64(encoded), "UTF-8"); String host = authority;/*from w w w.j a v a 2 s . co m*/ int port = -1; int index = authority.indexOf(':'); if (index >= 0) { host = authority.substring(0, index); port = Integer.parseInt(authority.substring(index + 1)); } AuthScope scope = new AuthScope(new HttpHost(host, port)); NTCredentials credential = new NTCredentials(username + ':' + password); credentials.setCredentials(scope, credential); }
From source file:org.whitesource.agent.client.WssServiceClientImpl.java
@Override public void setProxy(String host, int port, String username, String password) { if (host == null || host.trim().length() == 0) { return;/* w ww. jav a 2 s. co m*/ } if (port < 0 || port > 65535) { return; } HttpHost proxy = new HttpHost(host, port); // httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); httpClient = HttpClients.custom().setRoutePlanner(routePlanner).build(); logger.info("Using proxy: " + proxy.toHostString()); if (username != null && username.trim().length() > 0) { logger.info("Proxy username: " + username); Credentials credentials; if (username.indexOf('/') >= 0) { credentials = new NTCredentials(username + ":" + password); } else if (username.indexOf('\\') >= 0) { username = username.replace('\\', '/'); credentials = new NTCredentials(username + ":" + password); } else { credentials = new UsernamePasswordCredentials(username, password); } CredentialsProvider credsProvider = new BasicCredentialsProvider(); credsProvider.setCredentials(AuthScope.ANY, credentials); // TODO check httpClient = HttpClientBuilder.create().setProxy(proxy).setDefaultCredentialsProvider(credsProvider) .build(); // httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, credentials); } }