boolean isAuthorized(final String key, final Activity intent) { boolean result = false; final String grantedActivities = authorities.get(key); if (grantedActivities == null) { LOG.trace("no claim for key [{}]", key); } else { result = grantedActivities.contains(String.valueOf(intent.getCode())) || grantedActivities.equals("*"); LOG.trace("found claim [key: {}, activities: {}] {}matching intent [{}]", key, grantedActivities, result ? "" : "not ", intent.name()); } return result; } }
/** * Adds an authority to execute an operation. * * @param endpoint The endpoint segment of the resource the operation belongs to. * @param tenant The tenant segment of the resource the operation belongs to. * @param operation The operation. * @return This instance for command chaining. */ public AuthoritiesImpl addOperation(final String endpoint, final String tenant, final String operation) { authorities.put(getOperationKey(endpoint, tenant, operation), String.valueOf(Activity.EXECUTE.getCode())); return this; }
/** * Adds an authority to execute an operation. * * @param endpoint The endpoint segment of the resource the operation belongs to. * @param tenant The tenant segment of the resource the operation belongs to. * @param operation The operation. * @return This instance for command chaining. */ public AuthoritiesImpl addOperation(final String endpoint, final String tenant, final String operation) { authorities.put(getOperationKey(endpoint, tenant, operation), String.valueOf(Activity.EXECUTE.getCode())); return this; }
boolean isAuthorized(final String key, final Activity intent) { boolean result = false; final String grantedActivities = authorities.get(key); if (grantedActivities == null) { LOG.trace("no claim for key [{}]", key); } else { result = grantedActivities.contains(String.valueOf(intent.getCode())) || grantedActivities.equals("*"); LOG.trace("found claim [key: {}, activities: {}] {}matching intent [{}]", key, grantedActivities, result ? "" : "not ", intent.name()); } return result; } }
/** * Adds an authority to perform one or more activities on a resource. * * @param endpoint The endpoint segment of the resource. * @param tenant The tenant segment of the resource. * @param activities The activities. * @return This instance for command chaining. */ public AuthoritiesImpl addResource(final String endpoint, final String tenant, final Activity... activities) { final StringBuilder b = new StringBuilder(); for (final Activity a : activities) { b.append(a.getCode()); } authorities.put(getResourceKey(endpoint, tenant), b.toString()); return this; }
/** * Adds an authority to perform one or more activities on a resource. * * @param endpoint The endpoint segment of the resource. * @param tenant The tenant segment of the resource. * @param activities The activities. * @return This instance for command chaining. */ public AuthoritiesImpl addResource(final String endpoint, final String tenant, final Activity... activities) { final StringBuilder b = new StringBuilder(); for (final Activity a : activities) { b.append(a.getCode()); } authorities.put(getResourceKey(endpoint, tenant), b.toString()); return this; }