Hi,
Here are my details:
RuntimeEnvironment:
JBoss 3.2.3 with Tomcat 4.1
Configuration:
1-Single Sign On in Tomcat enabled
2-I Use my own Implementation for the LoginModule
3-I use my own Implementation of the Principal
Implementation:
LoginModule
| public boolean commit() throws LoginException {
| if (!loginOk) return false;
| Set principals = subject.getPrincipals();
| //add Principal
| principals.add(getIdentity());
| // Add Roles
| Group[] roleSets = getRoleSets();
| for (int g = 0; g < roleSets.length; g++) {
| Group group = roleSets[g];
| String name = group.getName();
| Group subjectGroup = createGroup(name, principals);
| if (subjectGroup instanceof NestableGroup) {
| SimpleGroup tmp = new SimpleGroup ("Roles");
| subjectGroup.addMember(tmp);
| subjectGroup = tmp;
| }
| // Copy the group members to the Subject group
| Enumeration members = group.members();
| while (members.hasMoreElements()) {
| Principal role = (Principal) members.nextElement();
| subjectGroup.addMember(role);
| }
| }
| return true;
| }
|
| public Group[] getRoleSets() throws LoginException {
|
| SimpleGroup userRoles = new SimpleGroup("Roles");
| SimpleGroup callerPrincipalGroup = new SimpleGroup("CallerPrincipal");
|
| Set set = new HashSet();
| //Roles to Group "Roles"
| try {
| set = (Set) bereMgr.getBenutzerrollen();
| } catch (DzException e) {
| throw new LoginException(e.getMessage());
| }
| Iterator it = set.iterator();
| while (it.hasNext()) {
| String rolle = (String) it.next();
| //Add each role to the "Roles" principal
| userRoles.addMember(new BereFunktion(rolle));
| }
|
| //Principal ins Group "CallerPrincipal"
| callerPrincipalGroup.addMember(getIdentity());
| Group[] roleSets = { userRoles, callerPrincipalGroup };
| return roleSets;
| }
|
Getting my Implementation of the principal DZPrincipal
| Principal principal = SecurityAssociation.getPrincipal();
| if (principal instanceof DZPrincipal)
| return (DZPrincipal) principal;
| else{
| Subject subject = SecurityAssociation.getSubject();
| Set principals = subject.getPrincipals();
| Iterator i = principals.iterator();
| while (i.hasNext()) {
| Principal p = (Principal) i.next();
| if (p instanceof DZPrincipal)
| return (DZPrincipal)p;
| }
| }
|
|
I use this methode to get my Principal, because request.getUserPrincipal() sometimes
returns an Instance of SimplePrincipal.
Is this Information sufficient?
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3834060#3834060
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3834060
-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user