1 18 19 package org.objectweb.jac.samples.photos; 20 21 import org.objectweb.jac.util.Log; 22 import org.objectweb.jac.core.CompositeAspectComponent; 23 import org.objectweb.jac.core.rtti.ClassItem; 24 import org.objectweb.jac.core.rtti.ClassRepository; 25 import org.objectweb.jac.core.rtti.MethodItem; 26 import org.objectweb.jac.aspects.authentication.AuthenticationAC; 27 import org.objectweb.jac.aspects.user.UserAC; 28 29 41 public class CompUserAC extends CompositeAspectComponent { 42 43 46 public CompUserAC() { 47 super(); 48 blockKeywords = new String [] {"profile"}; 51 addChild("user",UserAC.class); 54 addChild("authentication",AuthenticationAC.class); 55 } 56 57 boolean authenticator=false; 58 59 void setAuthenticator() { 60 if(!authenticator) { 61 ((AuthenticationAC)getChild("authentication")) 64 .setDisplayController( 65 ClassRepository.get() 66 .getClass("org.objectweb.jac.aspects.user.UserAC") 67 .getMethod("userController")); 68 authenticator=true; 69 } 70 71 } 72 73 78 public void setUserClass(ClassItem userClass, 79 String loginField, 80 String passwordField, 81 String profileField) { 82 Log.trace("compuser", 83 "setUserClass("+userClass+","+loginField+","+ 84 passwordField+","+profileField+")"); 85 setAuthenticator(); 86 ((UserAC)getChild("user")).setUserClass(userClass, 88 loginField, 89 passwordField, 90 profileField); 91 92 ((AuthenticationAC)getChild("authentication")) 95 .setAuthenticator 96 (ClassRepository.get() 97 .getClass("org.objectweb.jac.aspects.authentication.UserPasswordAuthenticator"), 98 new String [] { getChildActualName("user") }); 99 100 } 101 102 103 public void autoInitClasses(String classExpr) { 104 Log.trace("compuser", 105 "autoInitClass("+classExpr+")"); 106 ((UserAC)getChild("user")).autoInitClasses(classExpr); 107 } 108 109 110 public void autoInitClasses(ClassItem cl, 111 String triggerClassExpr, 112 String triggerMethodExpr) { 113 Log.trace("compuser", 114 "autoInitClass("+cl+","+triggerClassExpr+","+triggerMethodExpr+")"); 115 ((UserAC)getChild("user")).autoInitClasses 116 (cl,triggerClassExpr,triggerMethodExpr); 117 } 118 119 120 public void declareProfile(String name) { 121 Log.trace("compuser", 122 "declareProfile("+name+")"); 123 ((UserAC)getChild("user")).declareProfile(name); 124 } 125 126 127 public void declareProfile(String name,String parent) { 128 Log.trace("compuser", 129 "declareProfile("+name+","+parent+")"); 130 ((UserAC)getChild("user")).declareProfile(name,parent); 131 } 132 133 134 public void addReadable(String profile,String resourceExpr) { 135 Log.trace("compuser", 136 "addReadable("+profile+","+resourceExpr+")"); 137 ((UserAC)getChild("user")).addReadable(profile,resourceExpr); 138 } 139 140 141 public void addUnreadable(String profile,String resourceExpr) { 142 Log.trace("compuser", 143 "addUnreadable("+profile+","+resourceExpr+")"); 144 ((UserAC)getChild("user")).addUnreadable(profile,resourceExpr); 145 } 146 147 148 public void addWritable(String profile,String resourceExpr) { 149 Log.trace("compuser", 150 "addWritable("+profile+","+resourceExpr+")"); 151 ((UserAC)getChild("user")).addWritable(profile,resourceExpr); 152 } 153 154 155 public void addUnwritable(String profile,String resourceExpr) { 156 Log.trace("compuser", 157 "addUnwritable("+profile+","+resourceExpr+")"); 158 ((UserAC)getChild("user")).addUnwritable(profile,resourceExpr); 159 } 160 161 162 public void addRemovable(String profile,String resourceExpr) { 163 Log.trace("compuser", 164 "addRemovable("+profile+","+resourceExpr+")"); 165 ((UserAC)getChild("user")).addRemovable(profile,resourceExpr); 166 } 167 168 169 public void addUnremovable(String profile,String resourceExpr) { 170 Log.trace("compuser", 171 "addUnremovable("+profile+","+resourceExpr+")"); 172 ((UserAC)getChild("user")).addUnremovable(profile,resourceExpr); 173 } 174 175 176 public void addAddable(String profile,String resourceExpr) { 177 Log.trace("compuser", 178 "addAddable("+profile+","+resourceExpr+")"); 179 ((UserAC)getChild("user")).addAddable(profile,resourceExpr); 180 } 181 182 183 public void addCreatable(String profile,String resourceExpr) { 184 Log.trace("compuser", 185 "addCreatable("+profile+","+resourceExpr+")"); 186 ((UserAC)getChild("user")).addCreatable(profile,resourceExpr); 187 } 188 189 190 public void addUnaddable(String profile,String resourceExpr) { 191 Log.trace("compuser", 192 "addUnaddable("+profile+","+resourceExpr+")"); 193 ((UserAC)getChild("user")).addUnaddable(profile,resourceExpr); 194 } 195 196 197 public void defineAdministrator(String login,String password) { 198 Log.trace("compuser", 199 "defineAdministrator("+login+","+password+")"); 200 ((UserAC)getChild("user")).defineAdministrator(login,password); 201 } 202 203 204 public void setDisplayController(MethodItem controller) { 205 setAuthenticator(); 206 Log.trace("compuser", 207 "setDisplayController("+controller+")"); 208 ((AuthenticationAC)getChild("authentication")) 209 .setDisplayController(controller); 210 } 211 212 213 public void setAccessDeniedMessage(String message) { 214 setAuthenticator(); 215 Log.trace("compuser", 216 "setAccessDeniedMessage("+message+")"); 217 ((AuthenticationAC)getChild("authentication")) 218 .setAccessDeniedMessage(message); 219 } 220 221 222 226 } 227 | Popular Tags |