Package org.apache.hadoop.yarn.api.records.timeline

Examples of org.apache.hadoop.yarn.api.records.timeline.TimelineDelegationTokenResponse


        } else {
          TimelineDelegationTokenSecretManagerService secretManager =
              AHSWebApp.getInstance()
                  .getTimelineDelegationTokenSecretManagerService();
          try {
            TimelineDelegationTokenResponse res = null;
            switch (dtOp) {
              case GETDELEGATIONTOKEN:
                UserGroupInformation ownerUGI =
                    UserGroupInformation.createRemoteUser(token.getUserName());
                String renewerParam =
                    request
                        .getParameter(TimelineAuthenticationConsts.RENEWER_PARAM);
                if (renewerParam == null) {
                  renewerParam = token.getUserName();
                }
                Token<?> dToken =
                    secretManager.createToken(ownerUGI, renewerParam);
                res = new TimelineDelegationTokenResponse();
                res.setType(TimelineAuthenticationConsts.DELEGATION_TOKEN_URL);
                res.setContent(dToken.encodeToUrlString());
                break;
              case RENEWDELEGATIONTOKEN:
              case CANCELDELEGATIONTOKEN:
                String tokenParam =
                    request
                        .getParameter(TimelineAuthenticationConsts.TOKEN_PARAM);
                if (tokenParam == null) {
                  response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                      MessageFormat
                          .format(
                              "Operation [{0}] requires the parameter [{1}]",
                              dtOp,
                              TimelineAuthenticationConsts.TOKEN_PARAM));
                  requestContinues = false;
                } else {
                  if (dtOp == TimelineDelegationTokenOperation.CANCELDELEGATIONTOKEN) {
                    Token<TimelineDelegationTokenIdentifier> dt =
                        new Token<TimelineDelegationTokenIdentifier>();
                    dt.decodeFromUrlString(tokenParam);
                    secretManager.cancelToken(dt, token.getUserName());
                  } else {
                    Token<TimelineDelegationTokenIdentifier> dt =
                        new Token<TimelineDelegationTokenIdentifier>();
                    dt.decodeFromUrlString(tokenParam);
                    long expirationTime =
                        secretManager.renewToken(dt, token.getUserName());
                    res = new TimelineDelegationTokenResponse();
                    res.setType(TimelineAuthenticationConsts.DELEGATION_TOKEN_EXPIRATION_TIME);
                    res.setContent(expirationTime);
                  }
                }
                break;
            }
            if (requestContinues) {
View Full Code Here


    AuthenticatedURL aUrl =
        new AuthenticatedURL(new TimelineAuthenticator());
    try {
      HttpURLConnection conn = aUrl.openConnection(url, token);
      conn.setRequestMethod(op.getHttpMethod());
      TimelineDelegationTokenResponse dtRes = validateAndParseResponse(conn);
      if (!dtRes.getType().equals(
          TimelineAuthenticationConsts.DELEGATION_TOKEN_URL)) {
        throw new IOException("The response content is not expected: "
            + dtRes.getContent());
      }
      String tokenStr = dtRes.getContent().toString();
      Token<TimelineDelegationTokenIdentifier> dToken =
          new Token<TimelineDelegationTokenIdentifier>();
      dToken.decodeFromUrlString(tokenStr);
      return dToken;
    } catch (AuthenticationException ex) {
View Full Code Here

        new AuthenticatedURL(new TimelineAuthenticator());
    try {
      HttpURLConnection conn = aUrl.openConnection(url, token);
      conn.setRequestMethod(
          TimelineDelegationTokenOperation.RENEWDELEGATIONTOKEN.getHttpMethod());
      TimelineDelegationTokenResponse dtRes = validateAndParseResponse(conn);
      if (!dtRes.getType().equals(
          TimelineAuthenticationConsts.DELEGATION_TOKEN_EXPIRATION_TIME)) {
        throw new IOException("The response content is not expected: "
            + dtRes.getContent());
      }
      return Long.valueOf(dtRes.getContent().toString());
    } catch (AuthenticationException ex) {
      throw new IOException(ex.toString(), ex);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.api.records.timeline.TimelineDelegationTokenResponse

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.