1 23 package com.sun.enterprise.webservice; 24 25 import java.util.Iterator ; 26 27 import java.rmi.RemoteException ; 28 import java.rmi.UnmarshalException ; 29 30 import javax.xml.namespace.QName ; 31 32 import javax.xml.rpc.JAXRPCException ; 33 import javax.xml.rpc.handler.Handler ; 34 import javax.xml.rpc.handler.GenericHandler ; 35 import javax.xml.rpc.handler.HandlerInfo ; 36 import javax.xml.rpc.handler.MessageContext ; 37 38 import com.sun.enterprise.Switch; 39 import com.sun.ejb.Container; 40 import com.sun.ejb.Invocation; 41 import com.sun.enterprise.InvocationManager; 42 43 import java.util.logging.Logger ; 44 import java.util.logging.Level ; 45 import com.sun.logging.LogDomains; 46 47 55 public class EjbContainerPreHandler extends GenericHandler { 56 57 private static Logger logger = LogDomains.getLogger(LogDomains.EJB_LOGGER); 58 private WsUtil wsUtil = new WsUtil(); 59 60 public EjbContainerPreHandler() {} 61 62 public QName [] getHeaders() { 63 return new QName [0]; 64 } 65 66 public boolean handleRequest(MessageContext context) { 67 Invocation inv = null; 68 Container container = null; 69 70 try { 71 72 Switch theSwitch = Switch.getSwitch(); 73 InvocationManager invManager = theSwitch.getInvocationManager(); 74 inv = (Invocation) invManager.getCurrentInvocation(); 75 container = (Container) inv.container; 76 77 inv.method = wsUtil.getInvMethod(inv.getWebServiceTie(), context); 78 79 if( inv.method != null ) { 82 inv.setWebServiceMethod(inv.method); 83 84 if ( !container.authorize(inv) ) { 85 inv.exception = new Exception 86 ("Client not authorized for invocation of " 87 + inv.method); 88 } 89 } else { 90 inv.setWebServiceMethod(null); 91 } 92 } catch(Exception e) { 93 String errorMsg = "Error unmarshalling method " + 94 ( (container != null ) ? 95 "for ejb " + container.getEjbDescriptor().getName() : 96 "" ); 97 inv.exception = new UnmarshalException (errorMsg); 98 inv.exception.initCause(e); 99 } 100 101 if( inv.exception != null ) { 102 logger.log(Level.WARNING, "preEjbHandlerError", inv.exception); 103 wsUtil.throwSOAPFaultException(inv.exception.getMessage(), 104 context); 105 } 106 107 return true; 108 } 109 110 } 111 | Popular Tags |