Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java
38890 views
/*1* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.ws;2627import java.security.Principal;28import javax.xml.ws.handler.MessageContext;29import javax.xml.ws.wsaddressing.W3CEndpointReference;30import org.w3c.dom.Element;313233/**34* A <code>WebServiceContext</code> makes it possible for35* a web service endpoint implementation class to access36* message context and security information relative to37* a request being served.38*39* Typically a <code>WebServiceContext</code> is injected40* into an endpoint implementation class using the41* <code>Resource</code> annotation.42*43* @since JAX-WS 2.044*45* @see javax.annotation.Resource46**/47public interface WebServiceContext {4849/**50* Returns the <code>MessageContext</code> for the request being served51* at the time this method is called. Only properties with52* APPLICATION scope will be visible to the application.53*54* @return MessageContext The message context.55*56* @throws IllegalStateException This exception is thrown57* if the method is called while no request is58* being serviced.59*60* @see javax.xml.ws.handler.MessageContext61* @see javax.xml.ws.handler.MessageContext.Scope62* @see java.lang.IllegalStateException63**/64public MessageContext getMessageContext();6566/**67* Returns the Principal that identifies the sender68* of the request currently being serviced. If the69* sender has not been authenticated, the method70* returns <code>null</code>.71*72* @return Principal The principal object.73*74* @throws IllegalStateException This exception is thrown75* if the method is called while no request is76* being serviced.77*78* @see java.security.Principal79* @see java.lang.IllegalStateException80**/81public Principal getUserPrincipal();8283/**84* Returns a boolean indicating whether the85* authenticated user is included in the specified86* logical role. If the user has not been87* authenticated, the method returns <code>false</code>.88*89* @param role A <code>String</code> specifying the name of the role90*91* @return a <code>boolean</code> indicating whether92* the sender of the request belongs to a given role93*94* @throws IllegalStateException This exception is thrown95* if the method is called while no request is96* being serviced.97**/98public boolean isUserInRole(String role);99100/**101* Returns the <code>EndpointReference</code> for this102* endpoint.103* <p>104* If the {@link Binding} for this <code>bindingProvider</code> is105* either SOAP1.1/HTTP or SOAP1.2/HTTP, then a106* <code>W3CEndpointReference</code> MUST be returned.107*108* @param referenceParameters Reference parameters to be associated with the109* returned <code>EndpointReference</code> instance.110* @return EndpointReference of the endpoint associated with this111* <code>WebServiceContext</code>.112* If the returned <code>EndpointReference</code> is of type113* <code>W3CEndpointReference</code> then it MUST contain the114* the specified <code>referenceParameters</code>.115*116* @throws IllegalStateException This exception is thrown117* if the method is called while no request is118* being serviced.119*120* @see W3CEndpointReference121*122* @since JAX-WS 2.1123*/124public EndpointReference getEndpointReference(Element... referenceParameters);125126/**127* Returns the <code>EndpointReference</code> associated with128* this endpoint.129*130* @param clazz The type of <code>EndpointReference</code> that131* MUST be returned.132* @param referenceParameters Reference parameters to be associated with the133* returned <code>EndpointReference</code> instance.134* @return EndpointReference of type <code>clazz</code> of the endpoint135* associated with this <code>WebServiceContext</code> instance.136* If the returned <code>EndpointReference</code> is of type137* <code>W3CEndpointReference</code> then it MUST contain the138* the specified <code>referenceParameters</code>.139*140* @throws IllegalStateException This exception is thrown141* if the method is called while no request is142* being serviced.143* @throws WebServiceException If the <code>clazz</code> type of144* <code>EndpointReference</code> is not supported.145*146* @since JAX-WS 2.1147**/148public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,149Element... referenceParameters);150}151152153