Modify JAASMemoryLoginModule so it conforms to the contract with the JAASRealm regard...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Aug 2008 20:27:52 +0000 (20:27 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Aug 2008 20:27:52 +0000 (20:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@684081 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/JAASMemoryLoginModule.java

index acab513..2e00018 100644 (file)
@@ -194,8 +194,19 @@ public class JAASMemoryLoginModule extends MemoryRealm implements LoginModule, R
             return (false);
 
         // Add our Principal to the Subject if needed
-        if (!subject.getPrincipals().contains(principal))
+        if (!subject.getPrincipals().contains(principal)) {
             subject.getPrincipals().add(principal);
+            // Add the roles as additional sudjucts as per the contract with the
+            // JAASRealm
+            if (principal instanceof GenericPrincipal) {
+                String roles[] = ((GenericPrincipal) principal).getRoles();
+                for (int i = 0; i < roles.length; i++) {
+                    subject.getPrincipals().add(
+                            new GenericPrincipal(null, roles[i], null));
+                }
+                
+            }
+        }
 
         committed = true;
         return (true);