mitreid-connect
静的公開メンバ関数 | 全メンバ一覧
org.mitre.oauth2.web.AuthenticationUtilities クラスabstract
org.mitre.oauth2.web.AuthenticationUtilities 連携図
Collaboration graph

静的公開メンバ関数

static void ensureOAuthScope (Authentication auth, String scope)
 
static boolean isAdmin (Authentication auth)
 
static boolean hasRole (Authentication auth, String role)
 

詳解

Utility class to enforce OAuth scopes in authenticated requests.

著者
jricher

関数詳解

◆ ensureOAuthScope()

static void org.mitre.oauth2.web.AuthenticationUtilities.ensureOAuthScope ( Authentication  auth,
String  scope 
)
inlinestatic

Makes sure the authentication contains the given scope, throws an exception otherwise

引数
auththe authentication object to check
scopethe scope to look for
例外
InsufficientScopeExceptionif the authentication does not contain that scope
41  {
42  // if auth is OAuth, make sure we've got the right scope
43  if (auth instanceof OAuth2Authentication) {
44  OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) auth;
45  if (oAuth2Authentication.getOAuth2Request().getScope() == null
46  || !oAuth2Authentication.getOAuth2Request().getScope().contains(scope)) {
47  throw new InsufficientScopeException("Insufficient scope", ImmutableSet.of(scope));
48  }
49  }
50  }

◆ hasRole()

static boolean org.mitre.oauth2.web.AuthenticationUtilities.hasRole ( Authentication  auth,
String  role 
)
inlinestatic
67  {
68  for (GrantedAuthority grantedAuthority : auth.getAuthorities()) {
69  if (grantedAuthority.getAuthority().equals(role)) {
70  return true;
71  }
72  }
73  return false;
74 
75  }

◆ isAdmin()

static boolean org.mitre.oauth2.web.AuthenticationUtilities.isAdmin ( Authentication  auth)
inlinestatic

Check to see if the given auth object has ROLE_ADMIN assigned to it or not

引数
auth
戻り値
57  {
58  for (GrantedAuthority grantedAuthority : auth.getAuthorities()) {
59  if (grantedAuthority.getAuthority().equals("ROLE_ADMIN")) {
60  return true;
61  }
62  }
63  return false;
64  }

このクラス詳解は次のファイルから抽出されました: