Search in sources :

Example 1 with IBBCredentials

use of org.eclipse.ecf.bulletinboard.IBBCredentials in project ecf by eclipse.

the class AbstractBBContainer method connect.

public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
    this.targetID = targetID;
    bb.postConnect();
    IBBCredentials creds = getCredentialsFromConnectContext(connectContext);
    if (creds != null) {
        try {
            bb.login(creds);
        } catch (BBException e) {
            throw new ContainerConnectException(e);
        }
    }
}
Also used : ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) IBBCredentials(org.eclipse.ecf.bulletinboard.IBBCredentials) BBException(org.eclipse.ecf.bulletinboard.BBException)

Example 2 with IBBCredentials

use of org.eclipse.ecf.bulletinboard.IBBCredentials in project ecf by eclipse.

the class AbstractBBContainer method getCredentialsFromConnectContext.

protected IBBCredentials getCredentialsFromConnectContext(IConnectContext connectContext) throws ContainerConnectException {
    try {
        if (connectContext == null) {
            return null;
        }
        Callback[] callbacks = new Callback[2];
        callbacks[0] = new NameCallback("Username");
        callbacks[1] = new ObjectCallback();
        CallbackHandler handler = connectContext.getCallbackHandler();
        if (handler != null) {
            handler.handle(callbacks);
        }
        NameCallback nc = (NameCallback) callbacks[0];
        ObjectCallback cb = (ObjectCallback) callbacks[1];
        return new Credentials(nc.getName(), (String) cb.getObject());
    } catch (Exception e) {
        throw new ContainerConnectException("Exception in CallbackHandler.handle(<callbacks>)", e);
    }
}
Also used : CallbackHandler(org.eclipse.ecf.core.security.CallbackHandler) ObjectCallback(org.eclipse.ecf.core.security.ObjectCallback) Callback(org.eclipse.ecf.core.security.Callback) NameCallback(org.eclipse.ecf.core.security.NameCallback) NameCallback(org.eclipse.ecf.core.security.NameCallback) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ObjectCallback(org.eclipse.ecf.core.security.ObjectCallback) IBBCredentials(org.eclipse.ecf.bulletinboard.IBBCredentials) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) BBException(org.eclipse.ecf.bulletinboard.BBException)

Aggregations

BBException (org.eclipse.ecf.bulletinboard.BBException)2 IBBCredentials (org.eclipse.ecf.bulletinboard.IBBCredentials)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 Callback (org.eclipse.ecf.core.security.Callback)1 CallbackHandler (org.eclipse.ecf.core.security.CallbackHandler)1 NameCallback (org.eclipse.ecf.core.security.NameCallback)1 ObjectCallback (org.eclipse.ecf.core.security.ObjectCallback)1