Fixed some issues reported with FindBugs while security plugin is enabled.

revert-dabc3590
Maninda 8 years ago
parent 7aba0fe551
commit 0c7f1adcba

@ -111,7 +111,7 @@ public class FireAlarmHTTPCommunicator extends HTTPTransportHandler {
AgentManager agentManager = AgentManager.getInstance(); AgentManager agentManager = AgentManager.getInstance();
String pathContext = request.getPathInfo(); String pathContext = request.getPathInfo();
String separator = File.separator; String separator = File.separatorChar=='\\' ? "\\\\" : File.separator ;
if (pathContext.toUpperCase().contains( if (pathContext.toUpperCase().contains(
separator + AgentConstants.TEMPERATURE_CONTROL)) { separator + AgentConstants.TEMPERATURE_CONTROL)) {

@ -83,6 +83,7 @@
org.wso2.carbon.event.input.adapter.core, org.wso2.carbon.event.input.adapter.core,
org.wso2.carbon.event.input.adapter.core.exception, org.wso2.carbon.event.input.adapter.core.exception,
org.jivesoftware.smack.*, org.jivesoftware.smack.*,
javax.xml,
javax.xml.bind, javax.xml.bind,
javax.xml.bind.annotation, javax.xml.bind.annotation,
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",

@ -6,6 +6,7 @@ import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException;
import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
@ -50,6 +51,7 @@ public class VirtualFirealarmConfig {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -134,6 +134,7 @@
</Export-Package> </Export-Package>
<Import-Package> <Import-Package>
org.wso2.carbon.event.output.adapter.core.*, org.wso2.carbon.event.output.adapter.core.*,
javax.xml,
javax.xml.namespace; version=0.0.0, javax.xml.namespace; version=0.0.0,
org.apache.axis2, org.apache.axis2,
org.apache.axis2.client, org.apache.axis2.client,

@ -75,7 +75,8 @@ public class WebsocketConfig {
return websocketValidationConfigs; return websocketValidationConfigs;
} }
public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigs) { public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigsTemp) {
websocketValidationConfigs = websocketValidationConfigs; websocketValidationConfigs = websocketValidationConfigsTemp;
} }
} }

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.output.adapter.websocket.util;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException; import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -34,6 +35,7 @@ public class WebsocketUtils {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -300,7 +300,7 @@ public class AndroidDeviceInfo extends DeviceInfo implements Serializable {
} }
public Date getUpdatedTime() { public Date getUpdatedTime() {
if(this.updatedTime.equals((Object)null)) { if(this.updatedTime == null) {
this.updatedTime = new Date(); this.updatedTime = new Date();
} }

@ -83,13 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
} else {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -59,6 +59,7 @@
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml,
javax.xml.bind.*, javax.xml.bind.*,
javax.sql, javax.sql,
javax.xml.parsers; version=0.0.0, javax.xml.parsers; version=0.0.0,

@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Registry;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

@ -82,13 +82,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
} else {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -187,10 +187,10 @@ public class WindowsAPIUtils {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
AuthenticatorConfigService authenticatorConfigService = AuthenticatorConfigService authenticatorConfigService =
(AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null); (AuthenticatorConfigService) ctx.getOSGiService(AuthenticatorConfigService.class, null);
AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST");
if (authenticatorConfigService == null) { if (authenticatorConfigService == null) {
throw new IllegalStateException("AuthenticatorConfiguration service has not initialized."); throw new IllegalStateException("AuthenticatorConfiguration service has not initialized.");
} }
AuthenticatorConfig authenticatorConfig = authenticatorConfigService.getAuthenticatorConfig("BST");
if (authenticatorConfig == null) { if (authenticatorConfig == null) {
throw new IllegalStateException("BST authenticatorConfig has not initialized."); throw new IllegalStateException("BST authenticatorConfig has not initialized.");
} }

@ -181,7 +181,7 @@ public class OperationHandler {
if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) { if ((Constants.SyncMLResponseCodes.ACCEPTED.equals(status.getData()))) {
pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier); pendingDataOperations = WindowsAPIUtils.getPendingOperations(deviceIdentifier);
for (Operation operation : pendingDataOperations) { for (Operation operation : pendingDataOperations) {
if ((OperationCode.Command.DEVICE_RING.equals(operation.getCode())) && if ((OperationCode.Command.DEVICE_RING.getCode().equals(operation.getCode())) &&
(operation.getId() == status.getCommandReference())) { (operation.getId() == status.getCommandReference())) {
operation.setStatus(Operation.Status.COMPLETED); operation.setStatus(Operation.Status.COMPLETED);
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
@ -213,7 +213,7 @@ public class OperationHandler {
} }
for (Operation operation : pendingDataOperations) { for (Operation operation : pendingDataOperations) {
if ((OperationCode.Command.WIPE_DATA.equals(operation.getCode())) && if ((OperationCode.Command.WIPE_DATA.getCode().equals(operation.getCode())) &&
(operation.getId() == status.getCommandReference())) { (operation.getId() == status.getCommandReference())) {
operation.setStatus(Operation.Status.COMPLETED); operation.setStatus(Operation.Status.COMPLETED);
updateStatus(syncmlDocument.getHeader().getSource().getLocURI(), updateStatus(syncmlDocument.getHeader().getSource().getLocURI(),
@ -306,13 +306,13 @@ public class OperationHandler {
if (status.getTargetReference() == null) { if (status.getTargetReference() == null) {
updateDeviceOperations(status, syncmlDocument, deviceIdentifier); updateDeviceOperations(status, syncmlDocument, deviceIdentifier);
} else { } else {
if ((OperationCode.Command.DEVICE_LOCK.equals(status.getTargetReference()))) { if ((OperationCode.Command.DEVICE_LOCK.getCode().equals(status.getTargetReference()))) {
updateLockOperation(status, syncmlDocument, deviceIdentifier); updateLockOperation(status, syncmlDocument, deviceIdentifier);
} }
if ((OperationCode.Command.DEVICE_RING.equals(status.getTargetReference()))) { if ((OperationCode.Command.DEVICE_RING.getCode().equals(status.getTargetReference()))) {
ring(status, syncmlDocument, deviceIdentifier); ring(status, syncmlDocument, deviceIdentifier);
} }
if (equals(OperationCode.Command.WIPE_DATA.equals(status.getTargetReference()))) { if ((OperationCode.Command.WIPE_DATA.getCode().equals(status.getTargetReference()))) {
dataWipe(status, syncmlDocument, deviceIdentifier); dataWipe(status, syncmlDocument, deviceIdentifier);
} }
} }

@ -51,6 +51,7 @@ import org.xml.sax.SAXException;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.jws.WebService; import javax.jws.WebService;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -102,7 +103,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
String headerTo = null; String headerTo = null;
String encodedWap; String encodedWap;
List<Header> headers = getHeaders(); List<Header> headers = getHeaders();
for (Header headerElement : headers != null ? headers : null) { for (Header headerElement : headers) {
String nodeName = headerElement.getName().getLocalPart(); String nodeName = headerElement.getName().getLocalPart();
if (PluginConstants.SECURITY.equals(nodeName)) { if (PluginConstants.SECURITY.equals(nodeName)) {
Element element = (Element) headerElement.getObject(); Element element = (Element) headerElement.getObject();
@ -231,6 +232,7 @@ public class EnrollmentServiceImpl implements EnrollmentService {
signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded()); signedCertEncodedString = base64Encoder.encodeAsString(signedCertificate.getEncoded());
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder builder; DocumentBuilder builder;
builder = domFactory.newDocumentBuilder(); builder = domFactory.newDocumentBuilder();

@ -112,7 +112,7 @@ public class CertificateEnrollmentServiceImpl implements CertificateEnrollmentSe
String headerTo = null; String headerTo = null;
String encodedWap; String encodedWap;
List<Header> headers = getHeaders(); List<Header> headers = getHeaders();
for (Header headerElement : headers != null ? headers : null) { for (Header headerElement : headers) {
String nodeName = headerElement.getName().getLocalPart(); String nodeName = headerElement.getName().getLocalPart();
if (PluginConstants.SECURITY.equals(nodeName)) { if (PluginConstants.SECURITY.equals(nodeName)) {
Element element = (Element) headerElement.getObject(); Element element = (Element) headerElement.getObject();

@ -55,6 +55,7 @@
org.osgi.framework, org.osgi.framework,
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.xml,
javax.xml.bind.*, javax.xml.bind.*,
javax.sql, javax.sql,
javax.naming, javax.naming,

@ -38,6 +38,7 @@ import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Registry;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File; import java.io.File;
@ -66,6 +67,7 @@ public class MobileDeviceManagementUtil {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save