use of io.kubernetes.client.models.V1TokenReview in project weblogic-kubernetes-operator by oracle.
the class AuthenticationProxy method check.
/**
* Check if the specified access token can be authenticated
*
* @param principal The user, group or service account.
* @param token The access token that identifies the user.
* @return V1TokenReviewStatus containing either info about the authenticated user or
* an error explaining why the user couldn't be authenticated
*/
public V1TokenReviewStatus check(String principal, String token) {
// Don't expose the token since it's a credential
LOGGER.entering(principal);
V1TokenReview result = null;
try {
boolean allowed = authorizationProxy.check(principal, AuthorizationProxy.Operation.create, AuthorizationProxy.Resource.tokenreviews, null, AuthorizationProxy.Scope.cluster, null);
if (allowed) {
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
result = factory.create().createTokenReview(prepareTokenReview(token));
} else {
LOGGER.info(MessageKeys.CANNOT_CREATE_TOKEN_REVIEW);
}
} catch (ApiException e) {
LOGGER.severe(MessageKeys.APIEXCEPTION_FROM_TOKEN_REVIEW, e);
LOGGER.exiting(null);
return null;
}
LOGGER.info("Returned TokenReview", result);
V1TokenReviewStatus status = result != null ? result.getStatus() : null;
LOGGER.exiting(status);
return status;
}
use of io.kubernetes.client.models.V1TokenReview in project weblogic-kubernetes-operator by oracle.
the class AuthenticationProxy method prepareTokenReview.
private V1TokenReview prepareTokenReview(String token) {
LOGGER.entering();
V1TokenReviewSpec spec = new V1TokenReviewSpec();
spec.setToken(token);
V1TokenReview tokenReview = new V1TokenReview();
tokenReview.setSpec(spec);
// Can't just log token review since it prints out the token, which is sensitive data.
// It doesn't contain any other useful data, so don't log any return info.
LOGGER.exiting();
return tokenReview;
}
use of io.kubernetes.client.models.V1TokenReview in project java by kubernetes-client.
the class AuthenticationV1Api method createTokenReviewWithHttpInfo.
/**
* create a TokenReview
* @param body (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @return ApiResponse<V1TokenReview>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<V1TokenReview> createTokenReviewWithHttpInfo(V1TokenReview body, String pretty) throws ApiException {
com.squareup.okhttp.Call call = createTokenReviewValidateBeforeCall(body, pretty, null, null);
Type localVarReturnType = new TypeToken<V1TokenReview>() {
}.getType();
return apiClient.execute(call, localVarReturnType);
}
use of io.kubernetes.client.models.V1TokenReview in project java by kubernetes-client.
the class AuthenticationV1Api method createTokenReviewAsync.
/**
* (asynchronously)
* create a TokenReview
* @param body (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public com.squareup.okhttp.Call createTokenReviewAsync(V1TokenReview body, String pretty, final ApiCallback<V1TokenReview> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
callback.onDownloadProgress(bytesRead, contentLength, done);
}
};
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
@Override
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
callback.onUploadProgress(bytesWritten, contentLength, done);
}
};
}
com.squareup.okhttp.Call call = createTokenReviewValidateBeforeCall(body, pretty, progressListener, progressRequestListener);
Type localVarReturnType = new TypeToken<V1TokenReview>() {
}.getType();
apiClient.executeAsync(call, localVarReturnType, callback);
return call;
}
use of io.kubernetes.client.models.V1TokenReview in project java by kubernetes-client.
the class AuthenticationV1ApiTest method createTokenReviewTest.
/**
* create a TokenReview
*
* @throws ApiException
* if the Api call fails
*/
@Test
public void createTokenReviewTest() throws ApiException {
V1TokenReview body = null;
String pretty = null;
V1TokenReview response = api.createTokenReview(body, pretty);
// TODO: test validations
}
Aggregations