01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.core.stateless;
17:
18: import java.security.Principal;
19:
20: import javax.ejb.SessionContext;
21: import javax.xml.ws.WebServiceContext;
22: import javax.xml.ws.EndpointReference;
23: import javax.xml.ws.handler.MessageContext;
24:
25: import org.apache.openejb.core.ThreadContext;
26: import org.w3c.dom.Element;
27:
28: public class EjbWsContext implements WebServiceContext {
29: private SessionContext context;
30:
31: public EjbWsContext(SessionContext context) {
32: this .context = context;
33: }
34:
35: public MessageContext getMessageContext() {
36: ThreadContext threadContext = ThreadContext.getThreadContext();
37: MessageContext messageContext = threadContext
38: .get(MessageContext.class);
39: if (messageContext == null) {
40: throw new IllegalStateException(
41: "Only calls on the service-endpoint have a MessageContext.");
42: }
43: return messageContext;
44: }
45:
46: public Principal getUserPrincipal() {
47: return this .context.getCallerPrincipal();
48: }
49:
50: public boolean isUserInRole(String roleName) {
51: return this .context.isCallerInRole(roleName);
52: }
53:
54: @SuppressWarnings({"UnusedDeclaration"})
55: public EndpointReference getEndpointReference(
56: org.w3c.dom.Element... referenceParameters) {
57: throw new UnsupportedOperationException(
58: "JaxWS 2.1 APIs are not supported");
59: }
60:
61: @SuppressWarnings({"UnusedDeclaration"})
62: public <T extends EndpointReference> T getEndpointReference(
63: Class<T> clazz, Element... referenceParameters) {
64: throw new UnsupportedOperationException(
65: "JaxWS 2.1 APIs are not supported");
66: }
67: }
|