Class OAuthContextUtils
- java.lang.Object
-
- org.apache.cxf.rs.security.oauth2.utils.OAuthContextUtils
-
public final class OAuthContextUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertClient(MessageContext mc, String client)static voidassertRole(MessageContext mc, String role)static OAuthContextgetContext(MessageContext mc)static booleanisUserInRole(MessageContext mc, String role)static StringresolveClient(MessageContext mc)static List<OAuthPermission>resolvePermissions(MessageContext mc)static StringresolveTokenKey(MessageContext mc)static StringresolveUserId(MessageContext mc)static StringresolveUserName(MessageContext mc)static List<String>resolveUserRoles(MessageContext mc)
-
-
-
Method Detail
-
resolveUserId
public static String resolveUserId(MessageContext mc)
- Parameters:
mc- theMessageContext- 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- theMessageContext- 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- theMessageContext- 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- theMessageContextrole- 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- theMessageContextrole- the role to check- Throws:
WebApplicationException- with Status 401 if not authenticatedWebApplicationException- with Status 403 if user doesn't have needed role
-
resolvePermissions
public static List<OAuthPermission> resolvePermissions(MessageContext mc)
- Parameters:
mc- theMessageContext- 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- theMessageContext- Returns:
- the token key used to access
- Throws:
WebApplicationException- with Status 401 if not authenticated
-
resolveClient
public static String resolveClient(MessageContext mc)
- Parameters:
mc- theMessageContext- Returns:
- the client registration id
- Throws:
WebApplicationException- with Status 401 if not authenticated
-
assertClient
public static void assertClient(MessageContext mc, String client)
- Parameters:
mc- theMessageContextclient- 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- theMessageContext- Returns:
- the
OAuthContextof the givenMessageContext - Throws:
WebApplicationException- with Status 401 if not authenticated
-
-