Ejemplo n.º 1
0
  public AuthorizationResult authorize(SecuritySession session, Object permission, Object resource)
      throws AuthorizationException {
    AuthorizationDataSource source = null;

    if (session != null) {
      User user = session.getUser();
      if (user != null) {
        source = new AuthorizationDataSource(user.getPrincipal(), user, permission, resource);
      }
    }

    if (source == null) {
      source = new AuthorizationDataSource(null, null, permission, resource);
    }

    return authorizer.isAuthorized(source);
  }
Ejemplo n.º 2
0
  private void writeCsvRow(PrintWriter out, User user, Map assignmentsMap, List allRoles) {
    out.print(escapeCell(user.getUsername()));
    out.print("," + escapeCell(user.getFullName()));
    out.print("," + escapeCell(user.getEmail()));

    List assignedRoleNames = (List) assignmentsMap.get(user.getPrincipal().toString());
    if (assignedRoleNames == null) {
      assignedRoleNames = new ArrayList();
    }
    Iterator itRoles = allRoles.iterator();
    while (itRoles.hasNext()) {
      Role role = (Role) itRoles.next();
      out.print(',');
      if (assignedRoleNames.contains(role.getName())) {
        out.print('Y');
      }
    }
    out.println();
  }