NamedOperationDetail implements AccessControlledResource, Serializable { public AccessPredicate getReadAccessPredicate() { try { return readAccessPredicateJson != null ? JSONSerialiser.deserialise(readAccessPredicateJson, AccessPredicate.class) : null; } catch (final SerialisationException e) { throw new IllegalArgumentException("readAccessPredicate was not JsonSerialisable", e); } } NamedOperationDetail();  NamedOperationDetail(final String operationName, final String description, final String userId,
                                final String operations, final List<String> readers,
                                final List<String> writers, final Map<String, ParameterDetail> parameters,
                                final Integer score);  NamedOperationDetail(final String operationName, final String inputType, final String description, final String userId,
                                final String operations, final List<String> readers,
                                final List<String> writers, final Map<String, ParameterDetail> parameters,
                                final Integer score);  NamedOperationDetail(final String operationName, final List<String> labels, final String inputType, final String description,
                                final String userId, final String operations, final List<String> readers,
                                final List<String> writers, final Map<String, ParameterDetail> parameters,
                                final Integer score);  NamedOperationDetail(final String operationName, final List<String> labels, final String inputType, final String description,
                                final String userId, final String operations, final List<String> readers,
                                final List<String> writers, final Map<String, ParameterDetail> parameters,
                                final Integer score, final AccessPredicate readAccessPredicate, final AccessPredicate writeAccessPredicate); String getOperationName(); List<String> getLabels(); String getInputType(); void setInputType(final String inputType); String getDescription(); String getOperations(); List<String> getReadAccessRoles(); List<String> getWriteAccessRoles(); String getCreatorId(); Map<String, ParameterDetail> getParameters(); Integer getScore(); @JsonIgnore OperationChain getOperationChainWithDefaultParams(); OperationChain getOperationChain(final Map<String, Object> executionParams); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); @Override ResourceType getResourceType(); boolean hasReadAccess(final User user, final String adminAuth); boolean hasWriteAccess(final User user, final String adminAuth); AccessPredicate getReadAccessPredicate(); AccessPredicate getWriteAccessPredicate();  }
@Test public void shouldDefaultReadAccessPredicateIfNoneSpecified() { final NamedOperationDetail namedOperationDetail = getBaseNamedOperationDetailBuilder().build(); assertEquals( new AccessPredicate(new User.Builder().userId("creatorUserId").build(), asList("readerAuth1", "readerAuth2")), namedOperationDetail.getReadAccessPredicate()); }
@Test public void shouldConfigureCustomReadAccessPredicateWhenSpecified() { final AccessPredicate customAccessPredicate = new AccessPredicate(new CustomUserPredicate()); final NamedOperationDetail namedOperationDetail = getBaseNamedOperationDetailBuilder() .readAccessPredicate(customAccessPredicate) .build(); assertEquals(customAccessPredicate, namedOperationDetail.getReadAccessPredicate()); }
@Test public void shouldDeserialiseCustomAccessPredicate() throws SerialisationException { String json = "{" + " \"operationName\": \"operationName\"," + " \"creatorId\": \"creatorUserId\"," + " \"operationChain\": {\"operations\":[{\"class\":\"uk.gov.gchq.gaffer.operation.impl.get.GetAllElements\"}]}," + " \"readAccessPredicate\": {" + " \"class\": \"uk.gov.gchq.gaffer.access.predicate.AccessPredicate\"," + " \"userPredicate\": {" + " \"class\": \"uk.gov.gchq.gaffer.access.predicate.user.CustomUserPredicate\"" + " }" + " }" + "}"; NamedOperationDetail deserialised = JSONSerialiser.deserialise(json, NamedOperationDetail.class); AccessPredicate expected = new AccessPredicate(new CustomUserPredicate()); assertEquals(expected, deserialised.getReadAccessPredicate()); }