public static boolean isOutbound(MessageContext messageContext) { return (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); }
@WebService public class MyService { @Resource WebServiceContext wsContext; /** * Web service operation */ @WebMethod public String myMethod() { MessageContext mc = wsContext.getMessageContext(); HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST); System.out.println("Client IP = " + req.getRemoteAddr()); } }
public final boolean isUserInRole(final String role) { SecurityContext ctx = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (ctx == null) { return false; } return ctx.isUserInRole(role); }
public final Principal getUserPrincipal() { SecurityContext ctx = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (ctx == null) { return null; } return ctx.getUserPrincipal(); }
protected void updateHeader(Exchange exchange, MessageContext ctx) { if (ctx.containsKey(Header.HEADER_LIST) && ctx.get(Header.HEADER_LIST) instanceof List<?>) { List<?> list = (List<?>) ctx.get(Header.HEADER_LIST); if (list != null && !list.isEmpty()) { SoapMessage sm = (SoapMessage) createResponseMessage(exchange); if (sm != null) { Iterator<?> iter = list.iterator(); while (iter.hasNext()) { Header header = (Header) iter.next(); if (header.getDirection() != Header.Direction.DIRECTION_IN && !header.getName().getNamespaceURI(). equals("http://docs.oasis-open.org/wss/2004/01/" + "oasis-200401-wss-wssecurity-secext-1.0.xsd") && !header.getName().getNamespaceURI(). equals("http://docs.oasis-open.org/" + "wss/oasis-wss-wssecurity-secext-1.1.xsd")) { //don't copy over security header, out interceptor chain will take care of it. sm.getHeaders().add(header); } } } } } }
protected void updateWebServiceContext(Exchange exchange, MessageContext ctx) { // Guard against wrong type associated with header list. // Need to copy header only if the message is going out. if (ctx.containsKey(Header.HEADER_LIST) && ctx.get(Header.HEADER_LIST) instanceof List<?>) { List<?> list = (List<?>) ctx.get(Header.HEADER_LIST); if (list != null && !list.isEmpty()) { SoapMessage sm = (SoapMessage) createResponseMessage(exchange); if (sm != null) { Iterator<?> iter = list.iterator(); while (iter.hasNext()) { sm.getHeaders().add((Header) iter.next()); } } } } if (exchange.getOutMessage() != null) { Message out = exchange.getOutMessage(); if (out.containsKey(Message.PROTOCOL_HEADERS)) { Map<String, List<String>> heads = CastUtils .cast((Map<?, ?>)exchange.getOutMessage().get(Message.PROTOCOL_HEADERS)); if (heads.containsKey("Content-Type")) { List<String> ct = heads.get("Content-Type"); exchange.getOutMessage().put(Message.CONTENT_TYPE, ct.get(0)); heads.remove("Content-Type"); } } } }
public final Principal getUserPrincipal() { SecurityContext ctx = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (ctx == null) { return null; } return ctx.getUserPrincipal(); }
public final boolean isUserInRole(final String role) { SecurityContext ctx = (SecurityContext)getMessageContext().get(SecurityContext.class.getName()); if (ctx == null) { return false; } return ctx.isUserInRole(role); }
/** * pull id from manual context appendage */ protected String idFromMessageContext(MessageContext mc) { String id = null; String path = (String)mc.get(MessageContext.PATH_INFO); if (null != path) { id = path.substring(path.lastIndexOf('/') + 1); } return id; } }
private List<String> getHandlersInfo(MessageContext ctx) { List<String> ret = CastUtils.cast((List<?>)ctx.get("handler.info")); if (ret == null) { ret = new ArrayList<>(); } return ret; }
protected String idFromMessageContext(MessageContext mc) { String id = EndpointReferenceUtils.getEndpointReferenceId(mc); boolean jmsInvoke = null != mc.get(JMSConstants.JMS_REQUEST_MESSAGE); if ("999".equals(id) && jmsInvoke) { // verification that this is indeed JMS throw new RuntimeException("This is indeed JMS, id=" + id); } return id; }
private Continuation getContinuation(String name) { synchronized (suspended) { Continuation suspendedCont = suspended.remove(name); if (suspendedCont != null) { return suspendedCont; } } ContinuationProvider provider = (ContinuationProvider)context.getMessageContext().get(ContinuationProvider.class.getName()); return provider.getContinuation(); } }
private Continuation getContinuation(String name) { //System.out.println("Getting continuation for " + name); synchronized (suspended) { Continuation suspendedCont = suspended.remove(name); if (suspendedCont != null) { return suspendedCont; } } ContinuationProvider provider = (ContinuationProvider)context.getMessageContext().get(ContinuationProvider.class.getName()); return provider.getContinuation(); }
private Continuation getContinuation(String name) { //System.out.println("Getting continuation for " + name); synchronized (suspended) { Continuation suspendedCont = suspended.remove(name); if (suspendedCont != null) { return suspendedCont; } } ContinuationProvider provider = (ContinuationProvider)context.getMessageContext().get(ContinuationProvider.class.getName()); return provider.getContinuation(); }
private Continuation getContinuation(Integer name) { ContinuationProvider provider = (ContinuationProvider)context.getMessageContext().get(ContinuationProvider.class.getName()); return provider.getContinuation(); }
private Continuation getContinuation(String name) { ContinuationProvider provider = (ContinuationProvider)context.getMessageContext().get(ContinuationProvider.class.getName()); return provider.getContinuation(); } }
public T invoke(T req) { MessageContext mc = wsContext.getMessageContext(); String method = (String)mc.get(MessageContext.HTTP_REQUEST_METHOD); LOG.info("method: " + method); T ret = null; if ("GET".equalsIgnoreCase(method)) { ret = get(req); } else if ("POST".equalsIgnoreCase(method)) { ret = post(req); } return ret; }
private void addToReply(String key, String value) { MessageContext mc = wsContext.getMessageContext(); JMSMessageHeadersType responseHeaders = (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS); responseHeaders.putProperty(key, value); }
protected List<String> getHandlerInfoList(MessageContext ctx) { List<String> handlerInfoList = null; if (ctx.containsKey("handler.info")) { handlerInfoList = CastUtils.cast((List<?>)ctx.get("handler.info")); } else { handlerInfoList = new ArrayList<>(); ctx.put("handler.info", handlerInfoList); ctx.setScope("handler.info", MessageContext.Scope.APPLICATION); } return handlerInfoList; }
private void verifyMAPs() { if (context.getMessageContext() != null) { String property = ADDRESSING_PROPERTIES_INBOUND; AddressingProperties maps = (AddressingProperties) context.getMessageContext().get(property); verificationCache.put(MAPTestBase.verifyMAPs(maps, this)); } }