1 28 29 package com.caucho.ejb.gen; 30 31 import com.caucho.java.JavaWriter; 32 import com.caucho.java.gen.CallChain; 33 import com.caucho.java.gen.FilterCallChain; 34 import com.caucho.util.L10N; 35 36 import java.io.IOException ; 37 import java.util.ArrayList ; 38 39 42 public class UserInRoleChain extends FilterCallChain { 43 private static final L10N L = new L10N(UserInRoleChain.class); 44 45 private ArrayList <String > _roles; 46 47 public UserInRoleChain(CallChain next, ArrayList <String > roles) 48 { 49 super(next); 50 51 _roles = roles; 52 } 53 54 60 public void generateCall(JavaWriter out, String retType, 61 String var, String []args) 62 throws IOException 63 { 64 out.print("if (! com.caucho.security.SecurityContext.isUserInRole(new String[] {"); 65 66 for (int i = 0; i < _roles.size(); i++) { 67 String role = _roles.get(i); 68 69 if (i != 0) 70 out.print(", "); 71 72 out.print("\"" + role + "\""); 73 } 74 out.println("})) {"); 75 76 out.println(" throw new javax.ejb.EJBException(\"permission denied\");"); 77 out.println("}"); 78 79 out.println(); 80 81 super.generateCall(out, retType, var, args); 82 } 83 } 84 | Popular Tags |