|
30 | 30 | import org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule;
|
31 | 31 | import org.apache.kafka.common.security.oauthbearer.OAuthBearerValidatorCallback;
|
32 | 32 | import org.apache.kafka.common.utils.Time;
|
| 33 | +import org.apache.kafka.common.utils.Utils; |
33 | 34 | import org.slf4j.Logger;
|
34 | 35 | import org.slf4j.LoggerFactory;
|
35 | 36 |
|
@@ -171,32 +172,23 @@ private void handleCallback(OAuthBearerValidatorCallback callback) {
|
171 | 172 | OAuthBearerValidationUtils.validateTimeConsistency(unsecuredJwt).throwExceptionIfFailed();
|
172 | 173 | OAuthBearerValidationUtils.validateScope(unsecuredJwt, requiredScope).throwExceptionIfFailed();
|
173 | 174 | log.info("Successfully validated token with principal {}: {}", unsecuredJwt.principalName(),
|
174 |
| - unsecuredJwt.claims().toString()); |
| 175 | + unsecuredJwt.claims()); |
175 | 176 | callback.token(unsecuredJwt);
|
176 | 177 | }
|
177 | 178 |
|
178 | 179 | private String principalClaimName() {
|
179 | 180 | String principalClaimNameValue = option(PRINCIPAL_CLAIM_NAME_OPTION);
|
180 |
| - String principalClaimName = principalClaimNameValue != null && !principalClaimNameValue.trim().isEmpty() |
181 |
| - ? principalClaimNameValue.trim() |
182 |
| - : "sub"; |
183 |
| - return principalClaimName; |
| 181 | + return Utils.isBlank(principalClaimNameValue) ? "sub" : principalClaimNameValue.trim(); |
184 | 182 | }
|
185 | 183 |
|
186 | 184 | private String scopeClaimName() {
|
187 | 185 | String scopeClaimNameValue = option(SCOPE_CLAIM_NAME_OPTION);
|
188 |
| - String scopeClaimName = scopeClaimNameValue != null && !scopeClaimNameValue.trim().isEmpty() |
189 |
| - ? scopeClaimNameValue.trim() |
190 |
| - : "scope"; |
191 |
| - return scopeClaimName; |
| 186 | + return Utils.isBlank(scopeClaimNameValue) ? "scope" : scopeClaimNameValue.trim(); |
192 | 187 | }
|
193 | 188 |
|
194 | 189 | private List<String> requiredScope() {
|
195 | 190 | String requiredSpaceDelimitedScope = option(REQUIRED_SCOPE_OPTION);
|
196 |
| - List<String> requiredScope = requiredSpaceDelimitedScope == null || requiredSpaceDelimitedScope.trim().isEmpty() |
197 |
| - ? Collections.emptyList() |
198 |
| - : OAuthBearerScopeUtils.parseScope(requiredSpaceDelimitedScope.trim()); |
199 |
| - return requiredScope; |
| 191 | + return Utils.isBlank(requiredSpaceDelimitedScope) ? Collections.emptyList() : OAuthBearerScopeUtils.parseScope(requiredSpaceDelimitedScope.trim()); |
200 | 192 | }
|
201 | 193 |
|
202 | 194 | private int allowableClockSkewMs() {
|
|
0 commit comments