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);
}
}
}
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);
}
}
Aggregations