Skip to content

Commit

Permalink
BEARER_FLAG
Browse files Browse the repository at this point in the history
  • Loading branch information
martin.cong committed Sep 13, 2023
1 parent 8d266bb commit 5fa19d8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ public interface CredentialVerify {
Key<String> AUTHORIZATION = Metadata.Key.of(HttpConst.AUTHORIZATION_HEADER, Metadata.ASCII_STRING_MARSHALLER);


int TOKEN_INDEX = BEARER_FLAG.length() + 1;

static String bearerToken(Metadata headers) {
var tokenPlace = headers.get(AUTHORIZATION);
String token = null;
if (null != tokenPlace && tokenPlace.startsWith(BEARER_FLAG)) {
token = tokenPlace.substring(BEARER_FLAG.length() + 1);
if (null != tokenPlace
&& tokenPlace.length() > TOKEN_INDEX
&& tokenPlace.startsWith(BEARER_FLAG)) {
token = tokenPlace.substring(TOKEN_INDEX);
}
return token;
}
Expand Down

0 comments on commit 5fa19d8

Please sign in to comment.