Search in sources :

Example 1 with GetDelegationTokenResponseProto

use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto in project ozone by apache.

the class OzoneManagerProtocolClientSideTranslatorPB method getDelegationToken.

/**
 * 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);
    }
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) GetDelegationTokenResponseProto(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto) IOException(java.io.IOException) GetDelegationTokenRequestProto(org.apache.hadoop.ozone.security.proto.SecurityProtos.GetDelegationTokenRequestProto) OMException(org.apache.hadoop.ozone.om.exceptions.OMException)

Aggregations

IOException (java.io.IOException)1 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)1 GetDelegationTokenResponseProto (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.GetDelegationTokenResponseProto)1 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1 GetDelegationTokenRequestProto (org.apache.hadoop.ozone.security.proto.SecurityProtos.GetDelegationTokenRequestProto)1