if (Objects.equal(username, password))
{
// usually there will be a db call to verify the credentials
DefaultSubject subject = new MyPrimarySubject();
// add principals as required, usually these come from a db
subject.addPrincipal(new MyPrincipal("basic"));
return subject;
}
throw new LoginException("username does not match password");
}