Package org.apache.hadoop.lib.service

Examples of org.apache.hadoop.lib.service.DelegationTokenManager


    Configuration conf = new Configuration(false);
    conf.set("server.services", StringUtils.join(",",
      Arrays.asList(DelegationTokenManagerService.class.getName())));
    Server server = new Server("server", dir, dir, dir, dir, conf);
    server.init();
    DelegationTokenManager tm = server.get(DelegationTokenManager.class);
    Assert.assertNotNull(tm);
    server.destroy();
  }
View Full Code Here


    conf.set("server.services", StringUtils.join(",",
      Arrays.asList(DelegationTokenManagerService.class.getName())));
    HttpFSServerWebApp server = new HttpFSServerWebApp(dir, dir, dir, dir, conf);
    server.setAuthority(new InetSocketAddress(InetAddress.getLocalHost(), 14000));
    server.init();
    DelegationTokenManager tm = server.get(DelegationTokenManager.class);
    Token token = tm.createToken(UserGroupInformation.getCurrentUser(), "foo");
    Assert.assertNotNull(token);
    tm.verifyToken(token);
    Assert.assertTrue(tm.renewToken(token, "foo") > System.currentTimeMillis());
    tm.cancelToken(token, "foo");
    try {
      tm.verifyToken(token);
      Assert.fail();
    } catch (DelegationTokenManagerException ex) {
      //NOP
    } catch (Exception ex) {
      Assert.fail();
View Full Code Here

            MessageFormat.format(
              "Operation [{0}] requires SPNEGO authentication established",
              dtOp));
          requestContinues = false;
        } else {
          DelegationTokenManager tokenManager =
            HttpFSServerWebApp.get().get(DelegationTokenManager.class);
          try {
            Map map = null;
            switch (dtOp) {
              case GETDELEGATIONTOKEN:
                String renewerParam =
                  request.getParameter(HttpFSKerberosAuthenticator.RENEWER_PARAM);
                if (renewerParam == null) {
                  renewerParam = token.getUserName();
                }
                Token<?> dToken = tokenManager.createToken(
                  UserGroupInformation.getCurrentUser(), renewerParam);
                map = delegationTokenToJSON(dToken);
                break;
              case RENEWDELEGATIONTOKEN:
              case CANCELDELEGATIONTOKEN:
                String tokenParam =
                  request.getParameter(HttpFSKerberosAuthenticator.TOKEN_PARAM);
                if (tokenParam == null) {
                  response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                    MessageFormat.format(
                      "Operation [{0}] requires the parameter [{1}]",
                      dtOp, HttpFSKerberosAuthenticator.TOKEN_PARAM));
                  requestContinues = false;
                } else {
                  if (dtOp == DelegationTokenOperation.CANCELDELEGATIONTOKEN) {
                    Token<DelegationTokenIdentifier> dt =
                      new Token<DelegationTokenIdentifier>();
                    dt.decodeFromUrlString(tokenParam);
                    tokenManager.cancelToken(dt,
                      UserGroupInformation.getCurrentUser().getUserName());
                  } else {
                    Token<DelegationTokenIdentifier> dt =
                      new Token<DelegationTokenIdentifier>();
                    dt.decodeFromUrlString(tokenParam);
                    long expirationTime =
                      tokenManager.renewToken(dt, token.getUserName());
                    map = new HashMap();
                    map.put("long", expirationTime);
                  }
                }
                break;
View Full Code Here

    if (delegationParam != null) {
      try {
        Token<DelegationTokenIdentifier> dt =
          new Token<DelegationTokenIdentifier>();
        dt.decodeFromUrlString(delegationParam);
        DelegationTokenManager tokenManager =
          HttpFSServerWebApp.get().get(DelegationTokenManager.class);
        UserGroupInformation ugi = tokenManager.verifyToken(dt);
        final String shortName = ugi.getShortUserName();

        // creating a ephemeral token
        token = new AuthenticationToken(shortName, ugi.getUserName(),
                                        getType());
View Full Code Here

          SchedulerService.class.getName(),
          FileSystemAccessService.class.getName(),
          DelegationTokenManagerService.class.getName())));
    Server server = new HttpFSServerWebApp(dir, dir, dir, dir, conf);
    server.init();
    DelegationTokenManager tm = server.get(DelegationTokenManager.class);
    Assert.assertNotNull(tm);
    server.destroy();
  }
View Full Code Here

    conf.set("server.services", StringUtils.join(",",
      Arrays.asList(DelegationTokenManagerService.class.getName())));
    HttpFSServerWebApp server = new HttpFSServerWebApp(dir, dir, dir, dir, conf);
    server.setAuthority(new InetSocketAddress(InetAddress.getLocalHost(), 14000));
    server.init();
    DelegationTokenManager tm = server.get(DelegationTokenManager.class);
    Token token = tm.createToken(UserGroupInformation.getCurrentUser(), "foo");
    Assert.assertNotNull(token);
    tm.verifyToken(token);
    Assert.assertTrue(tm.renewToken(token, "foo") > System.currentTimeMillis());
    tm.cancelToken(token, "foo");
    try {
      tm.verifyToken(token);
      Assert.fail();
    } catch (DelegationTokenManagerException ex) {
      //NOP
    } catch (Exception ex) {
      Assert.fail();
View Full Code Here

TOP

Related Classes of org.apache.hadoop.lib.service.DelegationTokenManager

Copyright © 2018 www.massapicom. 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.