From 7e90fde46113a24f33236ed011204fae318c10cd Mon Sep 17 00:00:00 2001 From: amalhub Date: Fri, 9 Dec 2016 12:28:40 +0530 Subject: [PATCH] IOTS-292: Adding new filter configs --- .../AuthenticationHandler.java | 6 +++--- .../utils/AuthConstants.java | 2 ++ .../utils/CoreUtils.java | 16 ++++++++++++++++ .../src/main/resources/api-filter-config.xml | 2 ++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/AuthenticationHandler.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/AuthenticationHandler.java index d8e779d658..1c320410b6 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/AuthenticationHandler.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/AuthenticationHandler.java @@ -84,7 +84,7 @@ public class AuthenticationHandler implements Handler { String accessToken = getAccessToken(); URI certVerifyUrl = new URI(AuthConstants.HTTPS + "://" + CoreUtils.getHost() + ":" + CoreUtils - .getHttpsPort() + "/api/certificate-mgt/v1.0/admin/certificates/verify/ios"); + .getHttpsPort() + CoreUtils.getIosVerifyEndpoint()); Map certVerifyHeaders = new HashMap<>(); certVerifyHeaders.put("Authorization", "Bearer " + accessToken); certVerifyHeaders.put("Content-Type", "application/json"); @@ -103,7 +103,7 @@ public class AuthenticationHandler implements Handler { CoreUtils.debugLog(log, "Verify subject DN: ", subjectDN); String accessToken = getAccessToken(); URI certVerifyUrl = new URI(AuthConstants.HTTPS + "://" + CoreUtils.getHost() + ":" + CoreUtils - .getHttpsPort() + "/api/certificate-mgt/v1.0/admin/certificates/verify/android"); + .getHttpsPort() + CoreUtils.getAndroidVerifyEndpoint()); Map certVerifyHeaders = new HashMap<>(); certVerifyHeaders.put("Authorization", "Bearer " + accessToken); certVerifyHeaders.put("Content-Type", "application/json"); @@ -123,7 +123,7 @@ public class AuthenticationHandler implements Handler { String accessToken = getAccessToken(); URI certVerifyUrl = new URI(AuthConstants.HTTPS + "://" + CoreUtils.getHost() + ":" + CoreUtils - .getHttpsPort() + "/api/certificate-mgt/v1.0/admin/certificates/verify/ios"); + .getHttpsPort() + CoreUtils.getAndroidVerifyEndpoint()); Map certVerifyHeaders = new HashMap<>(); certVerifyHeaders.put("Authorization", "Bearer " + accessToken); certVerifyHeaders.put("Content-Type", "application/json"); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/AuthConstants.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/AuthConstants.java index 12bcda249a..03a8780efc 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/AuthConstants.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/AuthConstants.java @@ -28,6 +28,8 @@ public class AuthConstants { public static final String HTTPS_PORT = "httpsPort"; public static final String USERNAME = "username"; public static final String PASSWORD = "password"; + public static final String IOS_VERIFY_ENDPOINT = "ios-verify-endpoint"; + public static final String ANDROID_VERIFY_ENDPOINT = "android-verify-endpoint"; public static final String MDM_SIGNATURE = "mdm-signature"; public static final String PROXY_MUTUAL_AUTH_HEADER = "proxy-mutual-auth-header"; public static final String ENCODED_PEM = "encoded-pem"; diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/CoreUtils.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/CoreUtils.java index 42a7fe9ea7..852e2529b7 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/CoreUtils.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/java/org.wso2.carbon.apimgt.handlers/utils/CoreUtils.java @@ -37,6 +37,8 @@ public class CoreUtils { private static int httpsPort = 9443; private static String username = "admin"; private static String password = "admin"; + private static String iosVerifyEndpoint = "/api/certificate-mgt/v1.0/admin/certificates/verify/ios"; + private static String androidVerifyEndpoint = "/api/certificate-mgt/v1.0/admin/certificates/verify/android"; /** * Reading configurations from api-filter-config.xml file @@ -88,6 +90,12 @@ public class CoreUtils { } else if (AuthConstants.PASSWORD.equals(beanName)) { String value = beanProp.getAttributeValue(new QName(null, "value")); password = value; + } else if (AuthConstants.IOS_VERIFY_ENDPOINT.equals(beanName)) { + String value = beanProp.getAttributeValue(new QName(null, "value")); + iosVerifyEndpoint = value; + } else if (AuthConstants.ANDROID_VERIFY_ENDPOINT.equals(beanName)) { + String value = beanProp.getAttributeValue(new QName(null, "value")); + androidVerifyEndpoint = value; } } } @@ -137,4 +145,12 @@ public class CoreUtils { public static String getPassword() { return password; } + + public static String getIosVerifyEndpoint() { + return iosVerifyEndpoint; + } + + public static String getAndroidVerifyEndpoint() { + return androidVerifyEndpoint; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/api-filter-config.xml b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/api-filter-config.xml index 8811ccb8e7..fc6c241759 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/api-filter-config.xml +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.handlers/src/main/resources/api-filter-config.xml @@ -18,5 +18,7 @@ + + \ No newline at end of file