/** * Returns a {@code ResourceKey} for the given {@code type} and {@code path}. * * @param type the type value of the ResourceKey to be created. * @param path the path value of the ResourceKey to be created. * @return a new ResourceKey. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code type} is empty. */ static ResourceKey newInstance(final CharSequence type, final CharSequence path) { return PoliciesModelFactory.newResourceKey(type, path); }
/** * Creates a {@link ResourceKey} for a Policy containing the passed {@code resourcePath}. * * @param resourcePath the Resource path to use for creating the ResourceKey. * @return the created ResourceKey for Policy. * @throws NullPointerException if {@code resourcePath} is {@code null}. */ public static ResourceKey policyResource(final CharSequence resourcePath) { return PoliciesModelFactory.newResourceKey(POLICY, resourcePath); }
/** * Creates a {@link ResourceKey} for a Message containing the passed {@code resourcePath}. * * @param resourcePath the Resource path to use for creating the ResourceKey. * @return the created ResourceKey for Message. * @throws NullPointerException if {@code resourcePath} is {@code null}. */ public static ResourceKey messageResource(final CharSequence resourcePath) { return PoliciesModelFactory.newResourceKey(MESSAGE, resourcePath); }
/** * Creates a {@link ResourceKey} for a Thing containing the passed {@code resourcePath}. * * @param resourcePath the Resource path to use for creating the ResourceKey. * @return the created ResourceKey for Thing. * @throws NullPointerException if {@code resourcePath} is {@code null}. */ public static ResourceKey thingResource(final CharSequence resourcePath) { return PoliciesModelFactory.newResourceKey(THING, resourcePath); }
/** * Returns a ResourceKey for the given character sequence. The {@code typeWithPath} must contain a * "{@value KEY_DELIMITER}" to separate Resource type and Resource path. * If the given key value is already a ResourceKey, this is immediately properly cast and returned. * * @param typeWithPath the character sequence value of the ResourceKey to be created. * @return a new Label with {@code typeWithPath} as its value. * @throws NullPointerException if {@code typeWithPath} is {@code null}. * @throws IllegalArgumentException if {@code typeWithPath} is empty. */ static ResourceKey newInstance(final CharSequence typeWithPath) { return PoliciesModelFactory.newResourceKey(typeWithPath); }
/** * Removes the resource identified by the specified resource path from this Policy. * * @param label the label identifying the PolicyEntry to modify. * @param resourceType the type of the Resource to remove from the PolicyEntry identified by the {@code label}. * @param resourcePath the path of the Resource to remove from the PolicyEntry identified by the {@code label}. * @return a copy of this Policy with the removed subject. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code label} or {@code resourceType} is empty. */ default Policy removeResourceFor(final CharSequence label, final String resourceType, final CharSequence resourcePath) { return removeResourceFor(label, PoliciesModelFactory.newResourceKey(resourceType, resourcePath)); }
/** * Returns a new {@link Resource} with the specified {@code resourceType}, {@code resourcePath} and * {@code effectedPermissions}. * * @param resourceType the type of the new Resource to create. * @param resourcePath the path of the new Resource to create. * @param effectedPermissions the EffectedPermissions of the new Resource to create. * @return the new {@link Resource}. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code resourceType} is empty. */ public static Resource newResource(final CharSequence resourceType, final CharSequence resourcePath, final EffectedPermissions effectedPermissions) { return newResource(newResourceKey(resourceType, resourcePath), effectedPermissions); }
/** * Returns the {@link EffectedPermissions} for the specified subject ID on the passed resource type and resource * path. * * @param label the label identifying the PolicyEntry to modify. * @param subjectId the Subject ID to get the effected permissions for. * @param resourceType the Resource type to get the effected permissions for. * @param resourcePath the Resource path to get the effected permissions for. * @return the effected permissions which are associated with {@code subject} on the passed {@code resourceType} and * {@code resourcePath}. The returned set is mutable but disjoint from this Policy; thus modifying the set does not * have an impact on this Policy. * @throws NullPointerException if any argument is {@code null}. * @throws IllegalArgumentException if {@code label} or {@code resourceType} is empty. */ default Optional<EffectedPermissions> getEffectedPermissionsFor(final CharSequence label, final SubjectId subjectId, final CharSequence resourceType, final CharSequence resourcePath) { return getEffectedPermissionsFor(label, subjectId, PoliciesModelFactory.newResourceKey(resourceType, resourcePath)); }