diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java index d01a2fb7ec9..e88d80e67ce 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension.api/src/main/java/org/wso2/carbon/apimgt/application/extension/api/ApiApplicationRegistrationServiceImpl.java @@ -22,13 +22,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService; +import org.wso2.carbon.apimgt.application.extension.api.util.APIUtil; import org.wso2.carbon.apimgt.application.extension.api.util.RegistrationProfile; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; import org.wso2.carbon.base.MultitenantConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.apimgt.application.extension.api.util.APIUtil; import org.wso2.carbon.user.api.UserStoreException; import javax.ws.rs.DELETE; @@ -46,7 +46,7 @@ public class ApiApplicationRegistrationServiceImpl implements ApiApplicationRegi public Response register(@QueryParam("tenantDomain") String tenantDomain, @QueryParam("applicationName") String applicationName) { String authenticatedTenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(); - if (!authenticatedTenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(authenticatedTenantDomain)) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } try { diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java index bc02828ee37..304cab7df0f 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/APIManagementProviderServiceImpl.java @@ -23,12 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.json.simple.JSONObject; import org.wso2.carbon.apimgt.api.APIConsumer; import org.wso2.carbon.apimgt.api.APIManagementException; -import org.wso2.carbon.apimgt.api.model.API; -import org.wso2.carbon.apimgt.api.model.APIIdentifier; -import org.wso2.carbon.apimgt.api.model.APIKey; -import org.wso2.carbon.apimgt.api.model.Application; -import org.wso2.carbon.apimgt.api.model.SubscribedAPI; -import org.wso2.carbon.apimgt.api.model.Subscriber; +import org.wso2.carbon.apimgt.api.model.*; import org.wso2.carbon.apimgt.application.extension.constants.ApiApplicationConstants; import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey; import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException; @@ -415,7 +410,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe int applicationId = createApplication(apiConsumer, apiApplicationName, username, groupId); String tenantDomain = MultitenantUtils.getTenantDomain(username); Set userVisibleAPIs = apiConsumer.getAllPublishedAPIs(tenantDomain); - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { userVisibleAPIs.addAll(apiConsumer.getAllPublishedAPIs(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); } Subscriber subscriber = apiConsumer.getSubscriber(username); @@ -443,7 +438,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe try { APIConsumer apiConsumer = APIManagerFactory.getInstance().getAPIConsumer(username); loginInfoJsonObj.put("user", username); - if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { loginInfoJsonObj.put("isSuperTenant", true); } else { loginInfoJsonObj.put("isSuperTenant", false); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/util/APIManagerUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/util/APIManagerUtil.java index 530dfa662fc..8c204c422ec 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/util/APIManagerUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.application.extension/src/main/java/org/wso2/carbon/apimgt/application/extension/util/APIManagerUtil.java @@ -37,7 +37,7 @@ public final class APIManagerUtil { */ public static int getTenantId(String tenantDomain) throws APIManagerException { try { - if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { return MultitenantConstants.SUPER_TENANT_ID; } TenantManager tenantManager = APIApplicationManagerExtensionDataHolder.getInstance().getTenantManager(); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index 27e2af8fb61..3a2385d67c1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -36,10 +36,10 @@ import java.util.*; public class APIPublisherUtil { - private static final Log log = LogFactory.getLog(APIPublisherUtil.class); - private static final String DEFAULT_API_VERSION = "1.0.0"; public static final String API_VERSION_PARAM = "{version}"; public static final String API_PUBLISH_ENVIRONMENT = "Production and Sandbox"; + private static final Log log = LogFactory.getLog(APIPublisherUtil.class); + private static final String DEFAULT_API_VERSION = "1.0.0"; private static final String API_CONFIG_DEFAULT_VERSION = "1.0.0"; private static final String PARAM_MANAGED_API_ENDPOINT = "managed-api-endpoint"; private static final String PARAM_MANAGED_API_OWNER = "managed-api-owner"; @@ -242,7 +242,7 @@ public class APIPublisherUtil { MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; apiConfig.setTenantDomain(tenantDomain); String contextTemplate = context + "/" + APIConstants.VERSION_PLACEHOLDER; - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { contextTemplate = context + "/t/" + tenantDomain + "/" + APIConstants.VERSION_PLACEHOLDER; } apiConfig.setContextTemplate(contextTemplate); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java index a88fe00e9fe..d08055aed55 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/lifecycle/util/AnnotationProcessor.java @@ -63,11 +63,10 @@ public class AnnotationProcessor { private static final String HTTP_PORT = "httpPort"; private static final String STRING_ARR = "string_arr"; private static final String STRING = "string"; - + Class apiClazz; private StandardContext context; private Method[] pathClazzMethods; private Class pathClazz; - Class apiClazz; private ClassLoader classLoader; private ServletContext servletContext; @@ -319,7 +318,7 @@ public class AnnotationProcessor { * @return */ private String makeContextURLReady(String context) { - if (context != null && !context.equalsIgnoreCase("")) { + if (context != null && context.length() > 0) { if (context.startsWith("/")) { return context; } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java index 04f90307606..537e5b01b40 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.analytics.data.publisher/src/main/java/org/wso2/carbon/device/mgt/analytics/data/publisher/DeviceDataPublisher.java @@ -60,6 +60,10 @@ public class DeviceDataPublisher { private static Map dataPublisherMap; private static DeviceDataPublisher deviceDataPublisher; + public DeviceDataPublisher() { + dataPublisherMap = new ConcurrentHashMap<>(); + } + public static DeviceDataPublisher getInstance() { if (deviceDataPublisher == null) { synchronized (DeviceDataPublisher.class) { @@ -71,10 +75,6 @@ public class DeviceDataPublisher { return deviceDataPublisher; } - public DeviceDataPublisher() { - dataPublisherMap = new ConcurrentHashMap<>(); - } - /** * this return the data publisher for the tenant. * @@ -95,7 +95,7 @@ public class DeviceDataPublisher { String analyticsServerUrlGroups = analyticsConfig.getReceiverServerUrl(); String analyticsServerUsername = analyticsConfig.getAdminUsername(); String analyticsServerPassword = analyticsConfig.getAdminPassword(); - if (!tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); String userInfo[] = getAnalyticsServerUserInfo(tenantId); if (userInfo != null) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 4e788411e30..bab738ac1b6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -125,11 +125,11 @@ public class RoleManagementServiceImpl implements RoleManagementService { UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2]; for (UIPermissionNode permissionNode : rolePermissions.getNodeList()) { - if (permissionNode.getResourcePath().equals("/permission/admin")) { + if ("/permission/admin".equals(permissionNode.getResourcePath())) { for (UIPermissionNode node : permissionNode.getNodeList()) { - if (node.getResourcePath().equals("/permission/admin/device-mgt")) { + if ("/permission/admin/device-mgt".equals(node.getResourcePath())) { deviceMgtPermissions[0] = node; - } else if (node.getResourcePath().equals("/permission/admin/login")) { + } else if ("/permission/admin/login".equals(node.getResourcePath())) { deviceMgtPermissions[1] = node; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java index b86e3c1bcc3..3a841f2aa07 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/search/mgt/impl/QueryBuilderImpl.java @@ -47,8 +47,7 @@ public class QueryBuilderImpl implements QueryBuilder { Condition locCondition = new Condition(); if (conditions.size() == 1) { - - if (conditions.get(0).getKey().equalsIgnoreCase(Constants.LOCATION)) { + if (Constants.LOCATION.equalsIgnoreCase(conditions.get(0).getKey())) { locCondition = conditions.get(0); } else if (Utils.checkDeviceDetailsColumns(conditions.get(0).getKey()) || Utils.checkDeviceLocationColumns(conditions.get(0).getKey())) { @@ -58,7 +57,7 @@ public class QueryBuilderImpl implements QueryBuilder { } } else { for (Condition con : conditions) { - if (con.getKey().equalsIgnoreCase(Constants.LOCATION)) { + if (Constants.LOCATION.equalsIgnoreCase(con.getKey())) { locCondition = con; } else if (Utils.checkDeviceDetailsColumns(con.getKey()) || Utils.checkDeviceLocationColumns(con.getKey())) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java index a9d472d4985..bf563790d70 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/util/DeviceManagerUtil.java @@ -227,7 +227,7 @@ public final class DeviceManagerUtil { */ public static int getTenantId(String tenantDomain) throws DeviceManagementException { try { - if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { return MultitenantConstants.SUPER_TENANT_ID; } TenantManager tenantManager = DeviceManagementDataHolder.getInstance().getTenantManager(); diff --git a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java index 0e4723e23fa..9857c8f7536 100644 --- a/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.complex.policy.decision.point/src/main/java/org/wso2/carbon/policy/evaluator/FeatureFilterImpl.java @@ -67,25 +67,25 @@ public class FeatureFilterImpl implements FeatureFilter { for (FeatureRules rule : featureRulesList) { String ruleName = rule.getEvaluationCriteria(); String featureName = rule.getName(); - if (ruleName.equalsIgnoreCase(Constants.DENY_OVERRIDES)) { + if (Constants.DENY_OVERRIDES.equalsIgnoreCase(ruleName)) { getDenyOverridesFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.PERMIT_OVERRIDES)) { + if (Constants.PERMIT_OVERRIDES.equalsIgnoreCase(ruleName)) { getPermitOverridesFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.FIRST_APPLICABLE)) { + if (Constants.FIRST_APPLICABLE.equalsIgnoreCase(ruleName)) { getFirstApplicableFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.LAST_APPLICABLE)) { + if (Constants.LAST_APPLICABLE.equalsIgnoreCase(ruleName)) { getLastApplicableFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.ALL_APPLICABLE)) { + if (Constants.ALL_APPLICABLE.equalsIgnoreCase(ruleName)) { getAllApplicableFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.HIGHEST_APPLICABLE)) { + if (Constants.HIGHEST_APPLICABLE.equalsIgnoreCase(ruleName)) { getHighestApplicableFeatures(featureName, featureList, effectiveFeatureList); } - if (ruleName.equalsIgnoreCase(Constants.LOWEST_APPLICABLE)) { + if (Constants.LOWEST_APPLICABLE.equalsIgnoreCase(ruleName)) { getLowestApplicableFeatures(featureName, featureList, effectiveFeatureList); } } diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java index 94b11074409..1322834634a 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/ComplianceDecisionPointImpl.java @@ -253,7 +253,7 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint { Policy policy = complianceData.getPolicy(); String compliance = this.getNoneComplianceRule(policy); - if (compliance.equals("")) { + if ("".equals(compliance)) { String msg = "Compliance rule is empty for the policy " + policy.getPolicyName() + ". Therefore " + "Monitoring Engine cannot run."; throw new PolicyComplianceException(msg); diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java index ee55646f117..d0d9fce3526 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/util/PolicyManagerUtil.java @@ -203,7 +203,7 @@ public class PolicyManagerUtil { if (configuration != null && !configuration.isEmpty()) { for (ConfigurationEntry cEntry : configuration) { - if (cEntry.getName().equalsIgnoreCase(MONITORING_FREQUENCY)) { + if (MONITORING_FREQUENCY.equalsIgnoreCase(cEntry.getName())) { if (cEntry.getValue() == null) { throw new PolicyManagementException("Invalid value, i.e. '" + cEntry.getValue() + "', is configured as the monitoring frequency"); diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java index feb5c77415f..df15f9f1c77 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -105,7 +105,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { ctx = tokenizer.nextToken(); } } - return (ctx.equalsIgnoreCase("carbon") || ctx.equalsIgnoreCase("services")); + return ("carbon".equalsIgnoreCase(ctx) || "services".equalsIgnoreCase(ctx)); } private boolean isNonSecuredEndPoint(Request request) { @@ -132,10 +132,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { } } } - if (nonSecuredEndpoints.containsKey(uri)) { - return true; - } - return false; + return nonSecuredEndpoints.containsKey(uri); } private void processRequest(Request request, Response response, CompositeValve compositeValve, diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java index 8746cb14551..9184682d3a0 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/authenticator/JWTAuthenticator.java @@ -65,6 +65,13 @@ public class JWTAuthenticator implements WebappAuthenticator { private static final Map publicKeyHolder = new HashMap<>(); private Properties properties; + private static void loadTenantRegistry(int tenantId) throws RegistryException { + TenantRegistryLoader tenantRegistryLoader = AuthenticatorFrameworkDataHolder.getInstance(). + getTenantRegistryLoader(); + AuthenticatorFrameworkDataHolder.getInstance().getTenantIndexingLoader().loadTenantIndex(tenantId); + tenantRegistryLoader.loadTenantRegistry(tenantId); + } + @Override public void init() { @@ -73,10 +80,7 @@ public class JWTAuthenticator implements WebappAuthenticator { @Override public boolean canHandle(Request request) { String authorizationHeader = request.getHeader(JWTAuthenticator.JWT_ASSERTION_HEADER); - if ((authorizationHeader != null) && !authorizationHeader.isEmpty()) { - return true; - } - return false; + return (authorizationHeader != null) && !authorizationHeader.isEmpty(); } @Override @@ -106,7 +110,7 @@ public class JWTAuthenticator implements WebappAuthenticator { if (publicKey == null) { loadTenantRegistry(tenantId); KeyStoreManager keyStoreManager = KeyStoreManager.getInstance(tenantId); - if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) { String defaultPublicKey = properties.getProperty("DefaultPublicKey"); if (defaultPublicKey != null && !defaultPublicKey.isEmpty()) { boolean isDefaultPublicKey = Boolean.parseBoolean(defaultPublicKey); @@ -182,13 +186,13 @@ public class JWTAuthenticator implements WebappAuthenticator { } @Override - public void setProperties(Properties properties) { - this.properties = properties; + public Properties getProperties() { + return properties; } @Override - public Properties getProperties() { - return properties; + public void setProperties(Properties properties) { + this.properties = properties; } @Override @@ -198,11 +202,4 @@ public class JWTAuthenticator implements WebappAuthenticator { } return this.properties.getProperty(name); } - - private static void loadTenantRegistry(int tenantId) throws RegistryException { - TenantRegistryLoader tenantRegistryLoader = AuthenticatorFrameworkDataHolder.getInstance(). - getTenantRegistryLoader(); - AuthenticatorFrameworkDataHolder.getInstance().getTenantIndexingLoader().loadTenantIndex(tenantId); - tenantRegistryLoader.loadTenantRegistry(tenantId); - } }