comparison servlet/src/digilib/auth/AuthOpsImpl.java @ 181:afe7ff98bb71

Servlet version 1.18b1 - new transfer mode "rawfile" with mime-type application/octet-stream - finally proper logging with Log4J! - therefore a lot of debugging-prints changed - the Util class is now useless - ServletOps and FileOps are now purely static
author robcast
date Fri, 21 Nov 2003 00:17:31 +0100
parents 3b8797fc3e90
children 26b2a74e2fe5
comparison
equal deleted inserted replaced
180:bd87f802bea1 181:afe7ff98bb71
18 18
19 */ 19 */
20 20
21 package digilib.auth; 21 package digilib.auth;
22 22
23 import java.util.List;
24 import java.util.ListIterator;
25
23 import javax.servlet.http.HttpServletRequest; 26 import javax.servlet.http.HttpServletRequest;
24 import java.util.*;
25 27
26 import digilib.*; 28 import org.apache.log4j.Logger;
29
30 import digilib.Utils;
27 import digilib.servlet.DigilibRequest; 31 import digilib.servlet.DigilibRequest;
28 32
29 /** Basic implementation of AuthOps interface. 33 /** Basic implementation of AuthOps interface.
30 * 34 *
31 * Provides basic implementations. Only rolesForPath needs to be implemented 35 * Provides basic implementations. Only rolesForPath needs to be implemented
32 * by specific implementations. 36 * by specific implementations.
33 */ 37 */
34 public abstract class AuthOpsImpl implements AuthOps { 38 public abstract class AuthOpsImpl implements AuthOps {
35 39
36 /** Local utils object. */ 40 /** general logger for this class */
37 protected Utils util; 41 protected Logger logger = Logger.getLogger(this.getClass());
38 42
39 /** Default constructor. */ 43 /** Default constructor. */
40 public AuthOpsImpl() { 44 public AuthOpsImpl() {
41 util = new Utils();
42 try { 45 try {
43 init(); 46 init();
44 } catch (AuthOpException e) { 47 } catch (AuthOpException e) {
45 } 48 }
46 } 49 }
47 50
48 /** Constructor taking an utils object. 51 /** Constructor taking an utils object.
49 * @param u utils object. 52 * @param u utils object.
50 */ 53 */
51 public AuthOpsImpl(Utils u) { 54 public AuthOpsImpl(Utils u) {
52 util = u;
53 try { 55 try {
54 init(); 56 init();
55 } catch (AuthOpException e) { 57 } catch (AuthOpException e) {
56 } 58 }
57 } 59 }
109 public boolean isRoleAuthorized(List roles, HttpServletRequest request) { 111 public boolean isRoleAuthorized(List roles, HttpServletRequest request) {
110 ListIterator r = roles.listIterator(); 112 ListIterator r = roles.listIterator();
111 String s = ""; 113 String s = "";
112 while (r.hasNext()) { 114 while (r.hasNext()) {
113 s = (String)r.next(); 115 s = (String)r.next();
114 util.dprintln(5, "Testing role: "+s); 116 logger.debug("Testing role: "+s);
115 if (request.isUserInRole(s)) { 117 if (request.isUserInRole(s)) {
116 util.dprintln(5, "Role Authorized"); 118 logger.debug("Role Authorized");
117 return true; 119 return true;
118 } 120 }
119 } 121 }
120 return false; 122 return false;
121 } 123 }
126 public boolean isRoleAuthorized(List roles, DigilibRequest request) { 128 public boolean isRoleAuthorized(List roles, DigilibRequest request) {
127 ListIterator r = roles.listIterator(); 129 ListIterator r = roles.listIterator();
128 String s = ""; 130 String s = "";
129 while (r.hasNext()) { 131 while (r.hasNext()) {
130 s = (String)r.next(); 132 s = (String)r.next();
131 util.dprintln(5, "Testing role: "+s); 133 logger.debug("Testing role: "+s);
132 if (((HttpServletRequest)request.getServletRequest()).isUserInRole(s)) { 134 if (((HttpServletRequest)request.getServletRequest()).isUserInRole(s)) {
133 util.dprintln(5, "Role Authorized"); 135 logger.debug("Role Authorized");
134 return true; 136 return true;
135 } 137 }
136 } 138 }
137 return false; 139 return false;
138 } 140 }