01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.jaxws.description.builder;
21:
22: import javax.xml.ws.handler.MessageContext;
23: import java.lang.annotation.Annotation;
24: import java.security.Principal;
25:
26: public class WebServiceContextAnnot implements
27: javax.xml.ws.WebServiceContext {
28:
29: private MessageContext messageContext;
30: private Principal userPrincipal;
31: private boolean isUserInRole = false;
32:
33: /** A WebServiceContextAnnot cannot be instantiated. */
34: private WebServiceContextAnnot() {
35:
36: }
37:
38: private WebServiceContextAnnot(MessageContext messageContext,
39: Principal userPrincipal, boolean isUserInRole) {
40: this .messageContext = messageContext;
41: this .userPrincipal = userPrincipal;
42: this .isUserInRole = isUserInRole;
43: }
44:
45: public static WebServiceContextAnnot createWebServiceConextAnnot() {
46: return new WebServiceContextAnnot();
47: }
48:
49: public static WebServiceContextAnnot createWebServiceContextAnnot(
50: MessageContext messageContext, Principal userPrincipal,
51: boolean isUserInRole) {
52: return new WebServiceContextAnnot(messageContext,
53: userPrincipal, isUserInRole);
54: }
55:
56: /**
57: * @param role The role to check.
58: * @return Returns boolean indicating whether user is in Role
59: */
60: public boolean isUserInRole(String role) {
61: return isUserInRole;
62: }
63:
64: /** @return Returns the messageContext. */
65: public MessageContext getMessageContext() {
66: return messageContext;
67: }
68:
69: /** @return Returns the userPrincipal. */
70: public Principal getUserPrincipal() {
71: return userPrincipal;
72: }
73:
74: /** @param isUserInRole The isUserInRole to set. */
75: public void setUserInRole(boolean isUserInRole) {
76: this .isUserInRole = isUserInRole;
77: }
78:
79: /** @param messageContext The messageContext to set. */
80: public void setMessageContext(MessageContext messageContext) {
81: this .messageContext = messageContext;
82: }
83:
84: /** @param userPrincipal The userPrincipal to set. */
85: public void setUserPrincipal(Principal userPrincipal) {
86: this .userPrincipal = userPrincipal;
87: }
88:
89: //hmm, should we really do this
90: public Class<Annotation> annotationType() {
91: return Annotation.class;
92: }
93:
94: }
|