Package org.apache.hadoop.security

Examples of org.apache.hadoop.security.Credentials.addToken()


    //to cause this one to be set for renew in 2 secs
    Renewer.tokenToRenewIn2Sec = token4;
    LOG.info("token="+token4+" should be renewed for 2 secs");
   
    String nn4 = DelegationTokenRenewer.SCHEME + "://host4:0";
    ts.addToken(new Text(nn4), token4);
   

    ApplicationId applicationId_1 = BuilderUtils.newApplicationId(0, 1);
    delegationTokenRenewer.addApplicationAsync(applicationId_1, ts, true);
    waitForEventsToGetProcessed(delegationTokenRenewer);
View Full Code Here


    MyToken token = dfs.getDelegationToken("user1");
    token.cancelToken();

    Credentials ts = new Credentials();
    ts.addToken(token.getKind(), token);
   
    // register the tokens for renewal
    ApplicationId appId =  BuilderUtils.newApplicationId(0, 0);
    delegationTokenRenewer.addApplicationAsync(appId, ts, true);
    int waitCnt = 20;
View Full Code Here

    //to cause this one to be set for renew in 2 secs
    Renewer.tokenToRenewIn2Sec = token1;
    LOG.info("token="+token1+" should be renewed for 2 secs");
   
    String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
    ts.addToken(new Text(nn1), token1);
   

    ApplicationId applicationId_1 = BuilderUtils.newApplicationId(0, 1);
    delegationTokenRenewer.addApplicationAsync(applicationId_1, ts, false);
    waitForEventsToGetProcessed(delegationTokenRenewer);
View Full Code Here

    Credentials ts = new Credentials();
    // get the delegation tokens
    MyToken token1 = dfs.getDelegationToken("user1");

    String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
    ts.addToken(new Text(nn1), token1);

    // register the tokens for renewal
    ApplicationId applicationId_0 =  BuilderUtils.newApplicationId(0, 0);
    localDtr.addApplicationAsync(applicationId_0, ts, true);
    waitForEventsToGetProcessed(localDtr);
View Full Code Here

    Credentials ts = new Credentials();
    // get the delegation tokens
    MyToken token1 = dfs.getDelegationToken("user1");
   
    String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
    ts.addToken(new Text(nn1), token1);

    // register the tokens for renewal
    ApplicationId applicationId_0 =  BuilderUtils.newApplicationId(0, 0);
    localDtr.addApplicationAsync(applicationId_0, ts, true);
    localDtr.applicationFinished(applicationId_0);
View Full Code Here

    final CyclicBarrier endBarrier = new CyclicBarrier(2);                    
                                                                              
    // this token uses barriers to block during renew                         
    final Credentials creds1 = new Credentials();                             
    final Token<?> token1 = mock(Token.class);                                
    creds1.addToken(new Text("token"), token1);                               
    doReturn(true).when(token1).isManaged();                                  
    doAnswer(new Answer<Long>() {                                             
      public Long answer(InvocationOnMock invocation)                         
          throws InterruptedException, BrokenBarrierException {
        startBarrier.await();                                                 
View Full Code Here

      }}).when(token1).renew(any(Configuration.class));                       
                                                                              
    // this dummy token fakes renewing                                        
    final Credentials creds2 = new Credentials();                             
    final Token<?> token2 = mock(Token.class);                                
    creds2.addToken(new Text("token"), token2);                               
    doReturn(true).when(token2).isManaged();                                  
    doReturn(Long.MAX_VALUE).when(token2).renew(any(Configuration.class));    
                                                                              
    // fire up the renewer                                                    
    final DelegationTokenRenewer dtr =
View Full Code Here

    Assert.assertEquals(expectedTokenCount, delTokens.size());
    Credentials newCredentials = new Credentials();
    for (int i = 0; i < expectedTokenCount / 2; i++) {
      Token<?> token = delTokens.get(i);
      newCredentials.addToken(token.getService(), token);
    }

    List<Token<?>> delTokens2 =
        Arrays.asList(fsView.addDelegationTokens("sanjay", newCredentials));
    Assert.assertEquals((expectedTokenCount + 1) / 2, delTokens2.size());
View Full Code Here

    when(dfs.addDelegationTokens(eq((String) null), any(Credentials.class))).thenAnswer(
        new Answer<Token<?>[]>() {
          @Override
          public Token<?>[] answer(InvocationOnMock invocation) {
            Credentials creds = (Credentials)invocation.getArguments()[1];
            creds.addToken(service, t);
            return new Token<?>[]{t};
          }
        });
    when(dfs.renewDelegationToken(eq(t))).thenReturn(1000L);
    when(dfs.getUri()).thenReturn(uri);
View Full Code Here

      if (UserGroupInformation.isSecurityEnabled()) {
        // Add file-system tokens
        for (Token<? extends TokenIdentifier> token : fsTokens) {
          LOG.info("Putting fs-token for NM use for launching container : "
              + token.toString());
          taskCredentials.addToken(token.getService(), token);
        }
      }

      // LocalStorageToken is needed irrespective of whether security is enabled
      // or not.
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.