Skip to content

Commit d3f9294

Browse files
authored
Merge pull request #447 from microsoftgraph/bugfix/jwt-redaction-error-messages
- fixes a bug where jwts would be shown in error messages
2 parents c3d4d23 + c8c442f commit d3f9294

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/microsoft/graph/http/GraphServiceException.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
import java.util.List;
2929
import java.util.Locale;
3030
import java.util.Map;
31+
import java.util.Collections;
3132

3233
import com.google.gson.Gson;
3334
import com.google.gson.GsonBuilder;
3435
import com.microsoft.graph.core.ClientException;
35-
import com.microsoft.graph.core.GraphErrorCodes;
3636
import com.microsoft.graph.logger.ILogger;
3737
import com.microsoft.graph.logger.LoggerLevel;
3838
import com.microsoft.graph.options.HeaderOption;
@@ -150,8 +150,16 @@ protected GraphServiceException(final String method,
150150
this.responseHeaders = responseHeaders;
151151
this.error = error;
152152
this.verbose = verbose;
153+
for(String requestHeader : requestHeaders) {
154+
for(String headerKeyToRedact : requestHeadersToRedact) {
155+
if(requestHeader.startsWith(headerKeyToRedact)) {
156+
Collections.replaceAll(requestHeaders, requestHeader, headerKeyToRedact + " : [PII_REDACTED]");
157+
break;
158+
}
159+
}
160+
}
153161
}
154-
162+
private static String[] requestHeadersToRedact = {"Authorization"};
155163
/**
156164
* Gets the The HTTP response message
157165
*

0 commit comments

Comments
 (0)