@Override public EntityId apply(VisibilityKey input) { return input.getEntityId(); } };
AbstractAuthorizationEnforcer(CConfiguration cConf) { this.securityAuthorizationEnabled = AuthorizationUtil.isSecurityAuthorizationEnabled(cConf); }
@Override public void enforce(EntityId entity, Principal principal, Action action) throws Exception { if (!isSecurityAuthorizationEnabled()) { return; } doEnforce(entity, principal, Collections.singleton(action)); }
/** * Returns an {@link Authorizer} for performing authorization operations. */ @Beta protected static Authorizer getAuthorizer() throws IOException, InvalidAuthorizerException { return authorizerInstantiator.get(); }
@Override public AuthorizationContext create(Properties extensionProperties) { return new DefaultAuthorizationContext(extensionProperties, new NoOpDatasetContext(), new NoopAdmin(), new NoOpTransactional(), new AuthenticationTestContext(), new DummySecureStoreService()); }
@Override protected Authorizer get() { return new InMemoryAuthorizer(); } }
@Override public void revoke(Authorizable authorizable, Principal principal, Set<Action> actions) throws Exception { LOG.trace("Making request to revoke {} on {} to {}", actions, authorizable, principal); executeRequest("revoke", authorizable, principal, actions); LOG.debug("Revoked {} on {} to {} successfully", actions, authorizable, principal); }
@AuthEnforce(entities = "someEntity", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testNoParameters() throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); }
@Override public void enforce(EntityId entity, Principal principal, Action action) throws Exception { throw new ExpectedException(entity); }
AuthorizerClassLoader(File unpackedJarDir, @Nullable String authorizerExtraClasspath) { super(unpackedJarDir, authorizerExtraClasspath, createParent(), "lib"); } }
private void testRewrite(Method method, Object rewrittenObject, Class<? extends Exception> expectedException, Object... args) throws NoSuchMethodException { testRewrite(method, rewrittenObject, null, expectedException, args); }
@Override public void revoke(Authorizable authorizable, Principal principal, Set<Action> actions) throws Exception { getActions(authorizable, principal).removeAll(actions); }
private void testInvalidEntityHelper(Class cls) throws Exception { try { rewrite(cls); Assert.fail("An IllegalArgumentException should have been thrown earlier."); } catch (IllegalArgumentException e) { // expected } }
@After public void after() throws Exception { ((RemoteAuthorizationEnforcer) authorizationEnforcer).clearCache(); }
/** * Returns an {@link Authorizer} for performing authorization operations. */ @Beta protected static Authorizer getAuthorizer() throws IOException, InvalidAuthorizerException { return authorizerInstantiator.get(); }
@Override public void grant(Authorizable authorizable, Principal principal, Set<Action> actions) throws Exception { LOG.trace("Making request to grant {} on {} to {}", actions, authorizable, principal); executeRequest("grant", authorizable, principal, actions); LOG.debug("Granted {} on {} to {} successfully", actions, authorizable, principal); }
@AuthEnforce(entities = "someEntity", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testParaNameSameAsField(NamespaceId someEntity) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); }
@Override public void enforce(EntityId entity, Principal principal, Set<Action> actions) throws Exception { throw new ExpectedException(entity); }
@Override public void revoke(Authorizable authorizable) throws Exception { LOG.trace("Making request to revoke all actions on {}", authorizable); executeRequest("revokeAll", authorizable); LOG.debug("Revoked all actions on {} successfully", authorizable); }
@Override public void interfaceMethodWithAuthEnforce(@Name("namespaceId") NamespaceId namespaceId) throws Exception { throw new EnforceNotCalledException(); } }