Examples of TCredentials


Examples of org.apache.accumulo.core.security.thrift.TCredentials

    bw.addMutation(defaultTablet);
    bw.close();
   
    // Read out the TabletLocationStates
    MockCurrentState state = new MockCurrentState(new MergeInfo(new KeyExtent(tableId, new Text("p"), new Text("e")), MergeInfo.Operation.MERGE));
    TCredentials auths = CredentialHelper.create("root", new PasswordToken(new byte[0]), "instance");
   
    // Verify the tablet state: hosted, and count
    MetaDataStateStore metaDataStateStore = new MetaDataStateStore(instance, auths, state);
    int count = 0;
    for (TabletLocationState tss : metaDataStateStore) {
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

        } else
          initiateMinor = true;
      }
     
      if (updateMetadata) {
        TCredentials creds = SecurityConstants.getSystemCredentials();
        // if multiple threads were allowed to update this outside of a sync block, then it would be
        // a race condition
        MetadataTable.updateTabletFlushID(extent, tableFlushID, creds, tabletServer.getLock());
      } else if (initiateMinor)
        initiateMinorCompaction(tableFlushID, MinorCompactionReason.USER);
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

      if (extent.isRootTablet()) {
        throw new IllegalArgumentException("Can not import files to root tablet");
      }

      synchronized (bulkFileImportLock) {
        TCredentials auths = SecurityConstants.getSystemCredentials();
        Connector conn;
        try {
          conn = HdfsZooInstance.getInstance().getConnector(auths.getPrincipal(), CredentialHelper.extractToken(auths));
        } catch (Exception ex) {
          throw new IOException(ex);
        }
        // Remove any bulk files we've previously loaded and compacted away
        List<String> files = MetadataTable.getBulkFilesLoaded(conn, extent, tid);
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

      try {
        // the order of writing to !METADATA and walog is important in the face of machine/process failures
        // need to write to !METADATA before writing to walog, when things are done in the reverse order
        // data could be lost... the minor compaction start even should be written before the following metadata
        // write is made
        TCredentials creds = SecurityConstants.getSystemCredentials();
       
        synchronized (timeLock) {
          if (commitSession.getMaxCommittedTime() > persistedTime)
            persistedTime = commitSession.getMaxCommittedTime();
         
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

    deletes = new String[] {"~blip/1636/b-0001", "~del/1636/b-0001/I0000"};
    test1(metadata, deletes, 1, 0);
  }
 
  private void test1(String[] metadata, String[] deletes, int expectedInitial, int expected) throws Exception {
    TCredentials auth = CredentialHelper.create("root", new PasswordToken(new byte[0]), "instance");
   
    Instance instance = new MockInstance();
    FileSystem fs = FileSystem.getLocal(CachedConfiguration.getInstance());
   
    load(instance, metadata, deletes);
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

    gc.confirmDeletes(candidates);
    Assert.assertEquals(expected, candidates.size());
  }
 
  private void load(Instance instance, String[] metadata, String[] deletes) throws Exception {
    TCredentials credential = CredentialHelper.create("root", new PasswordToken(new byte[0]), "instance");
   
    Scanner scanner = instance.getConnector(credential.getPrincipal(), CredentialHelper.extractToken(credential)).createScanner(Constants.METADATA_TABLE_NAME,
        Constants.NO_AUTHS);
    int count = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      count++;
    }
   
    // ensure there is no data from previous test
    Assert.assertEquals(0, count);
   
    Connector conn = instance.getConnector(credential.getPrincipal(), CredentialHelper.extractToken(credential));
    BatchWriter bw = conn.createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
    for (String line : metadata) {
      String[] parts = line.split(" ");
      String[] columnParts = parts[1].split(":");
      Mutation m = new Mutation(parts[0]);
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

public class CredentialHelper {
  static Logger log = Logger.getLogger(CredentialHelper.class);
 
  public static TCredentials create(String principal, AuthenticationToken token, String instanceID) throws AccumuloSecurityException {
    String className = token.getClass().getName();
    return new TCredentials(principal, className, ByteBuffer.wrap(toBytes(token)), instanceID);
  }
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

  public static TCredentials fromByteArray(byte[] serializedCredential) throws AccumuloSecurityException {
    if (serializedCredential == null)
      return null;
    TDeserializer td = new TDeserializer();
    try {
      TCredentials toRet = new TCredentials();
      td.deserialize(toRet, serializedCredential);
      return toRet;
    } catch (TException e) {
      // This really shouldn't happen
      log.error(e, e);
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

   
    writerCache = CacheBuilder.newBuilder().expireAfterAccess(10, TimeUnit.MINUTES).maximumSize(1000).removalListener(new CloseWriter()).build();
  }
 
  protected Connector getConnector(ByteBuffer login) throws Exception {
    TCredentials user = CredentialHelper.fromByteArray(ByteBufferUtil.toBytes(login));
    if (user == null)
      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException("unknown user");
    Connector connector = instance.getConnector(user.getPrincipal(), CredentialHelper.extractToken(user));
    return connector;
  }
View Full Code Here

Examples of org.apache.accumulo.core.security.thrift.TCredentials

 
  @Override
  public ByteBuffer login(String principal, Map<String,String> loginProperties) throws org.apache.accumulo.proxy.thrift.AccumuloSecurityException, TException {
    try {
      AuthenticationToken token = getToken(principal, loginProperties);
      TCredentials credential = CredentialHelper.create(principal, token, instance.getInstanceID());
      ByteBuffer login = ByteBuffer.wrap(CredentialHelper.asByteArray(credential));
      getConnector(login); // check to make sure user exists
      return login;
    } catch (AccumuloSecurityException e) {
      throw new org.apache.accumulo.proxy.thrift.AccumuloSecurityException(e.toString());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.