@Override public Connector get() { try { Instance inst = new ZooKeeperInstance(instance, zooKeepers); Connector connector = inst.getConnector(username, new PasswordToken(password.getBytes(UTF_8))); LOG.info("Connection to instance %s at %s established, user %s", instance, zooKeepers, username); return connector; } catch (AccumuloException | AccumuloSecurityException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } } }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance( getProperties().getProperty("accumulo.instanceName"), getProperties().getProperty("accumulo.zooKeepers")); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
@Override public void init() throws DBException { colFam = new Text(getProperties().getProperty("accumulo.columnFamily")); colFamBytes = colFam.toString().getBytes(UTF_8); inst = new ZooKeeperInstance(new ClientConfiguration() .withInstance(getProperties().getProperty("accumulo.instanceName")) .withZkHosts(getProperties().getProperty("accumulo.zooKeepers"))); try { String principal = getProperties().getProperty("accumulo.username"); AuthenticationToken token = new PasswordToken(getProperties().getProperty("accumulo.password")); connector = inst.getConnector(principal, token); } catch (AccumuloException | AccumuloSecurityException e) { throw new DBException(e); } if (!(getProperties().getProperty("accumulo.pcFlag", "none").equals("none"))) { System.err.println("Sorry, the ZK based producer/consumer implementation has been removed. " + "Please see YCSB issue #416 for work on adding a general solution to coordinated work."); } }
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
Connector conn = inst.getConnector("root", new PasswordToken("")); conn.tableOperations().create(table.getFullTableName()); conn.tableOperations().create(table.getIndexTableName());
/** * Gets the AccumuloConnector singleton, starting the MiniAccumuloCluster on initialization. * This singleton instance is required so all test cases access the same MiniAccumuloCluster. * * @return Accumulo connector */ public static Connector getAccumuloConnector() { if (connector != null) { return connector; } try { MiniAccumuloCluster accumulo = createMiniAccumuloCluster(); Instance instance = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers()); connector = instance.getConnector(MAC_USER, new PasswordToken(MAC_PASSWORD)); LOG.info("Connection to MAC instance %s at %s established, user %s password %s", accumulo.getInstanceName(), accumulo.getZooKeepers(), MAC_USER, MAC_PASSWORD); return connector; } catch (AccumuloException | AccumuloSecurityException | InterruptedException | IOException e) { throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to get connector to Accumulo", e); } }
/** * Returns a connection to this instance of accumulo. * * @param user * a valid accumulo user * @param pass * If a mutable CharSequence is passed in, it may be cleared after this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, CharSequence pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
/** * Returns a connection to accumulo. * * @param user * a valid accumulo user * @param pass * A UTF-8 encoded password. The password may be cleared after making this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, byte[] pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
/** * Returns a connection to accumulo. * * @param user * a valid accumulo user * @param pass * A UTF-8 encoded password. The password may be cleared after making this call. * @return the accumulo Connector * @throws AccumuloException * when a generic exception occurs * @throws AccumuloSecurityException * when a user's credentials are invalid * @deprecated since 1.5, use {@link #getConnector(String, AuthenticationToken)} with * {@link PasswordToken} */ @Deprecated default Connector getConnector(String user, ByteBuffer pass) throws AccumuloException, AccumuloSecurityException { return getConnector(user, new PasswordToken(pass)); }
@Override public void changeLocalUserPassword(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException { PasswordToken token = new PasswordToken(password); Credentials toChange = new Credentials(principal, token); security.changePassword(credentials, toChange); }
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { // save old credentials and connection in case of failure String user = cl.getArgs()[0]; byte[] pass; // We can't let the wrapping try around the execute method deal // with the exceptions because we have to do something if one // of these methods fails final String p = shellState.readMaskedLine("Enter password for user " + user + ": ", '*'); if (p == null) { shellState.getReader().println(); return 0; } // user canceled pass = p.getBytes(UTF_8); shellState.updateUser(user, new PasswordToken(pass)); return 0; }
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "code runs in same security context as user who providing the token file") public static AuthenticationToken getAuthenticationToken(Properties properties) { String authType = ClientProperty.AUTH_TYPE.getValue(properties); String token = ClientProperty.AUTH_TOKEN.getValue(properties); switch (authType) { case "password": return new PasswordToken(token); case "PasswordToken": return decodeToken(PasswordToken.class.getName(), token); case "kerberos": try { String principal = ClientProperty.AUTH_PRINCIPAL.getValue(properties); return new KerberosToken(principal, new File(token)); } catch (IOException e) { throw new IllegalArgumentException(e); } case "KerberosToken": return decodeToken(KerberosToken.class.getName(), token); case "CredentialProviderToken": return decodeToken(CredentialProviderToken.class.getName(), token); case "DelegationToken": return decodeToken(DelegationToken.class.getName(), token); default: return decodeToken(authType, token); } }
@Override public void createLocalUser(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException { AuthenticationToken token; if (context.getSaslParams() != null) { try { token = new KerberosToken(); } catch (IOException e) { log.warn("Failed to create KerberosToken"); throw new ThriftSecurityException(e.getMessage(), SecurityErrorCode.DEFAULT_SECURITY_ERROR); } } else { token = new PasswordToken(password); } Credentials newUser = new Credentials(principal, token); security.createUser(credentials, newUser, new Authorizations()); }
PasswordToken token = new PasswordToken(password); ClientContext peerContext = getContextForPeer(localConf, target, principal, token); return _replicate(p, status, target, helper, localConf, peerContext, null);
@Override public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws AccumuloException, AccumuloSecurityException, IOException { final String user = cl.getArgs()[0]; final String p = shellState.readMaskedLine("Enter current password for '" + user + "': ", '*'); if (p == null) { shellState.getReader().println(); return 0; } // user canceled final byte[] password = p.getBytes(UTF_8); final boolean valid = shellState.getAccumuloClient().securityOperations().authenticateUser(user, new PasswordToken(password)); shellState.getReader().println((valid ? "V" : "Not v") + "alid"); return 0; }
PasswordToken passwordToken; if (userToken instanceof KerberosToken) { passwordToken = new PasswordToken(); } else { final String password = shellState.readMaskedLine("Enter new password for '" + user + "': ", throw new IllegalArgumentException("Passwords do not match"); passwordToken = new PasswordToken(password);
new PasswordToken(oldPassword))) throw new AccumuloSecurityException(user, SecurityErrorCode.BAD_CREDENTIALS); new PasswordToken(pass)); shellState.updateUser(user, new PasswordToken(pass));
if (loginMap.isEmpty()) { Property p = Property.TRACE_PASSWORD; at = new PasswordToken(conf.get(p).getBytes(UTF_8)); } else { Properties props = new Properties(); Property.TRACE_TOKEN_TYPE, AuthenticationToken.class, new PasswordToken()); token.init(props); at = token;
at = new PasswordToken(conf.get(p).getBytes(UTF_8)); } else { Properties props = new Properties();