Java Code Examples for org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto

The following examples show how to use org.apache.hadoop.security.proto.SecurityProtos.GetDelegationTokenRequestProto. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void setupRequest() {
  GetDelegationTokenRequestProto getDelegationTokenRequestProto =
      GetDelegationTokenRequestProto.newBuilder()
      .setRenewer(identifier.getRenewer().toString())
      .build();

  originalRequest = OMRequest.newBuilder()
      .setClientId(UUID.randomUUID().toString())
      .setCmdType(Type.GetDelegationToken)
      .setGetDelegationTokenRequest(getDelegationTokenRequestProto)
      .build();

  omGetDelegationTokenRequest =
      new OMGetDelegationTokenRequest(originalRequest);

  modifiedRequest = null;
}
 
Example 2
@Before
public void setupGetDelegationToken() {
  Text tester = new Text("tester");
  identifier = new OzoneTokenIdentifier(tester, tester, tester);
  identifier.setOmCertSerialId("certID");

  GetDelegationTokenRequestProto getDelegationTokenRequestProto =
      GetDelegationTokenRequestProto.newBuilder()
      .setRenewer(identifier.getRenewer().toString())
      .build();

  OMRequest omRequest = OMRequest.newBuilder()
      .setClientId(UUID.randomUUID().toString())
      .setCmdType(Type.GetDelegationToken)
      .setGetDelegationTokenRequest(getDelegationTokenRequestProto)
      .build();

  updateGetDelegationTokenRequest =
      new OMGetDelegationTokenRequest(omRequest)
          .getOmRequest()
          .getUpdateGetDelegationTokenRequest();
}
 
Example 3
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto req)
    throws ServiceException {
  try {
    Token<DelegationTokenIdentifier> token = server
        .getDelegationToken(new Text(req.getRenewer()));
    GetDelegationTokenResponseProto.Builder rspBuilder = 
        GetDelegationTokenResponseProto.newBuilder();
    if (token != null) {
      rspBuilder.setToken(PBHelper.convert(token));
    }
    return rspBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 4
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto req)
    throws ServiceException {
  try {
    Token<DelegationTokenIdentifier> token = server
        .getDelegationToken(new Text(req.getRenewer()));
    GetDelegationTokenResponseProto.Builder rspBuilder = 
        GetDelegationTokenResponseProto.newBuilder();
    if (token != null) {
      rspBuilder.setToken(PBHelper.convert(token));
    }
    return rspBuilder.build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 5
/**
 * Get a valid Delegation Token.
 *
 * @param renewer the designated renewer for the token
 * @return Token<OzoneDelegationTokenSelector>
 * @throws OMException
 */
@Override
public Token<OzoneTokenIdentifier> getDelegationToken(Text renewer)
    throws OMException {
  GetDelegationTokenRequestProto req = GetDelegationTokenRequestProto
      .newBuilder()
      .setRenewer(renewer == null ? "" : renewer.toString())
      .build();

  OMRequest omRequest = createOMRequest(Type.GetDelegationToken)
      .setGetDelegationTokenRequest(req)
      .build();

  final GetDelegationTokenResponseProto resp;
  try {
    resp =
        handleError(submitRequest(omRequest)).getGetDelegationTokenResponse();
    return resp.getResponse().hasToken() ?
        OMPBHelper.convertToDelegationToken(resp.getResponse().getToken())
        : null;
  } catch (IOException e) {
    if(e instanceof OMException) {
      throw (OMException)e;
    }
    throw new OMException("Get delegation token failed.", e,
        TOKEN_ERROR_OTHER);
  }
}
 
Example 6
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws YarnException, IOException {
  GetDelegationTokenRequestProto requestProto =
      ((GetDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 7
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws YarnException,
    IOException {
  GetDelegationTokenRequestProto requestProto =
      ((GetDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 8
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example 9
Source Project: hadoop   Source File: MRClientProtocolPBServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto proto)
    throws ServiceException {
  GetDelegationTokenRequest request = new GetDelegationTokenRequestPBImpl(proto);
  try {
    GetDelegationTokenResponse response = real.getDelegationToken(request);
    return ((GetDelegationTokenResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 10
Source Project: hadoop   Source File: MRClientProtocolPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl)
      request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example 11
Source Project: hadoop   Source File: ClientNamenodeProtocolTranslatorPB.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
    throws IOException {
  GetDelegationTokenRequestProto req = GetDelegationTokenRequestProto
      .newBuilder()
      .setRenewer(renewer.toString())
      .build();
  try {
    GetDelegationTokenResponseProto resp = rpcProxy.getDelegationToken(null, req);
    return resp.hasToken() ? PBHelper.convertDelegationToken(resp.getToken())
        : null;
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example 12
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws YarnException, IOException {
  GetDelegationTokenRequestProto requestProto =
      ((GetDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 13
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws YarnException,
    IOException {
  GetDelegationTokenRequestProto requestProto =
      ((GetDelegationTokenRequestPBImpl) request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
      null, requestProto));
  } catch (ServiceException e) {
    RPCUtil.unwrapAndThrowException(e);
    return null;
  }
}
 
Example 14
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example 15
Source Project: big-c   Source File: MRClientProtocolPBServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponseProto getDelegationToken(
    RpcController controller, GetDelegationTokenRequestProto proto)
    throws ServiceException {
  GetDelegationTokenRequest request = new GetDelegationTokenRequestPBImpl(proto);
  try {
    GetDelegationTokenResponse response = real.getDelegationToken(request);
    return ((GetDelegationTokenResponsePBImpl)response).getProto();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example 16
Source Project: big-c   Source File: MRClientProtocolPBClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GetDelegationTokenResponse getDelegationToken(
    GetDelegationTokenRequest request) throws IOException {
  GetDelegationTokenRequestProto requestProto = ((GetDelegationTokenRequestPBImpl)
      request).getProto();
  try {
    return new GetDelegationTokenResponsePBImpl(proxy.getDelegationToken(
        null, requestProto));
  } catch (ServiceException e) {
    throw unwrapAndThrowException(e);
  }
}
 
Example 17
Source Project: big-c   Source File: ClientNamenodeProtocolTranslatorPB.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
    throws IOException {
  GetDelegationTokenRequestProto req = GetDelegationTokenRequestProto
      .newBuilder()
      .setRenewer(renewer.toString())
      .build();
  try {
    GetDelegationTokenResponseProto resp = rpcProxy.getDelegationToken(null, req);
    return resp.hasToken() ? PBHelper.convertDelegationToken(resp.getToken())
        : null;
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example 18
Source Project: hadoop-ozone   Source File: OMGetDelegationTokenRequest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public OMRequest preExecute(OzoneManager ozoneManager) throws IOException {
  GetDelegationTokenRequestProto getDelegationTokenRequest =
      getOmRequest().getGetDelegationTokenRequest();

  // Call OM to create token
  Token<OzoneTokenIdentifier> token = ozoneManager
      .getDelegationToken(new Text(getDelegationTokenRequest.getRenewer()));


  // Client issues GetDelegationToken request, when received by OM leader
  // it will generate a token. Original GetDelegationToken request is
  // converted to UpdateGetDelegationToken request with the generated token
  // information. This updated request will be submitted to Ratis. In this
  // way delegation token created by leader, will be replicated across all
  // OMs. With this approach, original GetDelegationToken request from
  // client does not need any proto changes.

  // Create UpdateGetDelegationTokenRequest with token response.

  OMRequest.Builder omRequest;
  if (token != null) {
    omRequest = OMRequest.newBuilder().setUserInfo(getUserInfo())
        .setUpdateGetDelegationTokenRequest(
            UpdateGetDelegationTokenRequest.newBuilder()
                .setGetDelegationTokenResponse(
                    GetDelegationTokenResponseProto.newBuilder()
                        .setResponse(
                            SecurityProtos.GetDelegationTokenResponseProto
                            .newBuilder().setToken(OMPBHelper
                                .convertToTokenProto(token)).build())
                        .build())
                .setTokenRenewInterval(ozoneManager.getDelegationTokenMgr()
                    .getTokenRenewInterval()))
        .setCmdType(getOmRequest().getCmdType())
        .setClientId(getOmRequest().getClientId());


  } else {
    // If token is null, do not set GetDelegationTokenResponse with response.
    omRequest = OMRequest.newBuilder().setUserInfo(getUserInfo())
        .setUpdateGetDelegationTokenRequest(
            UpdateGetDelegationTokenRequest.newBuilder()
                .setGetDelegationTokenResponse(
                    GetDelegationTokenResponseProto.newBuilder()))
        .setCmdType(getOmRequest().getCmdType())
        .setClientId(getOmRequest().getClientId());
  }
  if (getOmRequest().hasTraceID()) {
    omRequest.setTraceID(getOmRequest().getTraceID());
  }
  return omRequest.build();
}
 
Example 19
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl() {
  builder = GetDelegationTokenRequestProto.newBuilder();
}
 
Example 20
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl (
    GetDelegationTokenRequestProto proto) {
  this.proto = proto;
  viaProto = true;
}
 
Example 21
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example 22
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = GetDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example 23
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl() {
  builder = GetDelegationTokenRequestProto.newBuilder();
}
 
Example 24
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl (
    GetDelegationTokenRequestProto proto) {
  this.proto = proto;
  viaProto = true;
}
 
Example 25
Source Project: hadoop   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = GetDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example 26
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl() {
  builder = GetDelegationTokenRequestProto.newBuilder();
}
 
Example 27
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl (
    GetDelegationTokenRequestProto proto) {
  this.proto = proto;
  viaProto = true;
}
 
Example 28
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestProto getProto() {
  mergeLocalToProto();
  proto = viaProto ? proto : builder.build();
  viaProto = true;
  return proto;
}
 
Example 29
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
private void maybeInitBuilder() {
  if (viaProto || builder == null) {
    builder = GetDelegationTokenRequestProto.newBuilder(proto);
  }
  viaProto = false;
}
 
Example 30
Source Project: big-c   Source File: GetDelegationTokenRequestPBImpl.java    License: Apache License 2.0 4 votes vote down vote up
public GetDelegationTokenRequestPBImpl() {
  builder = GetDelegationTokenRequestProto.newBuilder();
}