Skip to content

Commit

Permalink
Change logic to check for transport cert header first
Browse files Browse the repository at this point in the history
  • Loading branch information
imesh94 committed Aug 5, 2024
1 parent 7e762ba commit 771eda8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ private ServletRequest appendTransportHeader(ServletRequest request, ServletResp
if (request instanceof HttpServletRequest) {
Object certAttribute = request.getAttribute(IdentityCommonConstants.JAVAX_SERVLET_REQUEST_CERTIFICATE);
String x509Certificate = ((HttpServletRequest) request).getHeader(IdentityCommonUtil.getMTLSAuthHeader());
if (certAttribute != null) {
if (new IdentityCommonHelper().isTransportCertAsHeaderEnabled() && x509Certificate != null) {
return request;
} else if (certAttribute != null) {
RequestWrapper requestWrapper = new RequestWrapper((HttpServletRequest) request);
X509Certificate certificate = IdentityCommonUtil.getCertificateFromAttribute(certAttribute);
requestWrapper.setHeader(IdentityCommonUtil.getMTLSAuthHeader(),
new IdentityCommonHelper().encodeCertificateContent(certificate));
return requestWrapper;
} else if (new IdentityCommonHelper().isTransportCertAsHeaderEnabled() && x509Certificate != null) {
return request;
} else {
} else {
getDefaultTokenFilter().handleValidationFailure((HttpServletResponse) response,
HttpServletResponse.SC_BAD_REQUEST, IdentityCommonConstants.OAUTH2_INVALID_REQUEST_MESSAGE,
"Transport certificate not found in the request");
Expand Down

0 comments on commit 771eda8

Please sign in to comment.