Java Code Examples for io.vertx.ext.auth.authorization.AuthorizationContext#user()

The following examples show how to use io.vertx.ext.auth.authorization.AuthorizationContext#user() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WildcardPermissionBasedAuthorizationImpl.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
@Override
public boolean match(AuthorizationContext context) {
  Objects.requireNonNull(context);

  User user = context.user();
  if (user != null) {
    Authorization resolvedAuthorization = getResolvedAuthorization(context);
    for (String providerId: user.authorizations().getProviderIds()) {
      for (Authorization authorization : user.authorizations().get(providerId)) {
        if (authorization.verify(resolvedAuthorization)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
Example 2
Source File: RoleBasedAuthorizationImpl.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
@Override
public boolean match(AuthorizationContext context) {
  Objects.requireNonNull(context);

  User user = context.user();
  if (user != null) {
    Authorization resolvedAuthorization = getResolvedAuthorization(context);
    for (String providerId: user.authorizations().getProviderIds()) {
      for (Authorization authorization : user.authorizations().get(providerId)) {
        if (authorization.verify(resolvedAuthorization)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
Example 3
Source File: PermissionBasedAuthorizationImpl.java    From vertx-auth with Apache License 2.0 6 votes vote down vote up
@Override
public boolean match(AuthorizationContext context) {
  Objects.requireNonNull(context);

  User user = context.user();
  if (user != null) {
    Authorization resolvedAuthorization = getResolvedAuthorization(context);
    for (String providerId: user.authorizations().getProviderIds()) {
      for (Authorization authorization : user.authorizations().get(providerId)) {
        if (authorization.verify(resolvedAuthorization)) {
          return true;
        }
      }
    }
  }
  return false;
}