1 16 17 package org.apache.axis.security.servlet; 18 19 import org.apache.axis.MessageContext; 20 import org.apache.axis.components.logger.LogFactory; 21 import org.apache.axis.security.AuthenticatedUser; 22 import org.apache.axis.security.SecurityProvider; 23 import org.apache.axis.transport.http.HTTPConstants; 24 import org.apache.axis.utils.Messages; 25 import org.apache.commons.logging.Log; 26 27 import javax.servlet.http.HttpServletRequest ; 28 import java.security.Principal ; 29 import java.util.HashMap ; 30 31 32 43 public class ServletSecurityProvider implements SecurityProvider { 44 protected static Log log = 45 LogFactory.getLog(ServletSecurityProvider.class.getName()); 46 47 static HashMap users = null; 48 49 55 public AuthenticatedUser authenticate(MessageContext msgContext) { 56 HttpServletRequest req = (HttpServletRequest )msgContext.getProperty( 57 HTTPConstants.MC_HTTP_SERVLETREQUEST); 58 59 if (req == null) 60 return null; 61 62 log.debug(Messages.getMessage("got00", "HttpServletRequest")); 63 64 Principal principal = req.getUserPrincipal(); 65 if (principal == null) { 66 log.debug(Messages.getMessage("noPrincipal00")); 67 return null; 68 } 69 70 log.debug(Messages.getMessage("gotPrincipal00", principal.getName())); 71 72 return new ServletAuthenticatedUser(req); 73 } 74 75 80 public boolean userMatches(AuthenticatedUser user, String principal) { 81 if (user == null) return principal == null; 82 83 if (user instanceof ServletAuthenticatedUser) { 84 ServletAuthenticatedUser servletUser = (ServletAuthenticatedUser)user; 85 return servletUser.getRequest().isUserInRole(principal); 86 } 87 88 return false; 89 } 90 } 91 | Popular Tags |