• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java KerberosAuthenticator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testManagementOperationErrors

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
private void testManagementOperationErrors() throws Exception {
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
  Mockito.when(request.getQueryString()).thenReturn(
      DelegationTokenAuthenticator.OP_PARAM + "=" +
          DelegationTokenAuthenticator.DelegationTokenOperation.
              GETDELEGATIONTOKEN.toString()
  );
  Mockito.when(request.getMethod()).thenReturn("FOO");
  Assert.assertFalse(handler.managementOperation(null, request, response));
  Mockito.verify(response).sendError(
      Mockito.eq(HttpServletResponse.SC_BAD_REQUEST),
      Mockito.startsWith("Wrong HTTP method"));

  Mockito.reset(response);
  Mockito.when(request.getMethod()).thenReturn(
      DelegationTokenAuthenticator.DelegationTokenOperation.
          GETDELEGATIONTOKEN.getHttpMethod()
  );
  Assert.assertFalse(handler.managementOperation(null, request, response));
  Mockito.verify(response).setStatus(
      Mockito.eq(HttpServletResponse.SC_UNAUTHORIZED));
  Mockito.verify(response).setHeader(
      Mockito.eq(KerberosAuthenticator.WWW_AUTHENTICATE),
      Mockito.eq("mock"));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:27,代码来源:TestDelegationTokenAuthenticationHandlerWithMocks.java


示例2: KerberosWebHDFSConnection2

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public KerberosWebHDFSConnection2(String httpfsUrl, String principal, String password)  {
        this.httpfsUrl = httpfsUrl;
        this.principal = principal;
        this.password = password;

        Configuration conf = new Configuration();
        conf.addResource("conf/hdfs-site.xml");
        conf.addResource("conf/core-site.xml");
        newToken = new AuthenticatedURL.Token();

        KerberosAuthenticator ka = new KerberosAuthenticator();
        ConnectionConfigurator connectionConfigurator = new SSLFactory(SSLFactory.Mode.CLIENT,conf);
        ka.setConnectionConfigurator(connectionConfigurator);

        try{
            URL url = new URL(httpfsUrl);
            ka.authenticate(url,newToken);
        }catch(Exception e){
            e.printStackTrace();
        }


         this.authenticatedURL = new AuthenticatedURL(ka,connectionConfigurator);
//        this.authenticatedURL = new AuthenticatedURL(
//                new KerberosAuthenticator2(principal, password));
    }
 
开发者ID:Transwarp-DE,项目名称:Transwarp-Sample-Code,代码行数:27,代码来源:KerberosWebHDFSConnection2.java


示例3: KerberosDelegationTokenAuthenticator

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public KerberosDelegationTokenAuthenticator() {
  super(new KerberosAuthenticator() {
    @Override
    protected Authenticator getFallBackAuthenticator() {
      return new PseudoDelegationTokenAuthenticator();
    }
  });
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:KerberosDelegationTokenAuthenticator.java


示例4: testRequestWithoutAuthorization

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public void testRequestWithoutAuthorization() throws Exception {
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

  Assert.assertNull(handler.authenticate(request, response));
  Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
  Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:9,代码来源:TestKerberosAuthenticationHandler.java


示例5: testRequestWithInvalidAuthorization

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public void testRequestWithInvalidAuthorization() throws Exception {
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

  Mockito.when(request.getHeader(KerberosAuthenticator.AUTHORIZATION)).thenReturn("invalid");
  Assert.assertNull(handler.authenticate(request, response));
  Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
  Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:TestKerberosAuthenticationHandler.java


示例6: testRequestWithoutAuthorization

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public void testRequestWithoutAuthorization() throws Exception {
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

  assertNull(handler.authenticate(request, response));
  Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
  Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:9,代码来源:TestKerberosAuthenticationHandler.java


示例7: testRequestWithInvalidAuthorization

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
public void testRequestWithInvalidAuthorization() throws Exception {
  HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
  HttpServletResponse response = Mockito.mock(HttpServletResponse.class);

  Mockito.when(request.getHeader(KerberosAuthenticator.AUTHORIZATION)).thenReturn("invalid");
  assertNull(handler.authenticate(request, response));
  Mockito.verify(response).setHeader(KerberosAuthenticator.WWW_AUTHENTICATE, KerberosAuthenticator.NEGOTIATE);
  Mockito.verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:10,代码来源:TestKerberosAuthenticationHandler.java


示例8: testPing

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
@Test
public void testPing() throws Exception {
  runTestAsSubject(new TestOperation(){
    @Override
    public void runTestAsSubject() throws Exception {
      final URL url = new URL("http://"+ SERVER_HOST + ":" + webServerPort + "/ping");
      HttpURLConnection conn = new AuthenticatedURL(new KerberosAuthenticator()).
          openConnection(url, new AuthenticatedURL.Token());
      Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
      String response = IOUtils.toString(conn.getInputStream());
      Assert.assertEquals("pong\n", response);
    }} );
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:14,代码来源:TestSentryWebServerWithKerberos.java


示例9: testPingWithoutSubject

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
@Test
public void testPingWithoutSubject() throws Exception {
  final URL url = new URL("http://"+ SERVER_HOST + ":" + webServerPort + "/ping");
  try {
    new AuthenticatedURL(new KerberosAuthenticator()).openConnection(url, new AuthenticatedURL.Token());
    fail("Here should fail.");
  } catch (Exception e) {
    boolean isExpectError = e.getMessage().contains("No valid credentials provided");
    Assert.assertTrue("Here should fail by 'No valid credentials provided'," +
        " but the exception is:" + e, isExpectError);
  }
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:13,代码来源:TestSentryWebServerWithKerberos.java


示例10: testPingWithUnauthorizedUser

import org.apache.hadoop.security.authentication.client.KerberosAuthenticator; //导入依赖的package包/类
@Test
public void testPingWithUnauthorizedUser() throws Exception {
  // create an unauthorized User with Kerberos
  String userPrinciple = "user/" + SERVER_HOST;
  String userKerberosName = userPrinciple + "@" + REALM;
  Subject userSubject = new Subject(false, Sets.newHashSet(
      new KerberosPrincipal(userKerberosName)), new HashSet<Object>(),new HashSet<Object>());
  File userKeytab = new File(kdcWorkDir, "user.keytab");
  kdc.createPrincipal(userKeytab, userPrinciple);
  LoginContext userLoginContext = new LoginContext("", userSubject, null,
      KerberosConfiguration.createClientConfig(userKerberosName, userKeytab));
  userLoginContext.login();
  Subject.doAs(userLoginContext.getSubject(), new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      final URL url = new URL("http://"+ SERVER_HOST + ":" + webServerPort + "/ping");
      try {
        new AuthenticatedURL(new KerberosAuthenticator()).openConnection(url, new AuthenticatedURL.Token());
        fail("Here should fail.");
      } catch (AuthenticationException e) {
        String expectedError = "status code: 403";
        if (!e.getMessage().contains(expectedError)) {
          LOG.error("UnexpectedError: " + e.getMessage(), e);
          fail("UnexpectedError: " + e.getMessage());
        }
      }
      return null;
    }
  });
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:31,代码来源:TestSentryWebServerWithKerberos.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TableEditor类代码示例发布时间:2022-05-21
下一篇:
Java ConversionException类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap