|
18 | 18 | package org.apache.hadoop.crypto.key.kms; |
19 | 19 |
|
20 | 20 | import org.apache.commons.codec.binary.Base64; |
| 21 | +import org.apache.commons.lang3.StringUtils; |
21 | 22 | import org.apache.hadoop.classification.InterfaceAudience; |
22 | 23 | import org.apache.hadoop.conf.Configuration; |
23 | 24 | import org.apache.hadoop.crypto.key.KeyProvider; |
@@ -561,17 +562,19 @@ private <T> T call(HttpURLConnection conn, Object jsonOutput, |
561 | 562 | } |
562 | 563 | throw ex; |
563 | 564 | } |
| 565 | + |
564 | 566 | if ((conn.getResponseCode() == HttpURLConnection.HTTP_FORBIDDEN |
565 | | - && (conn.getResponseMessage().equals(ANONYMOUS_REQUESTS_DISALLOWED) || |
566 | | - conn.getResponseMessage().contains(INVALID_SIGNATURE))) |
| 567 | + && (!StringUtils.isEmpty(conn.getResponseMessage()) |
| 568 | + && (conn.getResponseMessage().equals(ANONYMOUS_REQUESTS_DISALLOWED) |
| 569 | + || conn.getResponseMessage().contains(INVALID_SIGNATURE)))) |
567 | 570 | || conn.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { |
568 | 571 | // Ideally, this should happen only when there is an Authentication |
569 | 572 | // failure. Unfortunately, the AuthenticationFilter returns 403 when it |
570 | 573 | // cannot authenticate (Since a 401 requires Server to send |
571 | 574 | // WWW-Authenticate header as well).. |
572 | 575 | if (LOG.isDebugEnabled()) { |
573 | | - LOG.debug("Response={}({}), resetting authToken", |
574 | | - conn.getResponseCode(), conn.getResponseMessage()); |
| 576 | + LOG.debug("Response={}, resetting authToken", |
| 577 | + conn.getResponseCode()); |
575 | 578 | } |
576 | 579 | KMSClientProvider.this.authToken = |
577 | 580 | new DelegationTokenAuthenticatedURL.Token(); |
@@ -797,6 +800,7 @@ public EncryptedKeyVersion generateEncryptedKey( |
797 | 800 | @SuppressWarnings("rawtypes") |
798 | 801 | @Override |
799 | 802 | public KeyVersion decryptEncryptedKey( |
| 803 | + |
800 | 804 | EncryptedKeyVersion encryptedKeyVersion) throws IOException, |
801 | 805 | GeneralSecurityException { |
802 | 806 | checkNotNull(encryptedKeyVersion.getEncryptionKeyVersionName(), |
|
0 commit comments