org.glassfish.jersey.internal.inject
Class SecurityContextInjectee

java.lang.Object
  extended by org.glassfish.jersey.internal.inject.SecurityContextInjectee
All Implemented Interfaces:
SecurityContext

public class SecurityContextInjectee
extends Object
implements SecurityContext

Proxiable wrapper for request scoped SecurityContext instance.

This wrapper must be used and cannot be replaced by ReferencingFactory. The reason is that security context can be set many times during the request processing. However, the HK2 proxy caches the first value that is injected. So, if for example any filter injects security context, then this security context will be cached and it will never be replaced for the same request. On the other hand, HK2 should probably cache the first value returned in the request scope to prevent that two subsequent calls done on the proxy will be forwarded to different object if the the object changes in the meantime.

Author:
Jakub Podlesak (jakub.podlesak at oracle.com)

Field Summary
 
Fields inherited from interface javax.ws.rs.core.SecurityContext
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
SecurityContextInjectee(ContainerRequestContext requestContext)
           
 
Method Summary
 boolean equals(Object that)
           
 String getAuthenticationScheme()
          Returns the string value of the authentication scheme used to protect the resource.
 Principal getUserPrincipal()
          Returns a java.security.Principal object containing the name of the current authenticated user.
 int hashCode()
           
 boolean isSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
 boolean isUserInRole(String role)
          Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityContextInjectee

@Inject
public SecurityContextInjectee(ContainerRequestContext requestContext)
Method Detail

getUserPrincipal

public Principal getUserPrincipal()
Description copied from interface: SecurityContext
Returns a java.security.Principal object containing the name of the current authenticated user. If the user has not been authenticated, the method returns null.

Specified by:
getUserPrincipal in interface SecurityContext
Returns:
a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated

isUserInRole

public boolean isUserInRole(String role)
Description copied from interface: SecurityContext
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.

Specified by:
isUserInRole in interface SecurityContext
Parameters:
role - a String specifying the name of the role
Returns:
a boolean indicating whether the user making the request belongs to a given role; false if the user has not been authenticated

isSecure

public boolean isSecure()
Description copied from interface: SecurityContext
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.

Specified by:
isSecure in interface SecurityContext
Returns:
true if the request was made using a secure channel, false otherwise

getAuthenticationScheme

public String getAuthenticationScheme()
Description copied from interface: SecurityContext
Returns the string value of the authentication scheme used to protect the resource. If the resource is not authenticated, null is returned. Values are the same as the CGI variable AUTH_TYPE

Specified by:
getAuthenticationScheme in interface SecurityContext
Returns:
one of the static members BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH (suitable for == comparison) or the container-specific string indicating the authentication scheme, or null if the request was not authenticated.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object that)
Overrides:
equals in class Object


Copyright © 2007-2014, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.