use of java.net.PasswordAuthentication in project cxf by apache.
the class ReferencingAuthenticator method tryWith.
PasswordAuthentication tryWith(Authenticator a) throws Exception {
if (a == null) {
return null;
}
for (final Field f : Authenticator.class.getDeclaredFields()) {
if (!Modifier.isStatic(f.getModifiers())) {
f.setAccessible(true);
Object o = f.get(this);
f.set(a, o);
}
}
final Method m = Authenticator.class.getDeclaredMethod("getPasswordAuthentication");
m.setAccessible(true);
return (PasswordAuthentication) m.invoke(a);
}
use of java.net.PasswordAuthentication in project knime-core by knime.
the class ThreadLocalHTTPAuthenticator method getPasswordAuthentication.
/**
* {@inheritDoc}
*/
@Override
protected PasswordAuthentication getPasswordAuthentication() {
if (SUPPRESS_POPUP.get() == Boolean.TRUE) {
return null;
}
try {
// write request values from this object into the delegate
for (final Field f : Authenticator.class.getDeclaredFields()) {
if (!Modifier.isStatic(f.getModifiers())) {
f.setAccessible(true);
Object o = f.get(this);
f.set(m_delegate, o);
}
}
final Method m = Authenticator.class.getDeclaredMethod("getPasswordAuthentication");
m.setAccessible(true);
return (PasswordAuthentication) m.invoke(m_delegate);
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
NodeLogger.getLogger(getClass()).warn("Could not delegate HTTP authentication request: " + ex.getMessage(), ex);
return null;
}
}
use of java.net.PasswordAuthentication in project Payara by payara.
the class HttpAuthenticator method getPasswordAuthentication.
/**
* This is called when authentication is needed for a protected
* web resource. It looks for the authentication data in the subject.
* If the data is not found then login is invoked on the login context.
*/
@Override
protected PasswordAuthentication getPasswordAuthentication() {
String user = null;
char[] password = null;
Subject subject = null;
String scheme = getRequestingScheme();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("scheme=" + scheme);
_logger.fine("requesting prompt=" + getRequestingPrompt());
_logger.fine("requesting protocol=" + getRequestingProtocol());
}
ClientSecurityContext cont = ClientSecurityContext.getCurrent();
subject = (cont != null) ? cont.getSubject() : null;
user = getUserName(subject);
password = getPassword(subject);
if (user == null || password == null) {
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Initiating login again...");
}
securityInfo.doClientLogin(loginType);
cont = ClientSecurityContext.getCurrent();
subject = cont.getSubject();
user = getUserName(subject);
password = getPassword(subject);
} catch (Exception e) {
_logger.log(Level.FINE, "Exception " + e.toString(), e);
return null;
}
}
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Username:" + user);
}
return new PasswordAuthentication(user, password);
}
Aggregations