fix token validation (#2507)

* fix token validation

* add validation to setter as well
This commit is contained in:
Ken Stevens 2021-03-25 14:57:29 -04:00 committed by GitHub
parent 8352bc9c01
commit e2cce4cc90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -20,11 +20,12 @@ package ca.uhn.fhir.rest.client.interceptor;
* #L% * #L%
*/ */
import org.apache.commons.lang3.Validate;
import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.client.api.*; import ca.uhn.fhir.rest.client.api.IClientInterceptor;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.api.IHttpResponse;
import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.CoverageIgnore;
import org.apache.commons.lang3.Validate;
/** /**
* HTTP interceptor to be used for adding HTTP Authorization using "bearer tokens" to requests. Bearer tokens are used for protocols such as OAUTH2 (see the * HTTP interceptor to be used for adding HTTP Authorization using "bearer tokens" to requests. Bearer tokens are used for protocols such as OAUTH2 (see the
@ -57,7 +58,7 @@ public class BearerTokenAuthInterceptor implements IClientInterceptor {
* The bearer token to use (must not be null) * The bearer token to use (must not be null)
*/ */
public BearerTokenAuthInterceptor(String theToken) { public BearerTokenAuthInterceptor(String theToken) {
Validate.notNull("theToken must not be null"); Validate.notNull(theToken, "theToken must not be null");
myToken = theToken; myToken = theToken;
} }
@ -82,6 +83,7 @@ public class BearerTokenAuthInterceptor implements IClientInterceptor {
* Sets the bearer token to use * Sets the bearer token to use
*/ */
public void setToken(String theToken) { public void setToken(String theToken) {
Validate.notNull(theToken, "theToken must not be null");
myToken = theToken; myToken = theToken;
} }