当前位置: 首页>>代码示例>>Java>>正文


Java KerberosTestUtils类代码示例

本文整理汇总了Java中org.apache.hadoop.security.authentication.KerberosTestUtils的典型用法代码示例。如果您正苦于以下问题:Java KerberosTestUtils类的具体用法?Java KerberosTestUtils怎么用?Java KerberosTestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KerberosTestUtils类属于org.apache.hadoop.security.authentication包,在下文中一共展示了KerberosTestUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cancelDelegationToken

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
private void cancelDelegationToken(final String tokenString) throws Exception {

    KerberosTestUtils.doAsClient(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        URL url =
            new URL("http://localhost:8088/ws/v1/cluster/delegation-token");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty(RMWebServices.DELEGATION_TOKEN_HEADER,
          tokenString);
        setupConn(conn, "DELETE", null, null);
        InputStream response = conn.getInputStream();
        assertEquals(Status.OK.getStatusCode(), conn.getResponseCode());
        response.close();
        return null;
      }
    });
  }
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestRMWebServicesDelegationTokenAuthentication.java

示例2: testPutTimelineEntities

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test
public void testPutTimelineEntities() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineClient client = createTimelineClientForUGI();
      TimelineEntity entityToStore = new TimelineEntity();
      entityToStore.setEntityType(
          TestTimelineAuthenticationFilter.class.getName());
      entityToStore.setEntityId("entity1");
      entityToStore.setStartTime(0L);
      TimelinePutResponse putResponse = client.putEntities(entityToStore);
      Assert.assertEquals(0, putResponse.getErrors().size());
      TimelineEntity entityToRead =
          testTimelineServer.getTimelineStore().getEntity(
              "entity1", TestTimelineAuthenticationFilter.class.getName(), null);
      Assert.assertNotNull(entityToRead);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestTimelineAuthenticationFilter.java

示例3: testPutDomains

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test
public void testPutDomains() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineClient client = createTimelineClientForUGI();
      TimelineDomain domainToStore = new TimelineDomain();
      domainToStore.setId(TestTimelineAuthenticationFilter.class.getName());
      domainToStore.setReaders("*");
      domainToStore.setWriters("*");
      client.putDomain(domainToStore);
      TimelineDomain domainToRead =
          testTimelineServer.getTimelineStore().getDomain(
              TestTimelineAuthenticationFilter.class.getName());
      Assert.assertNotNull(domainToRead);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestTimelineAuthenticationFilter.java

示例4: setup

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  // create keytab
  File keytabFile = new File(KerberosTestUtils.getKeytabFile());
  String clientPrincipal = KerberosTestUtils.getClientPrincipal();
  String serverPrincipal = KerberosTestUtils.getServerPrincipal();
  clientPrincipal = clientPrincipal.substring(0, clientPrincipal.lastIndexOf("@"));
  serverPrincipal = serverPrincipal.substring(0, serverPrincipal.lastIndexOf("@"));
  getKdc().createPrincipal(keytabFile, clientPrincipal, serverPrincipal);
  // handler
  handler = getNewAuthenticationHandler();
  Properties props = getDefaultProperties();
  try {
    handler.init(props);
  } catch (Exception ex) {
    handler = null;
    throw ex;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestKerberosAuthenticationHandler.java

示例5: testDynamicPrincipalDiscoveryMissingPrincipals

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test(timeout=60000)
public void testDynamicPrincipalDiscoveryMissingPrincipals() throws Exception {
  String[] keytabUsers = new String[]{"hdfs/localhost"};
  String keytab = KerberosTestUtils.getKeytabFile();
  getKdc().createPrincipal(new File(keytab), keytabUsers);

  // destroy handler created in setUp()
  handler.destroy();
  Properties props = new Properties();
  props.setProperty(KerberosAuthenticationHandler.KEYTAB, keytab);
  props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, "*");
  handler = getNewAuthenticationHandler();
  try {
    handler.init(props);
    Assert.fail("init should have failed");
  } catch (ServletException ex) {
    Assert.assertEquals("Principals do not exist in the keytab",
        ex.getCause().getMessage());
  } catch (Throwable t) {
    Assert.fail("wrong exception: "+t);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestKerberosAuthenticationHandler.java

示例6: testPutTimelineEntities

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test
public void testPutTimelineEntities() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineEntity entityToStore = new TimelineEntity();
      entityToStore.setEntityType(
          TestTimelineAuthenticationFilter.class.getName());
      entityToStore.setEntityId("entity1");
      entityToStore.setStartTime(0L);
      TimelinePutResponse putResponse = client.putEntities(entityToStore);
      Assert.assertEquals(0, putResponse.getErrors().size());
      TimelineEntity entityToRead =
          testTimelineServer.getTimelineStore().getEntity(
              "entity1", TestTimelineAuthenticationFilter.class.getName(), null);
      Assert.assertNotNull(entityToRead);
      return null;
    }
  });
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:21,代码来源:TestTimelineAuthenticationFilter.java

示例7: testPutDomains

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test
public void testPutDomains() throws Exception {
  KerberosTestUtils.doAs(HTTP_USER + "/localhost", new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      TimelineDomain domainToStore = new TimelineDomain();
      domainToStore.setId(TestTimelineAuthenticationFilter.class.getName());
      domainToStore.setReaders("*");
      domainToStore.setWriters("*");
      client.putDomain(domainToStore);
      TimelineDomain domainToRead =
          testTimelineServer.getTimelineStore().getDomain(
              TestTimelineAuthenticationFilter.class.getName());
      Assert.assertNotNull(domainToRead);
      return null;
    }
  });
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:19,代码来源:TestTimelineAuthenticationFilter.java

示例8: setUp

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Before
public void setUp()  throws Exception {
  krbTest.startMiniKdc();

  // create keytab
  File keytabFile = new File(KerberosTestUtils.getKeytabFile());
  String clientPrinc = KerberosTestUtils.getClientPrincipal();
  String serverPrinc = KerberosTestUtils.getServerPrincipal();
  clientPrinc = clientPrinc.substring(0, clientPrinc.lastIndexOf("@"));
  serverPrinc = serverPrinc.substring(0, serverPrinc.lastIndexOf("@"));
  krbTest.getKdc().createPrincipal(keytabFile, clientPrinc, serverPrinc);
  // configure handler
  handler = new MultiSchemeAuthenticationHandler();
  try {
    handler.init(getDefaultProperties());
  } catch (Exception e) {
    throw e;
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:20,代码来源:TestMultiSchemeAuthenticationHandler.java

示例9: getDefaultProperties

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
private Properties getDefaultProperties() {
  Properties p = new Properties();
  p.setProperty(SCHEMES_PROPERTY, BASIC + "," + NEGOTIATE);
  p.setProperty(String.format(AUTH_HANDLER_PROPERTY, "negotiate"),
      "kerberos");
  p.setProperty(String.format(AUTH_HANDLER_PROPERTY, "basic"), "ldap");
  // Kerberos related config
  p.setProperty(PRINCIPAL, KerberosTestUtils.getServerPrincipal());
  p.setProperty(KEYTAB, KerberosTestUtils.getKeytabFile());
  p.setProperty(NAME_RULES,
      "RULE:[1:[email protected]$0](.*@" + KerberosTestUtils.getRealm()+")s/@.*//\n");
  // LDAP related config
  p.setProperty(BASE_DN, LDAP_BASE_DN);
  p.setProperty(PROVIDER_URL, String.format("ldap://%s:%s", LDAP_SERVER_ADDR,
      getLdapServer().getPort()));
  return p;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:18,代码来源:TestMultiSchemeAuthenticationHandler.java

示例10: setUp

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();
  handler = new KerberosAuthenticationHandler();
  Properties props = new Properties();
  props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, KerberosTestUtils.getServerPrincipal());
  props.setProperty(KerberosAuthenticationHandler.KEYTAB, KerberosTestUtils.getKeytabFile());
  props.setProperty(KerberosAuthenticationHandler.NAME_RULES,
                    "RULE:[1:[email protected]$0](.*@" + KerberosTestUtils.getRealm()+")s/@.*//\n");
  try {
    handler.init(props);
  } catch (Exception ex) {
    handler = null;
    throw ex;
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:17,代码来源:TestKerberosAuthenticationHandler.java

示例11: verifyKerberosAuthCreate

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
private void verifyKerberosAuthCreate(String mType, String cType,
    String reqBody, String renUser) throws Exception {
  final String mediaType = mType;
  final String contentType = cType;
  final String body = reqBody;
  final String renewer = renUser;
  KerberosTestUtils.doAsClient(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      ClientResponse response =
          resource().path("ws").path("v1").path("cluster")
            .path("delegation-token").accept(contentType)
            .entity(body, mediaType).post(ClientResponse.class);
      assertEquals(Status.OK, response.getClientResponseStatus());
      DelegationToken tok = getDelegationTokenFromResponse(response);
      assertFalse(tok.getToken().isEmpty());
      Token<RMDelegationTokenIdentifier> token =
          new Token<RMDelegationTokenIdentifier>();
      token.decodeFromUrlString(tok.getToken());
      assertEquals(renewer, token.decodeIdentifier().getRenewer().toString());
      assertValidRMToken(tok.getToken());
      DelegationToken dtoken = new DelegationToken();
      response =
          resource().path("ws").path("v1").path("cluster")
            .path("delegation-token").accept(contentType)
            .entity(dtoken, mediaType).post(ClientResponse.class);
      assertEquals(Status.OK, response.getClientResponseStatus());
      tok = getDelegationTokenFromResponse(response);
      assertFalse(tok.getToken().isEmpty());
      token = new Token<RMDelegationTokenIdentifier>();
      token.decodeFromUrlString(tok.getToken());
      assertEquals("", token.decodeIdentifier().getRenewer().toString());
      assertValidRMToken(tok.getToken());
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestRMWebServicesDelegationTokens.java

示例12: setup

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Before
public void setup() throws Exception {
  // create keytab
  File keytabFile = new File(KerberosTestUtils.getKeytabFile());
  String clientPrincipal = KerberosTestUtils.getClientPrincipal();
  String serverPrincipal = KerberosTestUtils.getServerPrincipal();
  clientPrincipal = clientPrincipal.substring(0, clientPrincipal.lastIndexOf("@"));
  serverPrincipal = serverPrincipal.substring(0, serverPrincipal.lastIndexOf("@"));
  getKdc().createPrincipal(keytabFile, clientPrincipal, serverPrincipal);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestKerberosAuthenticator.java

示例13: getAuthenticationHandlerConfiguration

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
private Properties getAuthenticationHandlerConfiguration() {
  Properties props = new Properties();
  props.setProperty(AuthenticationFilter.AUTH_TYPE, "kerberos");
  props.setProperty(KerberosAuthenticationHandler.PRINCIPAL, KerberosTestUtils.getServerPrincipal());
  props.setProperty(KerberosAuthenticationHandler.KEYTAB, KerberosTestUtils.getKeytabFile());
  props.setProperty(KerberosAuthenticationHandler.NAME_RULES,
                    "RULE:[1:[email protected]$0](.*@" + KerberosTestUtils.getRealm()+")s/@.*//\n");
  return props;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestKerberosAuthenticator.java

示例14: testAuthentication

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test(timeout=60000)
public void testAuthentication() throws Exception {
  final AuthenticatorTestCase auth = new AuthenticatorTestCase(useTomcat);
  AuthenticatorTestCase.setAuthenticationHandlerConfig(
          getAuthenticationHandlerConfiguration());
  KerberosTestUtils.doAsClient(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      auth._testAuthentication(new KerberosAuthenticator(), false);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestKerberosAuthenticator.java

示例15: testAuthenticationPost

import org.apache.hadoop.security.authentication.KerberosTestUtils; //导入依赖的package包/类
@Test(timeout=60000)
public void testAuthenticationPost() throws Exception {
  final AuthenticatorTestCase auth = new AuthenticatorTestCase(useTomcat);
  AuthenticatorTestCase.setAuthenticationHandlerConfig(
          getAuthenticationHandlerConfiguration());
  KerberosTestUtils.doAsClient(new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      auth._testAuthentication(new KerberosAuthenticator(), true);
      return null;
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestKerberosAuthenticator.java


注:本文中的org.apache.hadoop.security.authentication.KerberosTestUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。