325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.ws.api.server;
325N/A
325N/Aimport com.sun.istack.internal.NotNull;
325N/Aimport com.sun.istack.internal.Nullable;
325N/Aimport com.sun.xml.internal.ws.api.message.Packet;
325N/Aimport com.sun.xml.internal.ws.api.pipe.Pipe;
325N/A
325N/Aimport javax.xml.ws.WebServiceContext;
325N/Aimport javax.xml.ws.WebServiceException;
325N/Aimport java.security.Principal;
325N/A
325N/A/**
325N/A * This object is set to {@link Packet#webServiceContextDelegate}
325N/A * to serve {@link WebServiceContext} methods for a {@link Packet}.
325N/A *
325N/A * <p>
325N/A * When the user application calls a method on {@link WebServiceContext},
325N/A * the JAX-WS RI goes to the {@link Packet} that represents the request,
325N/A * then check {@link Packet#webServiceContextDelegate}, and forwards
325N/A * the method calls to {@link WebServiceContextDelegate}.
325N/A *
325N/A * <p>
325N/A * All the methods defined on this interface takes {@link Packet}
325N/A * (whose {@link Packet#webServiceContextDelegate} points to
325N/A * this object), so that a single stateless {@link WebServiceContextDelegate}
325N/A * can be used to serve multiple concurrent {@link Packet}s,
325N/A * if the implementation wishes to do so.
325N/A *
325N/A * <p>
325N/A * (It is also allowed to create one instance of
325N/A * {@link WebServiceContextDelegate} for each packet,
325N/A * and thus effectively ignore the packet parameter.)
325N/A *
325N/A * <p>
325N/A * Attaching this on a {@link Packet} allows {@link Pipe}s to
325N/A * intercept and replace them, if they wish.
325N/A *
325N/A *
325N/A * @author Kohsuke Kawaguchi
325N/A */
325N/Apublic interface WebServiceContextDelegate {
325N/A /**
325N/A * Implements {@link WebServiceContext#getUserPrincipal()}
325N/A * for the given packet.
325N/A *
325N/A * @param request
325N/A * Always non-null. See class javadoc.
325N/A * @see WebServiceContext#getUserPrincipal()
325N/A */
325N/A Principal getUserPrincipal(@NotNull Packet request);
325N/A
325N/A /**
325N/A * Implements {@link WebServiceContext#isUserInRole(String)}
325N/A * for the given packet.
325N/A *
325N/A * @param request
325N/A * Always non-null. See class javadoc.
325N/A * @see WebServiceContext#isUserInRole(String)
325N/A */
325N/A boolean isUserInRole(@NotNull Packet request,String role);
325N/A
325N/A /**
325N/A * Gets the address of the endpoint.
325N/A *
325N/A * <p>
325N/A * The "address" of endpoints is always affected by a particular
325N/A * client being served, hence it's up to transport to provide this
325N/A * information.
325N/A *
325N/A * @param request
325N/A * Always non-null. See class javadoc.
325N/A * @param endpoint
325N/A * The endpoint whose address will be returned.
325N/A *
325N/A * @throws WebServiceException
325N/A * if this method could not compute the address for some reason.
325N/A * @return
325N/A * Absolute URL of the endpoint. This shold be an address that the client
325N/A * can use to talk back to this same service later.
325N/A *
325N/A * @see WebServiceContext#getEndpointReference
325N/A */
325N/A @NotNull String getEPRAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
325N/A
325N/A /**
325N/A * Gets the address of the primary WSDL.
325N/A *
325N/A * <p>
325N/A * If a transport supports publishing of WSDL by itself (instead/in addition to MEX),
325N/A * then it should implement this method so that the rest of the JAX-WS RI can
325N/A * use that information.
325N/A *
325N/A * For example, HTTP transports often use the convention {@code getEPRAddress()+"?wsdl"}
325N/A * for publishing WSDL on HTTP.
325N/A *
325N/A * <p>
325N/A * Some transports may not have such WSDL publishing mechanism on its own.
325N/A * Those transports may choose to return null, indicating that WSDL
325N/A * is not published. If such transports are always used in conjunction with
325N/A * other transports that support WSDL publishing (such as SOAP/TCP used
325N/A * with Servlet transport), then such transport may
325N/A * choose to find the corresponding servlet endpoint by {@link Module#getBoundEndpoints()}
325N/A * and try to obtain the address from there.
325N/A *
325N/A * <p>
325N/A * This information is used to put a metadata reference inside an EPR,
325N/A * among other things. Clients that do not support MEX rely on this
325N/A * WSDL URL to retrieve metadata, it is desirable for transports to support
325N/A * this, but not mandatory.
325N/A *
325N/A * <p>
325N/A * This method will be never invoked if the {@link WSEndpoint}
325N/A * does not have a corresponding WSDL to begin with
325N/A * (IOW {@link WSEndpoint#getServiceDefinition() returning null}.
325N/A *
325N/A * @param request
325N/A * Always non-null. See class javadoc.
325N/A * @param endpoint
325N/A * The endpoint whose address will be returned.
325N/A *
325N/A * @return
325N/A * null if the implementation does not support the notion of
325N/A * WSDL publishing.
325N/A */
325N/A @Nullable String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
325N/A}