1 55 56 package org.jboss.axis.security.servlet; 57 58 import org.jboss.axis.MessageContext; 59 import org.jboss.axis.security.AuthenticatedUser; 60 import org.jboss.axis.security.SecurityProvider; 61 import org.jboss.axis.transport.http.HTTPConstants; 62 import org.jboss.axis.utils.Messages; 63 import org.jboss.logging.Logger; 64 65 import javax.servlet.http.HttpServletRequest ; 66 import java.security.Principal ; 67 import java.util.HashMap ; 68 69 70 81 public class ServletSecurityProvider implements SecurityProvider 82 { 83 private static Logger log = Logger.getLogger(ServletSecurityProvider.class.getName()); 84 85 static HashMap users = null; 86 87 94 public AuthenticatedUser authenticate(MessageContext msgContext) 95 { 96 HttpServletRequest req = (HttpServletRequest )msgContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); 97 98 if (req == null) 99 return null; 100 101 log.debug(Messages.getMessage("got00", "HttpServletRequest")); 102 103 Principal principal = req.getUserPrincipal(); 104 if (principal == null) 105 { 106 log.debug(Messages.getMessage("noPrincipal00")); 107 return null; 108 } 109 110 log.debug(Messages.getMessage("gotPrincipal00", principal.getName())); 111 112 return new ServletAuthenticatedUser(req); 113 } 114 115 121 public boolean userMatches(AuthenticatedUser user, String principal) 122 { 123 if (user == null) return principal == null; 124 125 if (user instanceof ServletAuthenticatedUser) 126 { 127 ServletAuthenticatedUser servletUser = (ServletAuthenticatedUser)user; 128 return servletUser.getRequest().isUserInRole(principal); 129 } 130 131 return false; 132 } 133 } 134 | Popular Tags |