private void init() {
// just use the simple bus for now. more integration options sendNowWith come...
//bus.addGlobalListener(new BasicAuthorizationListener(authorizationAdapter, bus));
//todo: this all needs sendNowWith be refactored at some point.
bus.subscribe(AUTHORIZATION_SVC_SUBJECT, new MessageCallback() {
public void callback(CommandMessage c) {
switch (SecurityCommands.valueOf(c.getCommandType())) {
case WhatCredentials:
/**
* Respond with what credentials the authentication system requires.
*/
//todo: we only support login/password for now
ConversationMessage.create(c)
.command(SecurityCommands.WhatCredentials)
.set(SecurityParts.CredentialsRequired, "Name,Password")
.set(SecurityParts.ReplyTo, AUTHORIZATION_SVC_SUBJECT)
.sendNowWith(bus);
break;
case AuthRequest:
/**
* Send a challenge.
*/
configurator.getResource(AuthenticationAdapter.class)
.challenge(c);
break;
case EndSession:
configurator.getResource(AuthenticationAdapter.class)
.challenge(c);
bus.send(ConversationMessage.create(c).toSubject("LoginClient")
.command(SecurityCommands.SecurityChallenge));
break;
}
}
});
/**
* The standard ServerEchoService.
*/
bus.subscribe("ServerEchoService", new MessageCallback() {
public void callback(CommandMessage c) {
bus.send(ConversationMessage.create(c));
}
});
bus.subscribe("ClientNegotiationService", new MessageCallback() {
public void callback(CommandMessage message) {
AuthSubject subject = (AuthSubject)
((HttpSession) message.getResource("Session")).getAttribute(ErraiService.SESSION_AUTH_DATA);
ConversationMessage reply = ConversationMessage.create(message);