org.apache.cxf.rs.security.oauth2.utils
Class OAuthContextUtils

java.lang.Object
  extended by org.apache.cxf.rs.security.oauth2.utils.OAuthContextUtils

public final class OAuthContextUtils
extends Object


Method Summary
static void assertClient(org.apache.cxf.jaxrs.ext.MessageContext mc, String client)
           
static void assertRole(org.apache.cxf.jaxrs.ext.MessageContext mc, String role)
           
static OAuthContext getContext(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
static boolean isUserInRole(org.apache.cxf.jaxrs.ext.MessageContext mc, String role)
           
static String resolveClient(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
static List<OAuthPermission> resolvePermissions(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
static String resolveTokenKey(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
static String resolveUserName(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
static List<String> resolveUserRoles(org.apache.cxf.jaxrs.ext.MessageContext mc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resolveUserName

public static String resolveUserName(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the name of the UserSubject of the logged in user or resource owner
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

resolveUserRoles

public static List<String> resolveUserRoles(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the list of roles of the logged in user or resource owner
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

isUserInRole

public static boolean isUserInRole(org.apache.cxf.jaxrs.ext.MessageContext mc,
                                   String role)
Parameters:
mc - the MessageContext
role - the user role to check
Returns:
true if user has given role; false otherwise
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

assertRole

public static void assertRole(org.apache.cxf.jaxrs.ext.MessageContext mc,
                              String role)
Parameters:
mc - the MessageContext
role - the role to check
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated
javax.ws.rs.WebApplicationException - with Status 403 if user doesn't have needed role

resolvePermissions

public static List<OAuthPermission> resolvePermissions(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the list of permissions of the used access token
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

resolveTokenKey

public static String resolveTokenKey(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the token key used to access
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

resolveClient

public static String resolveClient(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the client registration id
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated

assertClient

public static void assertClient(org.apache.cxf.jaxrs.ext.MessageContext mc,
                                String client)
Parameters:
mc - the MessageContext
client - the desired client registration id
Throws:
javax.ws.rs.WebApplicationException - with Status 403 if the current client id is not valid

getContext

public static OAuthContext getContext(org.apache.cxf.jaxrs.ext.MessageContext mc)
Parameters:
mc - the MessageContext
Returns:
the OAuthContext of the given MessageContext
Throws:
javax.ws.rs.WebApplicationException - with Status 401 if not authenticated


Apache CXF