1 19 package org.lucane.server.store; 20 21 import org.lucane.server.*; 22 import org.lucane.common.concepts.*; 23 24 import java.util.*; 25 26 public abstract class UserStore 27 { 28 33 public abstract void storeUser(UserConcept user) throws Exception ; 34 35 40 public abstract void updateUser(UserConcept user) throws Exception ; 41 42 47 public abstract void removeUser(UserConcept user) throws Exception ; 48 49 55 public abstract UserConcept getUser(String login) throws Exception ; 56 57 62 public abstract Iterator getAllUsers() throws Exception ; 63 64 71 public boolean checkUserPassword(UserConcept user, String passwd) 72 { 73 try { 74 return user.getPassword().equals(passwd); 75 } catch(Exception e) { 76 return false; 77 } 78 } 79 80 86 public Iterator getAllUserGroups(UserConcept user) 87 throws Exception 88 { 89 ArrayList userGroups = new ArrayList(); 90 GroupStore gm = Server.getInstance().getStore().getGroupStore(); 91 92 Iterator groups = gm.getAllGroups(); 93 while(groups.hasNext()) 94 { 95 GroupConcept group = (GroupConcept)groups.next(); 96 if(group.hasUser(user)) 97 recurseGroups(group, userGroups); 98 } 99 100 return userGroups.iterator(); 101 } 102 103 109 private void recurseGroups(GroupConcept group, ArrayList groups) 110 { 111 if(group == null || groups.contains(group)) 112 return; 113 114 groups.add(group); 115 Iterator i = group.getParents(); 116 117 while(i.hasNext()) 118 recurseGroups((GroupConcept)i.next(), groups); 119 } 120 } 121 | Popular Tags |