use of java.net.PasswordAuthentication in project BiglyBT by BiglySoftware.
the class ResourceUploaderURLImpl method getAuthentication.
@Override
public PasswordAuthentication getAuthentication(String realm, URL tracker) {
if (user_name == null || password == null) {
String user_info = tracker.getUserInfo();
if (user_info == null) {
return (null);
}
String user_bit = user_info;
String pw_bit = "";
int pos = user_info.indexOf(':');
if (pos != -1) {
user_bit = user_info.substring(0, pos);
pw_bit = user_info.substring(pos + 1);
}
return (new PasswordAuthentication(user_bit, pw_bit.toCharArray()));
}
return (new PasswordAuthentication(user_name, password.toCharArray()));
}
use of java.net.PasswordAuthentication in project UniversalMediaServer by UniversalMediaServer.
the class HTTPResourceAuthenticator method getPasswordAuthentication.
/**
* Called when password authentication is needed.
* @return Returns the {@link PasswordAuthentication} collected from the site
* information, or null if none is provided.
*/
@Override
public PasswordAuthentication getPasswordAuthentication() {
URL requrl = getRequestingURL();
if (siteinfo.get(requrl.getHost()) != null) {
String userinfo = siteinfo.get(requrl.getHost());
StringTokenizer st = new StringTokenizer(userinfo, ":");
String user = null;
String pass = null;
if (st.hasMoreTokens()) {
user = st.nextToken();
}
if (st.hasMoreTokens()) {
pass = st.nextToken();
}
if (pass != null) {
// Send user information for the URL.
PasswordAuthentication pwAuth = new PasswordAuthentication(user, pass.toCharArray());
return pwAuth;
} else {
return null;
}
} else {
return null;
}
}
use of java.net.PasswordAuthentication in project epp.mpc by eclipse.
the class ProxyAuthenticator method getPasswordAuthentication.
@Override
protected PasswordAuthentication getPasswordAuthentication() {
IProxyService proxyService = ProxyHelper.getProxyService();
if (proxyService != null && proxyService.isProxiesEnabled()) {
URL requestingURL = getRequestingURL();
IProxyData[] proxies;
if (requestingURL == null) {
proxies = proxyService.getProxyData();
} else {
try {
proxies = proxyService.select(requestingURL.toURI());
} catch (URISyntaxException e) {
proxies = proxyService.getProxyData();
}
}
for (IProxyData proxyData : proxies) {
// make sure we don't hand out credentials to the wrong proxy
if (proxyData.isRequiresAuthentication() && proxyData.getPort() == getRequestingPort() && hostMatches(proxyData)) {
String userId = proxyData.getUserId();
String password = proxyData.getPassword();
if (userId != null && password != null) {
return new PasswordAuthentication(userId, password.toCharArray());
}
}
}
}
if (delegate != null) {
// Eclipse UI bundle registers one to query credentials from user
try {
Authenticator.setDefault(delegate);
String requestingHost = getRequestingHost();
InetAddress requestingSite = getRequestingSite();
int requestingPort = getRequestingPort();
String requestingProtocol = getRequestingProtocol();
String requestingPrompt = getRequestingPrompt();
String requestingScheme = getRequestingScheme();
URL requestingURL = getRequestingURL();
RequestorType requestorType = getRequestorType();
if (requestingSite == null) {
try {
requestingSite = InetAddress.getByName(requestingHost);
} catch (Exception ex) {
// ignore
}
}
if (requestingPrompt == null) {
// Help the Eclipse UI password dialog with its prompt
String promptHost = // $NON-NLS-1$
requestingSite == null ? // $NON-NLS-1$
String.format("%s:%s", requestingHost, requestingPort) : requestingHost == null ? requestingSite.getHostName() : requestingHost;
String promptType = requestorType.toString().toLowerCase();
requestingPrompt = MessageFormat.format(Messages.ProxyAuthenticator_prompt, requestingScheme, promptType, promptHost);
}
return Authenticator.requestPasswordAuthentication(requestingHost, requestingSite, requestingPort, requestingProtocol, requestingPrompt, requestingScheme, requestingURL, requestorType);
} finally {
Authenticator.setDefault(this);
}
}
return null;
}
use of java.net.PasswordAuthentication in project netxms by netxms.
the class ApplicationWorkbenchAdvisor method initialize.
/* (non-Javadoc)
* @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer)
*/
@Override
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
// Early creation of progress service to prevent NPE in Eclipse 4.2
PlatformUI.getWorkbench().getProgressService();
TweakletManager.initTweaklets();
BrandingManager.create();
final IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
// $NON-NLS-1$
configurer.setSaveAndRestore(ps.getBoolean("SAVE_AND_RESTORE"));
if (// $NON-NLS-1$
ps.getBoolean("HTTP_PROXY_ENABLED")) {
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("http.proxyHost", ps.getString("HTTP_PROXY_SERVER"));
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("http.proxyPort", ps.getString("HTTP_PROXY_PORT"));
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("http.noProxyHosts", ps.getString("HTTP_PROXY_EXCLUSIONS"));
if (// $NON-NLS-1$
ps.getBoolean("HTTP_PROXY_AUTH")) {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
// $NON-NLS-1$ //$NON-NLS-2$
return new PasswordAuthentication(ps.getString("HTTP_PROXY_LOGIN"), ps.getString("HTTP_PROXY_PASSWORD").toCharArray());
}
});
}
} else {
// $NON-NLS-1$
System.clearProperty("http.proxyHost");
// $NON-NLS-1$
System.clearProperty("http.proxyPort");
// $NON-NLS-1$
System.clearProperty("http.noProxyHosts");
}
}
use of java.net.PasswordAuthentication in project sonar-java by SonarSource.
the class A method a.
private void a(char[] pwd, String var) {
String variable1 = "blabla";
// Noncompliant [[sc=24;ec=46]] {{'password' detected in this expression, review this potentially hardcoded credential.}}
String variable2 = "login=a&password=xxx";
// Noncompliant
String variable3 = "login=a&passwd=xxx";
// Noncompliant
String variable4 = "login=a&pwd=xxx";
String variable5 = "login=a&password=";
String variable6 = "login=a&password= ";
// Noncompliant [[sc=12;ec=40]]
String variableNameWithPasswordInIt = "xxx";
// Noncompliant [[sc=12;ec=38]]
String variableNameWithPasswdInIt = "xxx";
// Noncompliant [[sc=12;ec=35]]
String variableNameWithPwdInIt = "xxx";
String otherVariableNameWithPasswordInIt;
// Noncompliant
fieldNameWithPasswordInIt = "xx";
fieldNameWithPasswordInIt = retrievePassword();
// Noncompliant
this.fieldNameWithPasswordInIt = "xx";
this.fieldNameWithPasswordInIt = retrievePassword();
variable1 = "xx";
String[] array = {};
array[0] = "xx";
A myA = new A();
// Noncompliant
myA.setProperty("password", "xxxxx");
// Noncompliant
myA.setProperty("passwd", "xxxxx");
// Noncompliant
myA.setProperty("pwd", "xxxxx");
myA.setProperty("password", new Object());
myA.setProperty("xxxxx", "password");
myA.setProperty(12, "xxxxx");
myA.setProperty(new Object(), new Object());
// Noncompliant
MyUnknownClass.myUnknownMethod("password", "xxxxx");
PasswordAuthentication pa;
// Noncompliant {{Remove this hard-coded password.}}
pa = new PasswordAuthentication("userName", "1234".toCharArray());
// Compliant
pa = new PasswordAuthentication("userName", pwd);
// Compliant
pa = new PasswordAuthentication("userName", getPwd(var));
// Compliant
pa = new PasswordAuthentication("userName", var.toCharArray());
OtherPasswordAuthentication opa;
// Compliant
opa = new OtherPasswordAuthentication("userName", "1234".toCharArray());
}
Aggregations