/** * @return the name */ @Override public String getName() { return this.role.getName(); }
@Override public String toString() { return getName(); }
/** * Indicates if the given role is in the list of roles. * * @param roles * The list of roles. * @param roleName * The name of the role to look for. * @return True if the list of roles contains the given role. */ protected boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) { return true; } } return false; } }
public static String[] parseScope(List<Role> roles) { String[] scopes = new String[roles.size()]; for (int i = 0; i < roles.size(); i++) { scopes[i] = roles.get(i).getName(); } return scopes; }
/** * Indicates if the given role is in the list of roles. * * @param roles * The list of roles. * @param roleName * The name of the role to look for. * @return True if the list of roles contains the given role. */ protected boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) { return true; } } return false; } }
/** * Indicates if the given role is in the list of roles. * * @param roles * The list of roles. * @param roleName * The name of the role to look for. * @return True if the list of roles contains the given role. */ protected boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) { return true; } } return false; } }
/** * Indicates if the given role is in the list of roles. * * @param roles * The list of roles. * @param roleName * The name of the role to look for. * @return True if the list of roles contains the given role. */ protected boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) { return true; } } return false; } }
/** * Indicates if the given role is in the list of roles. * * @param roles * The list of roles. * @param roleName * The name of the role to look for. * @return True if the list of roles contains the given role. */ protected boolean hasRole(List<Role> roles, String roleName) { for (Role role : roles) { if (role.getName().equals(roleName)) { return true; } } return false; } }
public static String toScope(Role r) throws IllegalArgumentException { String rname = r.getName(); if (rname == null) throw new IllegalArgumentException("Role name cannot be null"); rname = rname.trim(); if (rname.length() < 1) throw new IllegalArgumentException("Role name cannot be empty"); else if (rname.contains(" ")) throw new IllegalArgumentException("Role name cannot contain space"); return rname; }
/** * Returns the highest limit associated to the user's roles. */ @Override public int getLimit(Request request, String countedValue) { // TODO we don't rely on the counted value? int result = 0; List<Role> roles = request.getClientInfo().getRoles(); // iterate over user's roles for (Role role : roles) { if (limitsPerRole.containsKey(role.getName()) && (limitsPerRole.get(role.getName()) > result)) { result = limitsPerRole.get(role.getName()); } } if (result == 0) { result = defaultLimit; } return result; }
/** * Returns the role associated to the given name. * * @param name * The name of the role to find. * @return The role matched or null. */ public Role getRole(String name) { for (Role role : getRoles()) { if (role.getName().equals(name)) { return role; } } return null; }
/** * Returns the highest limit associated to the user's roles. */ @Override public int getLimit(Request request, String countedValue) { // TODO we don't rely on the counted value? int result = 0; List<Role> roles = request.getClientInfo().getRoles(); // iterate over user's roles for (Role role : roles) { if (limitsPerRole.containsKey(role.getName()) && (limitsPerRole.get(role.getName()) > result)) { result = limitsPerRole.get(role.getName()); } } if (result == 0) { result = defaultLimit; } return result; }
/** * Returns the highest limit associated to the user's roles. */ @Override public int getLimit(Request request, String countedValue) { // TODO we don't rely on the counted value? int result = 0; List<Role> roles = request.getClientInfo().getRoles(); // iterate over user's roles for (Role role : roles) { if (limitsPerRole.containsKey(role.getName()) && (limitsPerRole.get(role.getName()) > result)) { result = limitsPerRole.get(role.getName()); } } if (result == 0) { result = defaultLimit; } return result; }
/** * Returns the highest limit associated to the user's roles. */ @Override public int getLimit(Request request, String countedValue) { // TODO we don't rely on the counted value? int result = 0; List<Role> roles = request.getClientInfo().getRoles(); // iterate over user's roles for (Role role : roles) { if (limitsPerRole.containsKey(role.getName()) && (limitsPerRole.get(role.getName()) > result)) { result = limitsPerRole.get(role.getName()); } } if (result == 0) { result = defaultLimit; } return result; }
/** * Returns the highest limit associated to the user's roles. */ @Override public int getLimit(Request request, String countedValue) { // TODO we don't rely on the counted value? int result = 0; List<Role> roles = request.getClientInfo().getRoles(); // iterate over user's roles for (Role role : roles) { if (limitsPerRole.containsKey(role.getName()) && (limitsPerRole.get(role.getName()) > result)) { result = limitsPerRole.get(role.getName()); } } if (result == 0) { result = defaultLimit; } return result; }
public static RestletUtilRole getRoleByName(final String name) { for(final RestletUtilRole nextRole : RestletUtilRoles.values()) { if(nextRole.getRole().getName().equals(name)) { return nextRole; } } return null; }
@Override public int hashCode() { return SystemUtils.hashCode(getApplication(), getName(), getChildRoles()); }
RestletUtilRole standardRole = this.getRoleByName(mapping.getTarget().getName()); if(standardRole != null)
.getRoleByName(nextMapping.getTarget().getName()).getURI()), this.getContexts());