use of org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties in project accumulo by apache.
the class CredentialProviderTokenTest method missingProviderProperty.
@Test(expected = IllegalArgumentException.class)
public void missingProviderProperty() throws Exception {
CredentialProviderToken token = new CredentialProviderToken();
Properties props = new Properties();
props.put(CredentialProviderToken.CREDENTIAL_PROVIDERS_PROPERTY, keystorePath);
token.init(props);
}
use of org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties in project accumulo by apache.
the class CredentialProviderTokenTest method missingNameProperty.
@Test(expected = IllegalArgumentException.class)
public void missingNameProperty() throws Exception {
CredentialProviderToken token = new CredentialProviderToken();
Properties props = new Properties();
props.put(CredentialProviderToken.NAME_PROPERTY, "root.password");
token.init(props);
}
use of org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties in project accumulo by apache.
the class CredentialProviderTokenTest method testEqualityAfterInit.
@Test
public void testEqualityAfterInit() throws Exception {
if (!isCredentialProviderAvailable) {
return;
}
CredentialProviderToken token = new CredentialProviderToken("root.password", keystorePath);
CredentialProviderToken uninitializedToken = new CredentialProviderToken();
Properties props = new Properties();
props.put(CredentialProviderToken.NAME_PROPERTY, "root.password");
props.put(CredentialProviderToken.CREDENTIAL_PROVIDERS_PROPERTY, keystorePath);
uninitializedToken.init(props);
Assert.assertArrayEquals(token.getPassword(), uninitializedToken.getPassword());
}
use of org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties in project accumulo by apache.
the class CredentialProviderTokenTest method missingProperties.
@Test(expected = IllegalArgumentException.class)
public void missingProperties() throws Exception {
CredentialProviderToken token = new CredentialProviderToken();
token.init(new Properties());
}
use of org.apache.accumulo.core.client.security.tokens.AuthenticationToken.Properties in project accumulo by apache.
the class TraceServer method ensureTraceTableExists.
/**
* Exceptions thrown out of here should be things that cause service failure (e.g. misconfigurations that aren't likely to change on retry).
*
* @return a working Connection that can be reused
* @throws ClassNotFoundException
* if TRACE_TOKEN_TYPE is set to a class that we can't load.
* @throws InstantiationException
* if we fail to create an instance of TRACE_TOKEN_TYPE.
* @throws IllegalAccessException
* if the class pointed to by TRACE_TOKEN_TYPE is private.
* @throws AccumuloSecurityException
* if the trace user has the wrong permissions
*/
private Connector ensureTraceTableExists(final AccumuloConfiguration conf) throws AccumuloSecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException {
Connector connector = null;
while (true) {
try {
final boolean isDefaultTokenType = conf.get(Property.TRACE_TOKEN_TYPE).equals(Property.TRACE_TOKEN_TYPE.getDefaultValue());
String principal = conf.get(Property.TRACE_USER);
if (conf.getBoolean(Property.INSTANCE_RPC_SASL_ENABLED)) {
// Make sure that we replace _HOST if it exists in the principal
principal = SecurityUtil.getServerPrincipal(principal);
}
AuthenticationToken at;
Map<String, String> loginMap = conf.getAllPropertiesWithPrefix(Property.TRACE_TOKEN_PROPERTY_PREFIX);
if (loginMap.isEmpty() && isDefaultTokenType) {
// Assume the old type of user/password specification
Property p = Property.TRACE_PASSWORD;
at = new PasswordToken(conf.get(p).getBytes(UTF_8));
} else {
Properties props = new Properties();
AuthenticationToken token = AccumuloVFSClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class).newInstance();
int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length();
for (Entry<String, String> entry : loginMap.entrySet()) {
props.put(entry.getKey().substring(prefixLength), entry.getValue());
}
token.init(props);
at = token;
}
connector = instance.getConnector(principal, at);
if (!connector.tableOperations().exists(tableName)) {
connector.tableOperations().create(tableName);
IteratorSetting setting = new IteratorSetting(10, "ageoff", AgeOffFilter.class.getName());
AgeOffFilter.setTTL(setting, 7 * 24 * 60 * 60 * 1000l);
connector.tableOperations().attachIterator(tableName, setting);
}
connector.tableOperations().setProperty(tableName, Property.TABLE_FORMATTER_CLASS.getKey(), TraceFormatter.class.getName());
break;
} catch (AccumuloException | TableExistsException | TableNotFoundException | IOException | RuntimeException ex) {
log.info("Waiting to checking/create the trace table.", ex);
sleepUninterruptibly(1, TimeUnit.SECONDS);
}
}
return connector;
}
Aggregations