Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Mutual TLS failure[WIP] #1258

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public boolean handleResponse(org.apache.synapse.MessageContext messageContext)
private String getDeviceType(String url) {
StringTokenizer parts = new StringTokenizer(url, "/");
while (parts.hasMoreElements()) {
if (parts.nextElement().equals("api")) {
if (parts.nextElement().equals("device-mgt")) {
return (String) parts.nextElement();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void testHandleSuccessfulRequestMDMCertificate() throws Exception {
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(getValidationResponse());
boolean response = this.handler.handleRequest(createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice"));
transportHeaders, "https://test.com/testservice/device-mgt/testdevice"));
Assert.assertTrue(response);
this.mockClient.reset();
}
Expand All @@ -110,7 +110,7 @@ public void testHandleSuccessRequestProxyMutualAuthHeader() throws Exception {
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(getValidationResponse());
boolean response = this.handler.handleRequest(createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice"));
transportHeaders, "https://test.com/testservice/device-mgt/testdevice"));
Assert.assertTrue(response);
this.mockClient.reset();
}
Expand All @@ -124,7 +124,7 @@ public void testHandleSuccessRequestMutualAuthHeader() throws Exception {
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(getValidationResponse());
MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice");
transportHeaders, "https://test.com/testservice/device-mgt/testdevice");
org.apache.axis2.context.MessageContext axisMC = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
String certStr = getContent(TestUtils.getAbsolutePathOfConfig("ra_cert.pem"));
X509Certificate cert = X509Certificate.getInstance(new ByteArrayInputStream(certStr.
Expand All @@ -144,7 +144,7 @@ public void testHandleSuccessRequestEncodedPem() throws Exception {
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(getValidationResponse());
MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice");
transportHeaders, "https://test.com/testservice/device-mgt/testdevice");
boolean response = this.handler.handleRequest(messageContext);
Assert.assertTrue(response);
this.mockClient.reset();
Expand All @@ -159,7 +159,7 @@ public void testHandleSuccessRequestEncodedPemInvalidResponse() throws Exception
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(getInvalidResponse());
MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice");
transportHeaders, "https://test.com/testservice/device-mgt/testdevice");
boolean response = this.handler.handleRequest(messageContext);
Assert.assertFalse(response);
this.mockClient.reset();
Expand All @@ -173,7 +173,7 @@ public void testHandleRequestWithCertMgmtException() throws Exception {
setMockClient();
this.mockClient.setResponse(null);
MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice");
transportHeaders, "https://test.com/testservice/device-mgt/testdevice");
boolean response = this.handler.handleRequest(messageContext);
Assert.assertFalse(response);
this.mockClient.reset();
Expand All @@ -188,7 +188,7 @@ public void testHandleRequestWithIOException() throws Exception {
this.mockClient.setResponse(getAccessTokenReponse());
this.mockClient.setResponse(null);
MessageContext messageContext = createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice");
transportHeaders, "https://test.com/testservice/device-mgt/testdevice");
boolean response = this.handler.handleRequest(messageContext);
Assert.assertFalse(response);
this.mockClient.reset();
Expand All @@ -202,7 +202,7 @@ public void testHandleRequestWithURIException() throws Exception {
transportHeaders.put(AuthConstants.MDM_SIGNATURE, "some cert");
AuthenticationHandler handler = new AuthenticationHandler();
boolean response = handler.handleRequest(createSynapseMessageContext("<empty/>", this.synapseConfiguration,
transportHeaders, "https://test.com/testservice/api/testdevice"));
transportHeaders, "https://test.com/testservice/device-mgt/testdevice"));
Assert.assertFalse(response);
TestUtils.setSystemProperties();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public boolean equals(Object obj) {
if (obj instanceof EnrolmentInfo) {
EnrolmentInfo tempInfo = (EnrolmentInfo) obj;
if (this.owner != null && this.ownership != null) {
if (this.owner.equalsIgnoreCase(tempInfo.getOwner()) && this.ownership.equals(tempInfo.getOwnership())) {
if (this.owner.equalsIgnoreCase(tempInfo.getOwner())) {
return true;
}
}
Expand Down