@@ -0,0 +1,2074 @@
+import java.security.acl.Group;%0Aimport javax.security.auth.Subject;%0Aimport java.security.Principal;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0Aimport java.util.Enumeration;%0Aimport java.util.Collections;%0A%0A%0Aclass SubjectTest%0A%7B%0A    private static class MyGroup implements Group%0A    %7B%0A        private HashSet%3CPrincipal%3E _members;%0A        private String _name;%0A        %0A        MyGroup( String name )%0A        %7B%0A            _name = name;%0A            _members = new HashSet%3CPrincipal%3E();%0A        %7D%0A        %0A        public boolean%09addMember(Principal user)%0A        %7B%0A            if( _members.contains(user) )%0A            %7B%0A                return false;%0A            %7D%0A            _members.add( user );%0A            return true;%0A        %7D%0A%0A        public boolean%09isMember(Principal member)%0A        %7B%0A            return _members.contains(member);%0A        %7D%0A%0A        public Enumeration%3CPrincipal%3E%09members()%0A        %7B%0A            return Collections.enumeration( _members );%0A        %7D%0A%0A        public boolean%09removeMember(Principal user)%0A        %7B%0A            if( !_members.contains(user) )%0A            %7B%0A                return false;%0A            %7D%0A            _members.remove( user );%0A            return true;%0A        %7D%0A        %0A        public String%09getName()%0A        %7B%0A            return _name;%0A        %7D%0A    %7D%0A    %0A    private void test()%0A    %7B%0A        Subject sub = new Subject();%0A        Set%3CPrincipal%3E prmg =  sub.getPrincipals();%0A        //Set prl =  sub.getPrincipals(MyGroup.class);%0A        MyGroup gr = new MyGroup(%22Roles%22);%0A        if( gr instanceof Group )%0A        %7B%0A            System.out.println(%22is Group%22);%0A        %7D%0A        prmg.add( gr );%0A        Set%3CGroup%3E prl =  sub.getPrincipals(Group.class);%0A        System.out.println( prl.size() );%0A        System.out.println( prl.toString() );%0A        Set%3CMyGroup%3E pr2 =  sub.getPrincipals(MyGroup.class);%0A        System.out.println( pr2.size() );%0A        System.out.println( pr2.toString() );%0A    %7D%0A    %0A    public static void main(String%5B%5D args)%0A    %7B%0A        SubjectTest st = new SubjectTest();%0A        st.test();%0A    %7D%0A%7D

add SubjectTest