org.apache.cxf.rs.security.oauth2.utils
Class OAuthContextUtils
java.lang.Object
org.apache.cxf.rs.security.oauth2.utils.OAuthContextUtils
public final class OAuthContextUtils
- extends Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
resolveUserId
public static String resolveUserId(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the id of the UserSubject of the logged in user or resource owner
- Throws:
WebApplicationException
- with Status 401 if not authenticated
resolveUserName
public static String resolveUserName(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the name of the UserSubject of the logged in user or resource owner
- Throws:
WebApplicationException
- with Status 401 if not authenticated
resolveUserRoles
public static List<String> resolveUserRoles(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the list of roles of the logged in user or resource owner
- Throws:
WebApplicationException
- with Status 401 if not authenticated
isUserInRole
public static boolean isUserInRole(MessageContext mc,
String role)
- Parameters:
mc
- the MessageContext
role
- the user role to check
- Returns:
- true if user has given role; false otherwise
- Throws:
WebApplicationException
- with Status 401 if not authenticated
assertRole
public static void assertRole(MessageContext mc,
String role)
- Parameters:
mc
- the MessageContext
role
- the role to check
- Throws:
WebApplicationException
- with Status 401 if not authenticated
WebApplicationException
- with Status 403 if user doesn't have needed role
resolvePermissions
public static List<OAuthPermission> resolvePermissions(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the list of permissions of the used access token
- Throws:
WebApplicationException
- with Status 401 if not authenticated
resolveTokenKey
public static String resolveTokenKey(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the token key used to access
- Throws:
WebApplicationException
- with Status 401 if not authenticated
resolveClient
public static String resolveClient(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the client registration id
- Throws:
WebApplicationException
- with Status 401 if not authenticated
assertClient
public static void assertClient(MessageContext mc,
String client)
- Parameters:
mc
- the MessageContext
client
- the desired client registration id
- Throws:
WebApplicationException
- with Status 403 if the current client id is not valid
getContext
public static OAuthContext getContext(MessageContext mc)
- Parameters:
mc
- the MessageContext
- Returns:
- the
OAuthContext
of the given MessageContext
- Throws:
WebApplicationException
- with Status 401 if not authenticated
Apache CXF