Search in sources :

Example 6 with ObjectCallback

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());
}
Also used : CallbackHandler(org.eclipse.ecf.core.security.CallbackHandler) NameCallback(org.eclipse.ecf.core.security.NameCallback) ObjectCallback(org.eclipse.ecf.core.security.ObjectCallback) UnsupportedCallbackException(org.eclipse.ecf.core.security.UnsupportedCallbackException)

Example 7 with ObjectCallback

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());
}
Also used : CallbackHandler(org.eclipse.ecf.core.security.CallbackHandler) NameCallback(org.eclipse.ecf.core.security.NameCallback) ObjectCallback(org.eclipse.ecf.core.security.ObjectCallback) UnsupportedCallbackException(org.eclipse.ecf.core.security.UnsupportedCallbackException)

Aggregations

ObjectCallback (org.eclipse.ecf.core.security.ObjectCallback)7 CallbackHandler (org.eclipse.ecf.core.security.CallbackHandler)5 NameCallback (org.eclipse.ecf.core.security.NameCallback)5 UnsupportedCallbackException (org.eclipse.ecf.core.security.UnsupportedCallbackException)3 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 Callback (org.eclipse.ecf.core.security.Callback)2 IOException (java.io.IOException)1 BBException (org.eclipse.ecf.bulletinboard.BBException)1 IBBCredentials (org.eclipse.ecf.bulletinboard.IBBCredentials)1 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)1 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)1 ID (org.eclipse.ecf.core.identity.ID)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IRosterGroup (org.eclipse.ecf.presence.roster.IRosterGroup)1 ChatSession (org.eclipse.ecf.protocol.msn.ChatSession)1 Contact (org.eclipse.ecf.protocol.msn.Contact)1 Group (org.eclipse.ecf.protocol.msn.Group)1 MsnClient (org.eclipse.ecf.protocol.msn.MsnClient)1 Status (org.eclipse.ecf.protocol.msn.Status)1