assertEquals(0, exec(SystemCredentialsIT.class, "good", getCluster().getZooKeepers()).waitFor());
assertEquals(FAIL_CODE, exec(SystemCredentialsIT.class, "bad", getCluster().getZooKeepers()).waitFor());
}
public static void main(final String[] args) throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
Credentials creds = null;
if (args.length < 2)
throw new RuntimeException("Incorrect usage; expected to be run by test only");
if (args[0].equals("bad")) {
creds = new SystemCredentials(new Instance() {
@Deprecated
@Override
public void setConfiguration(AccumuloConfiguration conf) {
throw new UnsupportedOperationException();
}
@Override
public int getZooKeepersSessionTimeOut() {
throw new UnsupportedOperationException();
}
@Override
public String getZooKeepers() {
throw new UnsupportedOperationException();
}
@Override
public String getRootTabletLocation() {
throw new UnsupportedOperationException();
}
@Override
public List<String> getMasterLocations() {
throw new UnsupportedOperationException();
}
@Override
public String getInstanceName() {
throw new UnsupportedOperationException();
}
@Override
public String getInstanceID() {
return SystemCredentials.class.getName();
}
@Override
public Connector getConnector(String principal, AuthenticationToken token) throws AccumuloException, AccumuloSecurityException {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException {
throw new UnsupportedOperationException();
}
@Deprecated
@Override
public AccumuloConfiguration getConfiguration() {
throw new UnsupportedOperationException();
}
});
} else if (args[0].equals("good")) {
creds = SystemCredentials.get();
}
Instance instance = HdfsZooInstance.getInstance();
Connector conn = instance.getConnector(creds.getPrincipal(), creds.getToken());
try {
Scanner scan = conn.createScanner(RootTable.NAME, Authorizations.EMPTY);
for (Entry<Key,Value> e : scan) {
e.hashCode();
}