Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Biret <[email protected]>
  • Loading branch information
Ndiritu and baywet authored Sep 11, 2024
1 parent 67047cd commit 293575b
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@

public class AuthorizationHandler implements Interceptor {

@Nonnull
private final BaseBearerTokenAuthenticationProvider authenticationProvider;
private static final String authorizationHeaderKey = "Authorization";

/**
* Instantiates a new AuthorizationHandler.
* @param authenticationProvider the authentication provider.
*/
public AuthorizationHandler(BaseBearerTokenAuthenticationProvider authenticationProvider) {
this.authenticationProvider = authenticationProvider;
public AuthorizationHandler(@Nonnull final BaseBearerTokenAuthenticationProvider authenticationProvider) {
this.authenticationProvider = Objects.requireNonNull(authenticationProvider);
}

@Override
Expand Down Expand Up @@ -64,15 +65,15 @@ public Response intercept(final Chain chain) throws IOException {
}

// Attempt CAE claims challenge
String claims = ContinuousAccessEvaluationClaims.getClaimsFromResponse(response);
final String claims = ContinuousAccessEvaluationClaims.getClaimsFromResponse(response);
if (claims == null || claims.isEmpty()) {
return response;
}

span.addEvent("com.microsoft.kiota.handler.authorization.challenge_received");

// We cannot replay one-shot requests after claims challenge
boolean isRequestBodyOneShot =
final boolean isRequestBodyOneShot =
request != null && request.body() != null && request.body().isOneShot();
if (isRequestBodyOneShot) {
return response;
Expand All @@ -96,9 +97,9 @@ public Response intercept(final Chain chain) throws IOException {
}

private void authenticateRequest(
@Nonnull Request request,
@Nullable Map<String, Object> additionalAuthenticationContext,
@Nonnull Span span) {
@Nonnull final Request request,
@Nullable final Map<String, Object> additionalAuthenticationContext,
@Nonnull final Span span) {
final RequestInformation requestInformation = getRequestInformation(request);
authenticationProvider.authenticateRequest(
requestInformation, additionalAuthenticationContext);
Expand Down

0 comments on commit 293575b

Please sign in to comment.