}
private ConversationState getConversationState() throws Exception
{
ExoContainer container = ExoContainerContext.getCurrentContainer();
Authenticator authenticator = (Authenticator)container.getComponentInstanceOfType(Authenticator.class);
IdentityRegistry identityRegistry =
(IdentityRegistry)container.getComponentInstanceOfType(IdentityRegistry.class);
if (authenticator == null)
throw new LoginException("No Authenticator component found, check your configuration");
Credential[] credentials =
new Credential[]{new UsernameCredential(this.userName), new PasswordCredential(this.userPass)};
this.userId = authenticator.validateUser(credentials);
Identity identity = authenticator.createIdentity(this.userId);
identityRegistry.register(identity);
ConversationState state = new ConversationState(identity);
// keep subject as attribute in ConversationState
state.setAttribute(ConversationState.SUBJECT, identity.getSubject());