WebServiceContext (Java EE 5)

Java EE API


javax.xml.ws Interface WebServiceContext


public interface WebServiceContext


WebServiceContext 能使 Web 服务端点实现类访问与服务的请求有关的消息上下文和安全信息。 通常,使用 Resource 注释将 WebServiceContext 注入到端点实现类中。
英文文档:

A WebServiceContext makes it possible for a web service endpoint implementation class to access message context and security information relative to a request being served. Typically a WebServiceContext is injected into an endpoint implementation class using the Resource annotation.

Since:
JAX-WS 2.0
See Also:
Resource

Method Summary
 MessageContext
 Principal
 boolean
 

Method Detail

public MessageContext getMessageContext()
调用此方法时,返回正在服务的请求的 MessageContext。应用程序只能看到具有 APPLICATION 作用域的属性。
return MessageContext 消息上下文。
ThrowsIllegalStateException: 如果调用该方法但不存在任何正被服务的请求,则抛出该异常。
See also javax.xml.ws.handler.MessageContext, javax.xml.ws.handler.MessageContext.Scope, java.lang.IllegalStateException
英文文档:

getMessageContext

MessageContext getMessageContext()
Returns the MessageContext for the request being served at the time this method is called. Only properties with APPLICATION scope will be visible to the application.

Returns:
MessageContext The message context.
Throws:
IllegalStateException - This exception is thrown if the method is called while no request is being serviced.
See Also:
MessageContext, MessageContext.Scope, IllegalStateException

public java.security.Principal getUserPrincipal()
返回标识当前正服务请求发送方的 Principal。如果发送方没有经过验证,则该方法返回 null
return Principal 主体对象。
ThrowsIllegalStateException: 如果调用该方法但不存在任何正被服务的请求,则抛出该异常。
See also java.security.Principal, java.lang.IllegalStateException
英文文档:

getUserPrincipal

Principal getUserPrincipal()
Returns the Principal that identifies the sender of the request currently being serviced. If the sender has not been authenticated, the method returns null.

Returns:
Principal The principal object.
Throws:
IllegalStateException - This exception is thrown if the method is called while no request is being serviced.
See Also:
Principal, IllegalStateException

public boolean isUserInRole(String role)
返回一个布尔值,指示指定的逻辑角色中是否包含经过验证的用户。如果用户没有经过验证,则该方法返回 false。
role 指定角色名称的 String
return 一个 boolean 值,指示请求的发送方是否属于给定角色
ThrowsIllegalStateException: 如果调用该方法但不存在任何正被服务的请求,则抛出该异常。
英文文档:

isUserInRole

boolean isUserInRole(String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical role. If the user has not been authenticated, the method returns false.

Parameters:
role - A String specifying the name of the role
Returns:
a boolean indicating whether the sender of the request belongs to a given role
Throws:
IllegalStateException - This exception is thrown if the method is called while no request is being serviced.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!