1 55 56 package org.jboss.axis.handlers; 57 58 import org.jboss.axis.AxisFault; 59 import org.jboss.axis.MessageContext; 60 import org.jboss.axis.security.AuthenticatedUser; 61 import org.jboss.axis.security.SecurityProvider; 62 import org.jboss.axis.security.simple.SimpleSecurityProvider; 63 import org.jboss.axis.utils.Messages; 64 import org.jboss.logging.Logger; 65 66 67 78 public class SimpleAuthenticationHandler extends BasicHandler 79 { 80 private static Logger log = Logger.getLogger(SimpleAuthenticationHandler.class.getName()); 81 82 85 public void invoke(MessageContext msgContext) throws AxisFault 86 { 87 if (log.isDebugEnabled()) 88 { 89 log.debug("Enter: SimpleAuthenticationHandler::invoke"); 90 } 91 92 SecurityProvider provider = (SecurityProvider)msgContext.getProperty(MessageContext.SECURITY_PROVIDER); 93 if (provider == null) 94 { 95 provider = new SimpleSecurityProvider(); 96 msgContext.setProperty(MessageContext.SECURITY_PROVIDER, provider); 97 } 98 99 if (provider != null) 100 { 101 String userID = msgContext.getUsername(); 102 if (log.isDebugEnabled()) 103 { 104 log.debug(Messages.getMessage("user00", userID)); 105 } 106 107 if (userID == null || userID.equals("")) 109 throw new AxisFault("Server.Unauthenticated", 110 Messages.getMessage("cantAuth00", userID), 111 null, null); 112 113 String passwd = msgContext.getPassword(); 114 if (log.isDebugEnabled()) 115 { 116 log.debug(Messages.getMessage("password00", passwd)); 117 } 118 119 AuthenticatedUser authUser = provider.authenticate(msgContext); 120 121 if (authUser == null) 123 throw new AxisFault("Server.Unauthenticated", 124 Messages.getMessage("cantAuth01", userID), 125 null, null); 126 127 if (log.isDebugEnabled()) 128 { 129 log.debug(Messages.getMessage("auth00", userID)); 130 } 131 132 msgContext.setProperty(MessageContext.AUTHUSER, authUser); 133 } 134 135 if (log.isDebugEnabled()) 136 { 137 log.debug("Exit: SimpleAuthenticationHandler::invoke"); 138 } 139 } 140 } 141 142 ; 143 | Popular Tags |