@Override
  public boolean authorize(Resource resource, UserContext subject) throws AuthorizationException {
    if (stopped) {
      throw PicketBoxMessages.MESSAGES.instanceAlreadyStopped();
    }
    if (!started) {
      throw PicketBoxMessages.MESSAGES.instanceNotStarted();
    }

    for (String role : this.roleNames) {
      if (subject.hasRole(role)) {
        return true;
      }
    }

    return false;
  }
Esempio n. 2
0
  /* (non-Javadoc)
   * @see javax.servlet.http.HttpServletRequestWrapper#isUserInRole(java.lang.String)
   */
  @Override
  public boolean isUserInRole(String role) {
    UserContext userContext = getUserContext();

    return userContext != null && userContext.hasRole(role);
  }