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 at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * 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 and14 * limitations under the License.15 */16package org.apache.juddi.example.juddi.embedded;
1718import java.security.Principal;
19import java.util.Set;
20import javax.xml.ws.EndpointReference;
21import javax.xml.ws.WebServiceContext;
22import javax.xml.ws.handler.MessageContext;
23import org.w3c.dom.Element;
2425/**26 *27 * @author Alex28 */29publicclassMyWebContextimplements WebServiceContext {
3031 String user;
32 Set<String> roles;
3334publicMyWebContext(String username, Set<String> roles) {
35this.user = username;
36this.roles = roles;
37 }
3839 @Override
40public MessageContext getMessageContext() {
41returnnull;
42 }
4344 @Override
45public Principal getUserPrincipal() {
46returnnew Principal() {
47 @Override
48public String getName() {
49return user;
50 }
51 };
52 }
5354 @Override
55publicboolean isUserInRole(String arg0) {
56return roles.contains(arg0);
57 }
5859 @Override
60public EndpointReference getEndpointReference(Element... arg0) {
61returnnull;
62 }
6364 @Override
65public <T extends EndpointReference> T getEndpointReference(Class<T> arg0, Element... arg1) {
66returnnull;
67 }
6869 }