use of org.eclipse.ecf.core.security.ObjectCallback in project ecf by eclipse.
the class UrlConnectionRetrieveFileTransfer method setupAuthentication.
protected void setupAuthentication() throws IOException, UnsupportedCallbackException {
if (connectContext == null)
return;
final CallbackHandler callbackHandler = connectContext.getCallbackHandler();
if (callbackHandler == null)
return;
final NameCallback usernameCallback = new NameCallback(USERNAME_PREFIX);
final ObjectCallback passwordCallback = new ObjectCallback();
// Call callback with username and password callbacks
callbackHandler.handle(new Callback[] { usernameCallback, passwordCallback });
username = usernameCallback.getName();
Object o = passwordCallback.getObject();
if (!(o instanceof String))
throw new UnsupportedCallbackException(passwordCallback, Messages.UrlConnectionRetrieveFileTransfer_UnsupportedCallbackException);
password = (String) passwordCallback.getObject();
// Now set authenticator to our authenticator with user and password
Authenticator.setDefault(new UrlConnectionAuthenticator());
}
use of org.eclipse.ecf.core.security.ObjectCallback in project ecf by eclipse.
the class URLFileSystemBrowser method setupAuthentication.
protected void setupAuthentication() throws IOException, UnsupportedCallbackException {
if (connectContext == null)
return;
final CallbackHandler callbackHandler = connectContext.getCallbackHandler();
if (callbackHandler == null)
return;
final NameCallback usernameCallback = new NameCallback(USERNAME_PREFIX);
final ObjectCallback passwordCallback = new ObjectCallback();
// Call callback with username and password callbacks
callbackHandler.handle(new Callback[] { usernameCallback, passwordCallback });
username = usernameCallback.getName();
Object o = passwordCallback.getObject();
if (!(o instanceof String))
throw new UnsupportedCallbackException(passwordCallback, Messages.UrlConnectionRetrieveFileTransfer_UnsupportedCallbackException);
password = (String) passwordCallback.getObject();
// Now set authenticator to our authenticator with user and password
Authenticator.setDefault(new UrlConnectionAuthenticator());
}
Aggregations