Adding Attributes to the Principal
Ross Bleakney
rossbleakney at hotmail.com
Fri Sep 14 17:49:19 EDT 2007
I would like to return more than the user name from the server. So, I
changed my authentication handler to do the following:
public class MyHandler implements AuthenticationHandler{
public boolean authenticate(Credentials cred) throws AuthenticationException {
UsernamePasswordCredentials upCred = (UsernamePasswordCredentials) cred;
String username = upCred.getUsername();
String password = upCred.getPassword();
try {
MyAccount account = MyAccount.authenticate(username, password);
UsernamePasswordCredentialsToPrincipalResolver resolver =
new UsernamePasswordCredentialsToPrincipalResolver();
Principal principal = resolver.resolvePrincipal(upCred);
StubPersonAttributeDao stub = new StubPersonAttributeDao();
HashMap<String, Object> map = new HashMap<String, Object>(principal.getAttributes());
map.put("AccountID", account.getAccountID());
stub.setBackingMap(map);
resolver.setAttributeRepository(stub);
} catch (Throwable e) {
return false;
}
return true;
}
...
}
So, now I have a few questions:
1) Should this work?
2) How do I get the information out on the client side (servlet)?
I can get the receipt from the client side (using
session.getAttribute(CASFilter.CAS_FILTER_RECEIPT)), but I don't know
how to resolve that into a set of attributes. If I just had a lump of
xml, I could easily parse through it, but I don't know how to get that.
Thanks,
Ross
_________________________________________________________________
Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way of saying thanks for using Windows Live™.
http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tp.its.yale.edu/pipermail/cas/attachments/20070914/9e43eb7a/attachment.html
More information about the cas
mailing list