Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/273#discussion_r124118903
  
    --- Diff: 
test/src/test/java/org/apache/accumulo/test/functional/KerberosProxyIT.java ---
    @@ -463,6 +477,56 @@ public void testMismatchPrincipals() throws Exception {
         }
       }
     
    +  @Test
    +  public void proxiedUserAccessWithoutAccumuloProxy() throws Exception {
    +    final String tableName = getUniqueNames(1)[0];
    +    ClusterUser rootUser = kdc.getRootUser();
    +    final UserGroupInformation rootUgi = 
UserGroupInformation.loginUserFromKeytabAndReturnUGI(rootUser.getPrincipal(), 
rootUser.getKeytab().getAbsolutePath());
    +    final UserGroupInformation realUgi = 
UserGroupInformation.loginUserFromKeytabAndReturnUGI(proxyPrincipal, 
proxyKeytab.getAbsolutePath());
    +    final String userWithoutCredentials = kdc.qualifyUser(PROXIED_USER);
    +    final UserGroupInformation proxyUser = 
UserGroupInformation.createProxyUser(userWithoutCredentials, realUgi);
    +
    +    // Create a table and user, grant permission to our user to read that 
table.
    +    rootUgi.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new 
ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(rootUgi.getUserName(), new 
KerberosToken());
    +        conn.tableOperations().create(tableName);
    +        conn.securityOperations().createLocalUser(userWithoutCredentials, 
new PasswordToken("ignored"));
    +        
conn.securityOperations().grantTablePermission(userWithoutCredentials, 
tableName, TablePermission.READ);
    +        return null;
    +      }
    +    });
    +    realUgi.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new 
ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(proxyPrincipal, new 
KerberosToken());
    +        try {
    +          Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
    +          s.iterator().hasNext();
    +          Assert.fail("Expected to see an exception");
    +        } catch (RuntimeException e) {
    +          int numSecurityExceptionsSeen = 
Iterables.size(Iterables.filter(Throwables.getCausalChain(e),
    +              
org.apache.accumulo.core.client.AccumuloSecurityException.class));
    +          assertTrue("Expected to see at least one 
AccumuloSecurityException, but saw: " + Throwables.getStackTraceAsString(e), 
numSecurityExceptionsSeen > 0);
    +        }
    +        return null;
    +      }
    +    });
    +    proxyUser.doAs(new PrivilegedExceptionAction<Void>() {
    +      @Override
    +      public Void run() throws Exception {
    +        ZooKeeperInstance inst = new 
ZooKeeperInstance(mac.getClientConfig());
    +        Connector conn = inst.getConnector(userWithoutCredentials, new 
KerberosToken(userWithoutCredentials));
    +        Scanner s = conn.createScanner(tableName, Authorizations.EMPTY);
    +        assertFalse(s.iterator().hasNext());
    +        return null;
    --- End diff --
    
    Sadly, it cannot. It would be a compilation error. We cannot do 
`PrivilegedExceptionAction<void>`, only `Void`. As such, we need to have an 
explicit return value (it's annoying :D)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to