@Test public void testGetAuthorizationsContainer() { SecurityOperation security = createMock(SecurityOperation.class); TCredentials goodCred = createMock(TCredentials.class); TCredentials badCred = createMock(TCredentials.class); ByteSequence bs = new ArrayByteSequence("foo".getBytes()); List<ByteBuffer> bbList = Collections.singletonList(ByteBuffer.wrap(bs.getBackingArray(), bs.offset(), bs.length())); expect(security.authenticatedUserHasAuthorizations(goodCred, bbList)).andReturn(true); expect(security.authenticatedUserHasAuthorizations(badCred, bbList)).andReturn(false); replay(security); assertTrue( new TservConstraintEnv(null, security, goodCred).getAuthorizationsContainer().contains(bs)); assertFalse( new TservConstraintEnv(null, security, badCred).getAuthorizationsContainer().contains(bs)); }
@Override public AuthorizationContainer getAuthorizationsContainer() { return new AuthorizationContainer() { @Override public boolean contains(ByteSequence auth) { return security.authenticatedUserHasAuthorizations(credentials, Collections .singletonList(ByteBuffer.wrap(auth.getBackingArray(), auth.offset(), auth.length()))); } }; }
TservConstraintEnv implements SystemEnvironment { @Override public AuthorizationContainer getAuthorizationsContainer() { return new AuthorizationContainer() { @Override public boolean contains(ByteSequence auth) { return security.authenticatedUserHasAuthorizations(credentials, Collections .singletonList(ByteBuffer.wrap(auth.getBackingArray(), auth.offset(), auth.length()))); } }; } }
TservConstraintEnv implements SystemEnvironment { @Override public AuthorizationContainer getAuthorizationsContainer() { return new AuthorizationContainer() { @Override public boolean contains(ByteSequence auth) { return security.authenticatedUserHasAuthorizations(credentials, Collections .singletonList(ByteBuffer.wrap(auth.getBackingArray(), auth.offset(), auth.length()))); } }; } TservConstraintEnv(ServerContext context, SecurityOperation secOp, TCredentials credentials); }
TservConstraintEnv implements SystemEnvironment { @Override public AuthorizationContainer getAuthorizationsContainer() { return new AuthorizationContainer() { @Override public boolean contains(ByteSequence auth) { return security.authenticatedUserHasAuthorizations(credentials, Collections .singletonList(ByteBuffer.wrap(auth.getBackingArray(), auth.offset(), auth.length()))); } }; } TservConstraintEnv(ServerContext context, SecurityOperation secOp, TCredentials credentials); void setExtent(KeyExtent ke); @Override KeyExtent getExtent(); @Override String getUser(); @Override AuthorizationContainer getAuthorizationsContainer(); @Override ServerContext getServerContext(); }
TservConstraintEnv implements SystemEnvironment { @Override public AuthorizationContainer getAuthorizationsContainer() { return new AuthorizationContainer() { @Override public boolean contains(ByteSequence auth) { return security.authenticatedUserHasAuthorizations(credentials, Collections .singletonList(ByteBuffer.wrap(auth.getBackingArray(), auth.offset(), auth.length()))); } }; } TservConstraintEnv(ServerContext context, SecurityOperation secOp, TCredentials credentials); void setExtent(KeyExtent ke); @Override KeyExtent getExtent(); @Override String getUser(); @Override AuthorizationContainer getAuthorizationsContainer(); @Override ServerContext getServerContext();  }