View Javadoc
1   /*
2    * Copyright 2020 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.example.juddi.embedded;
17  
18  import java.security.Principal;
19  import java.util.Set;
20  import javax.xml.ws.EndpointReference;
21  import javax.xml.ws.WebServiceContext;
22  import javax.xml.ws.handler.MessageContext;
23  import org.w3c.dom.Element;
24  
25  /**
26   *
27   * @author Alex
28   */
29  public class MyWebContext implements WebServiceContext {
30  
31      String user;
32      Set<String> roles;
33  
34      public MyWebContext(String username, Set<String> roles) {
35          this.user = username;
36          this.roles = roles;
37      }
38  
39      @Override
40      public MessageContext getMessageContext() {
41          return null;
42      }
43  
44      @Override
45      public Principal getUserPrincipal() {
46          return new Principal() {
47              @Override
48              public String getName() {
49                  return user;
50              }
51          };
52      }
53  
54      @Override
55      public boolean isUserInRole(String arg0) {
56          return roles.contains(arg0);
57      }
58  
59      @Override
60      public EndpointReference getEndpointReference(Element... arg0) {
61          return null;
62      }
63  
64      @Override
65      public <T extends EndpointReference> T getEndpointReference(Class<T> arg0, Element... arg1) {
66          return null;
67      }
68  
69  }