I'm trying to send a information for a securite webservice but I am with the following error when he gotta tell me the answer
[ERROR] Expected encrypted part missing
org.apache.axis2.AxisFault: Expected encrypted part missing
at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:186)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:99)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:335)
at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:250)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:156)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:357)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:414)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
at tutorial.somar.Soma001SNAPSHOTStub.add(Soma001SNAPSHOTStub.java:190)
at tutorial.somar.teste2.main(teste2.java:65)
Caused by: org.apache.rampart.RampartException: Expected encrypted part missing
at org.apache.rampart.PolicyBasedResultsValidator.validateEncrSig(PolicyBasedResultsValidator.java:276)
at org.apache.rampart.PolicyBasedResultsValidator.validate(PolicyBasedResultsValidator.java:153)
at org.apache.rampart.RampartEngine.process(RampartEngine.java:280)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
... 10 more
Exception in thread "main" org.apache.axis2.AxisFault: Expected encrypted part missing
at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:186)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:99)
at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:335)
at org.apache.axis2.engine.Phase.invoke(Phase.java:308)
at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:250)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:156)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:357)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:414)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150)
at tutorial.somar.Soma001SNAPSHOTStub.add(Soma001SNAPSHOTStub.java:190)
at tutorial.somar.teste2.main(teste2.java:65)
Caused by: org.apache.rampart.RampartException: Expected encrypted part missing
at org.apache.rampart.PolicyBasedResultsValidator.validateEncrSig(PolicyBasedResultsValidator.java:276)
at org.apache.rampart.PolicyBasedResultsValidator.validate(PolicyBasedResultsValidator.java:153)
at org.apache.rampart.RampartEngine.process(RampartEngine.java:280)
at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
... 10 more
I'm using maven on the server:
here is the services.xml
<module ref="rampart"/>
<parameter name="ServiceClass" locked="false">tutorial.somar.SecureService</parameter>
<operation name="add">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</operation>
<sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<sp:MustSupportRefKeyIdentifier/>
<sp:MustSupportRefIssuerSerial/>
</wsp:Policy>
</sp:Wss10>
<sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:SignedParts>
<sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<sp:Body/>
</sp:EncryptedParts>
<ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
<ramp:user>serverkey</ramp:user>
<ramp:encryptionUser>clientkey</ramp:encryptionUser>
<ramp:passwordCallbackClass>tutorial.somar.PWCBHandler</ramp:passwordCallbackClass>
<ramp:signatureCrypto>
<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.file">server.keystore</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">nosecret</ramp:property>
</ramp:crypto>
</ramp:signatureCrypto>
<ramp:encryptionCrypto>
<ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.file">server.keystore</ramp:property>
<ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">nosecret</ramp:property>
</ramp:crypto>
</ramp:encryptionCrypto>
</ramp:RampartConfig>
</wsp:All>
and the SecureService.java
public int add(int a, int b) {
System.out.println(a+b);
return a+b;
}
my WS-client is like this:
public class teste2 {
private static Policy loadPolicy(String name) throws XMLStreamException{
ClassLoader loader = teste2.class.getClassLoader();
InputStream resource = loader.getResourceAsStream(name);
StAXOMBuilder builder = new StAXOMBuilder(resource);
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
public static void main (String[] args) throws XMLStreamException, RemoteException{
/*if(args.length < 4){
System.out.println("Usage:\n java " +
"com.sosnoski.ws.library.adb.WebServiceClient protocol host port path");
System.exit(1);
}*/
//String target = args[0] + "://" + args[1] + ":" + args[2] + args[3];
String target = "http://localhost:8070/axis2/services/soma-0.0.1-SNAPSHOT";
System.out.println("Connecting to " + target);
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("client-repo", null);
Soma001SNAPSHOTStub stub = new Soma001SNAPSHOTStub(ctx ,target);
//FacebookStub stub = new FacebookStub(target);
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
Policy policy = loadPolicy("signencr-policy-client.xml");
//Policy policy = loadPolicy("policy.xml");
//Policy policy = loadPolicy("sign-policy-client.xml");
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
options.setUserName("libuser");
options.setPassword("books");
client.engageModule("rampart");
int a = 4;
int b = 4;
Add n = new Add();
n.setA(a);
n.setB(b);
AddResponse result = stub.add(n);
System.out.println(a + " + " + b + " = " + result.get_return());
}
}
I'm using axis2 1.7.1, rampart 1.7.0
I solve the problem... I just change that line
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never"/>
for that
<sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
<wsp:Policy>
<sp:RequireThumbprintReference/>
</wsp:Policy>
</sp:X509Token>
peace.
Related
(previously it was working fine but don't what is changed )
When i am removing the default handler from synapse configs and adding my custom handler it is giving this error
[2022-01-13 10:44:41,924] ERROR - ServerWorker Error processing POST request for : /dev/21.2/ext-rt/publish/TestTenant/SmooksProviderTranslation.csv.
java.lang.NullPointerException: null
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.doRoleBasedAccessThrottlingWithCEP_aroundBody0(ThrottleHandler.java:193) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.doRoleBasedAccessThrottlingWithCEP(ThrottleHandler.java:145) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.doThrottle_aroundBody12(ThrottleHandler.java:585) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.doThrottle(ThrottleHandler.java:562) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.handleRequest_aroundBody8(ThrottleHandler.java:522) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.wso2.carbon.apimgt.gateway.handlers.throttling.ThrottleHandler.handleRequest(ThrottleHandler.java:503) ~[org.wso2.carbon.apimgt.gateway_6.7.206.jar:?]
at org.apache.synapse.rest.API.process(API.java:373) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:95) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:73) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:99) ~[synapse-core_2.1.7.wso2v183.jar:2.1.7-wso2v183]
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) ~[axis2_1.6.1.wso2v41.jar:?]
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367) [synapse-nhttp-transport_2.1.7.wso2v183.jar:?]
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:426) [synapse-nhttp-transport_2.1.7.wso2v183.jar:?]
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:181) [synapse-nhttp-transport_2.1.7.wso2v183.jar:?]
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) [axis2_1.6.1.wso2v41.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
at java.lang.Thread.run(Thread.java:834) [?:?]
Below is the authenticate() method from myCustomHandler.java class, which has the AuthenticationContext object
public boolean authenticate(MessageContext synCtx) throws APISecurityException {
Map headers = getTransportHeaders(synCtx);
String authHeader = getAuthorizationHeader(headers);
String postmanToken = getPostmanToken(headers);
String clientIP = "10.110.67.195";
org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) synCtx)
.getAxis2MessageContext();
AuthenticationContext authContext = new AuthenticationContext();
authContext.setAuthenticated(true);
// Can modify to support scopes based throttle policy selection
authContext.setTier(APIConstants.UNLIMITED_TIER);
authContext.setStopOnQuotaReach(true);
authContext.setApiKey(clientIP);
authContext.setKeyType(APIConstants.API_KEY_TYPE_PRODUCTION);
authContext.setUsername((String) axis2MessageContext.getProperty("user"));
authContext.setCallerToken(null);
authContext.setApplicationName(null);
authContext.setApplicationId(clientIP);
authContext.setConsumerKey(null);
log.debug("**** applicationID is --- " + authContext.getApplicationId());
APISecurityUtils.setAuthenticationContext(synCtx, authContext, null);
System.out.println("**** TE is HERE");
log.debug("**** TE is HERE2");
log.debug("**** Header is --- " + headers);
log.debug("**** AuthHeader is --- " + authHeader);
log.debug("**** Postman token is --- " + postmanToken);
return true;
/*
* if (authHeader.startsWith("Bearer ")) { return true; } return false;
*/
}
I think the problem is with the AuthenticationContext object. We populate the authContext object at the Authentication handler(in each authenticator [1]) and this object is used at the throttle handler[2]. when you replaced the Authentication handler with your custom handler, you might have missed populating this object. Try populating this object as [1].
[1] - https://github.com/wso2/carbon-apimgt/blob/v6.7.206/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/security/oauth/OAuthAuthenticator.java#L301
[2] - https://github.com/wso2/carbon-apimgt/blob/v6.7.206/components/apimgt/org.wso2.carbon.apimgt.gateway/src/main/java/org/wso2/carbon/apimgt/gateway/handlers/throttling/ThrottleHandler.java#L193
I'm using Camel-http4 because I simply need a producer, not expose a webservice. I simply need to push files up to an HTTP server, so this is a client implementation. the problem I am facing is the attempt to post returns an error.
CamelHttpResponseCode=403, CamelHttpResponseText=Forbidden
{"timestamp":"2018-05-03T20:36:20.571","traceId":"","path":"[POST] https://apm-query-svc-prod.apm-api.com/v2/t_series/upload%2520?throwExceptionOnFailure=false","errors":[{"httpStatusCode":"FORBIDDEN","code":"FORBIDDEN","message":"Failed to parse multipart servlet request; nested exception is java.io.IOException: org.apache.tomcat.util.http.fileupload.FileUploadException: the request was rejected because no multipart boundary was found","detail":null,"requestId":null}]}
Question, is there a way to do this with Camel-HTTP4 ? how is / can this be done? and thank you !!!
here is the route
<route
id="core.pr.upload.route"
autoStartup="false" >
<from uri="{{uploadEntranceEndpoint}}" />
<process ref="customerEntitesProcessor" />
<process ref="customerTokenProcessor" />
<process ref="uploadProcessor" />
<setHeader headerName="CamelHttpUri">
<simple>${header.UPLOADURL}?throwExceptionOnFailure=false</simple>
</setHeader>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
<to uri="http4://apm-query-svc-prod.app-api.aws-usw02-pr.io:443/v2/t_series/upload?throwExceptionOnFailure=false" />
<log message="After POSTING FILE: ${body}" loggingLevel="INFO"/>
<to uri="{{afteruploadLocation}}" />
</route>
here is the class, I simply set the headers up and the URI is overridden with the one provided by Exchange.HTTP_URI.
public class UploadProcessor implements Processor {
private static final Logger LOG = LoggerFactory.getLogger(UploadProcessor.class);
#Override
public void process(Exchange exchange) throws Exception {
LOG.info("Entering Upload Processor ..." );
final String tenant = (String)exchange.getIn().getHeader("TENANT");
final String token = (String)exchange.getIn().getHeader("TOKEN");
final String uploadUrl = (String)exchange.getIn().getHeader("UPLOADURL");
final String custKey = (String)exchange.getIn().getHeader("CUSTKEY");
LOG.info("TENANT: " + tenant);
LOG.info("TOKEN: " + token);
LOG.info("UPLOADURL: " + uploadUrl);
LOG.info("CUSTKEY: " + custKey);
LOG.info("Uploading File for CustKey: " + custKey + " and Tenant: " + tenant);
StringBuilder authHeader = new StringBuilder("Bearer ");
authHeader.append(token);
LOG.info("Authorization: " + authHeader.toString());
exchange.setProperty("CamelCharsetName", "UTF-8"); //"CamelCharsetName" Exchange.CHARSET_NAME
exchange.getIn().setHeader("CamelHttpCharacterEncoding", "UTF-8"); //"CamelHttpCharacterEncoding" Exchange.HTTP_CHARACTER_ENCODING
exchange.getIn().setHeader("CamelAcceptContentType", "application/json"); //"CamelAcceptContentType" Exchange.ACCEPT_CONTENT_TYPE
exchange.getIn().setHeader("CamelHttpUri", uploadUrl); //"CamelHttpUri" Exchange.HTTP_URI
exchange.getIn().setHeader("CamelHttpMethod", "POST"); //"CamelHttpMethod" Exchange.HTTP_METHOD
exchange.getIn().setHeader("x-ge-csvformat", "ODB");
exchange.getIn().setHeader("Tenant", tenant);
exchange.getIn().setHeader("Content-Type", "multipart/form-data"); //"Content-Type" ; boundary=
exchange.getIn().setHeader("Authorization", authHeader.toString());
LOG.info("Exiting Upload Processor: Finish " );
}
}
this is my first HTTP introduction, not familiar with the multipart boundary, I'm hoping there is a kind a simple solution to this. :) thank you !!!
The solution wasn't that difficult at all, here is the final based on Ralf's answer. thanks all! the hard part was finding the import packages and that it has a dependency.
add to POM
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.3.1</version>
</dependency>
import java.lang.StringBuilder;
import java.net.URLEncoder;
import java.util.Base64;
import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.camel.LoggingLevel;
import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
public class UploadProcessor implements Processor {
private static final Logger LOG = LoggerFactory.getLogger(UploadProcessor.class);
#Override
public void process(Exchange exchange) throws Exception {
LOG.info("Entering Upload Processor ..." );
final String tenant = (String)exchange.getIn().getHeader("TENANT");
final String token = (String)exchange.getIn().getHeader("TOKEN");
final String uploadUrl = (String)exchange.getIn().getHeader("UPLOADURL");
final String custKey = (String)exchange.getIn().getHeader("CUSTKEY");
LOG.info("TENANT: " + tenant);
LOG.info("TOKEN: " + token);
LOG.info("UPLOADURL: " + uploadUrl);
LOG.info("CUSTKEY: " + custKey);
LOG.info("Uploading File for CustKey: " + custKey + " and Tenant: " + tenant);
StringBuilder authHeader = new StringBuilder("Bearer ");
authHeader.append(token);
LOG.info("Authorization: " + authHeader.toString());
exchange.setProperty("CamelCharsetName", "UTF-8"); //"CamelCharsetName" Exchange.CHARSET_NAME
exchange.getIn().setHeader("CamelHttpCharacterEncoding", "UTF-8"); //"CamelHttpCharacterEncoding" Exchange.HTTP_CHARACTER_ENCODING
exchange.getIn().setHeader("CamelAcceptContentType", "application/json"); //"CamelAcceptContentType" Exchange.ACCEPT_CONTENT_TYPE
exchange.getIn().setHeader("CamelHttpUri", uploadUrl); //"CamelHttpUri" Exchange.HTTP_URI
exchange.getIn().setHeader("CamelHttpMethod", "POST"); //"CamelHttpMethod" Exchange.HTTP_METHOD
exchange.getIn().setHeader("x-ge-csvformat", "ODB");
exchange.getIn().setHeader("Tenant", tenant);
exchange.getIn().setHeader("Authorization", authHeader.toString());
// Process the file in the exchange body
File file = exchange.getIn().getBody(File.class);
String fileName = (String) exchange.getIn().getHeader(Exchange.FILE_NAME);
LOG.info("fileName: " + fileName);
MultipartEntityBuilder entity = MultipartEntityBuilder.create();
entity.addBinaryBody("file", file);
entity.addTextBody("name", fileName);
exchange.getIn().setBody(entity.build());
LOG.info("Exiting Upload Processor: Finish " );
}
}
UPDATE:
I am running it on Fedora 21.
SonarQube - 5.0.
SonarQube Runner - 2.4
UPDATE2: Findbugs v3.1, Java Plugin v2.8
UPDATE3:
Analyzer fails on the following file:
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class MyManager extends ParentManager {
public MyManager(int id, int var1, int var2, int var3) {
super(id, var1, var2, var3);
}
public void load() {
Connection con = null;
Statement st;
ResultSet res;
try {
con = DatabaseManager.getDataSource().getConnection();
st = con.createStatement();
int currentId = 0;
CurrentData currentData= null;
res = st.executeQuery("SELECT subjects.subjectname" + " AS name, " +
" subjects.subjectcode AS code, " +
" groups.groupname AS gname, " +
" groups.groupID AS gID , " +
" subjects.sID AS sID, " +
" groups.isMain AS ismain " +
" FROM joinGroup LEFT JOIN groups ON joinGroup.groupID=groups.groupID " +
" LEFT JOIN subjects ON subjects.sID=groups.sID " +
" WHERE joinGroup.sID=" + id + " " +
" AND groups.var1" + var1 + " AND groups.var2=" + var2 + " " +
" ORDER BY name, subjects.subjectcode, subjects.sID ");
while (res.next()) {
if (currentId != res.getInt("sID")) {
currentData = new CurrentData();
data.subjects.add(currentData);
currentData.subjectName = res.getString("name");
currentData.subjectID = res.getInt("sID");
}
CurrentGroupData groupData = new CurrentGroupData();
groupData.name = res.getString("gname");
groupData.id = res.getInt("gID");
currentId = res.getInt("sID");
if (res.getBoolean("ismain")) {
assert currentData != null;
currentData.groupID = res.getInt("gID");
}
if (currentData != null) {
currentData.groups.add(groupData);
}
}
loadSubjectsData(st, res);
} catch (Exception exc) {
Log.writeLog(ex);
} finally {
try {
con.close();
} catch (SQLException e) {
Log.writeLog(e);
}
}
}
}
I have installed SonarQube following the tutorials on sonar website.
I am able to browse to localhost:9000 and it shows start page.
Then I try to analyze the project via command: sonar-runner.
It fails.
Running sonar-runner -X displays the following:
>
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : '/path/to/my/file/MyFile.java'
at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:114)
at org.sonar.java.ast.AstScanner.scan(AstScanner.java:75)
at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:122)
at org.sonar.java.JavaSquid.scan(JavaSquid.java:115)
at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:91)
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:122)
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:222)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:223)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:65)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:52)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:128)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:93)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:78)
at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:171)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 9 more
Caused by: java.lang.NullPointerException
at org.sonar.java.checks.AbstractInjectionChecker.isIdentifierDynamicString(AbstractInjectionChecker.java:67)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:54)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:49)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:57)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:49)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:57)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:49)
at org.sonar.java.checks.AbstractInjectionChecker.isDynamicString(AbstractInjectionChecker.java:57)
at org.sonar.java.checks.SQLInjectionCheck.visitNode(SQLInjectionCheck.java:48)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:95)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visitChildren(SubscriptionVisitor.java:113)
at org.sonar.java.ast.visitors.SubscriptionVisitor.visit(SubscriptionVisitor.java:97)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanTree(SubscriptionVisitor.java:73)
at org.sonar.java.ast.visitors.SubscriptionVisitor.scanFile(SubscriptionVisitor.java:67)
at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:122)
at com.sonar.sslr.impl.ast.AstWalker.walkAndVisit(AstWalker.java:67)
at org.sonar.java.ast.AstScanner.simpleScan(AstScanner.java:107)
... 38 more
>
Didn't do anything "exotic", just followed the official tutorials like this one:
http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Runner
I am running it locally.
Any ideas?
Thanks
I got similar problem with ReturnEmptyArrayyNotNullCheck. As a workaround I disabled that rule in sonarqube web gui.
Log in as an admin. Click Rules in the top menu. Search for SQL or Inject or whatever other word to find the rule you think is causing analysis failures. Then select the rule and disable it in the quality profile attached to your project. Of course this rule will be ignored totally in all attached projects.
I got no solution, but ran into the same problem and and found this reference on sonar website, could it be the same problem you have?
http://sonarqube.15.x6.nabble.com/NullPointerException-analysing-file-with-SQLInjectionCheck-td5032155.html (Scroll to the end)
I would like to upload a file to QuickBooks Online using IDS V3.
I followed the steps described here
https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/020_key_concepts/attachments.
Here is my source code
URL url = new URL("https://quickbooks.api.intuit.com/v3/company/My_company_ID/upload");
HttpURLConnection request = (HttpURLConnection) url.openConnection();
request.setDoOutput(true);
request.setRequestMethod("POST");
HttpParameters para = new HttpParameters();
//String status = URLEncoder.encode("中 文","utf-8").replaceAll("\\+", "%20");
//para.put("status", status);
String boundary = "---------------------------37531613912423";
//String content = "--"+boundary+"\r\nContent-Disposition: form-data; name=\"status\"\r\n\r\n";
String pic = "\r\n--"+boundary+"\r\nContent-Disposition: form-data; name=\"pic\"; filename=\"postpic.gif\"\r\nContent-Type: image/gif\r\n\r\n";
byte[] end_data = ("\r\n--" + boundary + "--\r\n").getBytes();
File f = new File("/Users/cnanfack/Documents/oml_map1.gif");
FileInputStream stream = new FileInputStream(f);
byte[] file = new byte[(int)f.length()];
stream.read(file);
String lineEnd = "\r\n";
String header = "Content-Disposition: form-data; name=\"file_metadata_0\""+lineEnd
+"Content-Type: application/xml; charset=UTF-8"+lineEnd
+"Content-Transfer-Encoding: 8bit"+lineEnd;
String attachable = header+"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Attachable xmlns=\"http://schema.intuit.com/finance/v3\" domain=\"QBO\" sparse=\"false\">"
+"<EntityRef type=\"Bill\">285</EntityRef>"
+"<Size>4099</Size>"
+"<ContentType>image/gif</ContentType>"
+"<FileName>postpic.gif</FileName>"
+"</Attachable>";
request.setRequestProperty("Content-Type", "multipart/form-data; boundary="+boundary);
//request.setRequestProperty("Content-Length", String.valueOf(boundary.getBytes().length+"test".getBytes().length+pic.getBytes().length+f.length()+end_data.length));
//consumer.setAdditionalParameters(para);
consumer.sign(request);
OutputStream ot = request.getOutputStream();
ot.write(end_data);
ot.write(attachable.getBytes());
ot.write(end_data);
//ot.write(status.getBytes());
ot.write(pic.getBytes());
ot.write("Content-Transfer-Encoding: binary\r\n\r\n".getBytes());
ot.write(file);
ot.write(end_data);
ot.flush();
ot.close();
System.err.println("Sending request...");
request.connect();
System.err.println("Response: " + request.getResponseCode() + " "
+ request.getResponseMessage());
BufferedReader reader =new BufferedReader(new InputStreamReader(request.getInputStream()));
String b = null;
while((b = reader.readLine())!=null){
System.err.println(b);
}
The returned result:
Response: 200 OK
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-11-10T20:24:27.823-08:00"/>
But I don't see the file on Quickbooks Online.
Maybe I miss something. Can someone help me?
Thank you in advance
I had tried this Upload endpoint call using Java Devkit. It is working fine. PFB details.
- Request URI : https://quickbooks.api.intuit.com/v3/company/688779980/upload? Http
- Method : POST Content-Disposition: form-data; name="file_metadata_2bddf"
- Content-Type: application/xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Attachable xmlns="http://schema.intuit.com/finance/v3">
<FileName>images.jpg</FileName>
<ContentType>image/jpeg</ContentType>
<Lat>25.293112341223</Lat>
<Long>-21.3253249834</Long>
<PlaceName>Fake Place</PlaceName>
<Note>Attachable note 900a49e1</Note>
<Tag>Attachable tag 900a49e1</Tag>
</Attachable>
Response XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2013-11-12T05:58:25.296-08:00">
<AttachableResponse>
<Attachable domain="QBO" sparse="false">
<Id>100000000000543524</Id>
<SyncToken>0</SyncToken>
<MetaData>
<CreateTime>2013-11-12T05:58:26-08:00</CreateTime>
<LastUpdatedTime>2013-11-12T05:58:26-08:00</LastUpdatedTime>
</MetaData>
<FileName>images.jpg</FileName>
<FileAccessUri>/v3/company/688779980/download/100000000000543524</FileAccessUri>
<TempDownloadUri>https://intuit-qbo-prod-19.s3.amazonaws.com/688779980%2Fattachments%2Fimages-1384264705362.jpg?Expires=1384265606&AWSAccessKeyId=AKIAJEXDXKNYCBUNCCCQ&Signature=ESZPzeO%2B5YWxw8VOWMVMBRnvIdw%3D</TempDownloadUri>
<Size>58616</Size>
<ContentType>image/jpeg</ContentType>
<Lat>25.293112341223</Lat>
<Long>-21.3253249834</Long>
<PlaceName>Fake Place</PlaceName>
<Note>Attachable note 8219e79a</Note>
<Tag>Attachable tag 8219e79a</Tag>
<ThumbnailFileAccessUri>/v3/company/688779980/attachable-thumbnail/100000000000543524</ThumbnailFileAccessUri>
</Attachable>
</AttachableResponse>
</IntuitResponse>
From the ThumnailFileAccessUri property I got the following attachment URI which I had used for Download endpoint.
/v3/company/688779980/attachable-thumbnail/100000000000543524
Download Endpoint(GET)-
https://quickbooks.api.intuit.com/v3/company/688779980/download/100000000000543521
JAVA/.Net SDK download link - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits
Hope it will be useful.
EDIT- Adding Java code snippet
public static void executeUploadForImageFilePoc(DataService service) throws ParseException, FMSException, FileNotFoundException {
System.out.println("executeUploadForImageFile");
String uuid = UUID.randomUUID().toString().substring(0, 8);
Attachable attachable1 = new Attachable();
//attachable.setSize(new Long("34234"));
attachable1.setLat("25.293112341223");
attachable1.setLong("-21.3253249834");
attachable1.setPlaceName("Fake Place");
attachable1.setNote("Attachable note " + uuid);
attachable1.setTag("Attachable tag " + uuid);
Attachable attachable = attachable1;
attachable.setFileName("images.jpg");
attachable.setContentType("image/jpeg");
File file = new File("C:\\images_new.jpg");
InputStream in = new FileInputStream(file);
//Upload endpoint call
Attachable attachableOutput = service.upload(attachable, in);
//Check return XML
attachable.getFileAccessUri();
System.out.println(attachableOutput.getFileAccessUri());
System.out.println(attachableOutput.getFileName());
//Download endpoint call
InputStream output = service.download(attachableOutput);
try {
BufferedImage bImageFromConvert = ImageIO.read(output);
ImageIO.write(bImageFromConvert, "jpg", new File("C:\\images_new_manas.jpg"));
} catch (IOException e) {
throw new FMSException("Error while reading the upload file.", e);
}
}
Thanks
I have a working code in dotnet. See if it works for you:
DataService.DataService commonServiceQBO= new DataService.DataService(qboContextoAuth);
string imagePath = string.Concat(AppDomain.CurrentDomain.BaseDirectory, "\\", "Services\\Resource\\image.jpg");
System.IO.FileInfo file = new System.IO.FileInfo(imagePath);
Attachable attachable = new Attachable();
attachable.AttachableRef = new AttachableRef[1];
attachable.AttachableRef[0].EntityRef = new ReferenceType();
attachable.AttachableRef[0].EntityRef.type = "Bill";
attachable.AttachableRef[0].EntityRef.Value = "12";
attachable.Lat = "25.293112341223";
attachable.Long = "-21.3253249834";
attachable.PlaceName = "Fake Place";
attachable.Note = "Attachable note123 ";
attachable.Tag = "Attachable tag123 ";
using (System.IO.FileStream fs = file.OpenRead())
{
attachable.ContentType = "image/jpeg";
attachable.FileName = file.Name;
Attachable attachableUploaded = commonServiceQBO.Upload(attachable, fs);
}
For download use:
byte[] responseByte = service.Download(attachableUploaded);
I built the wsdl-client-stub based on xmlbeans. Now I got stuck adding a custom header for authentification using xmlbeans since xmlbeans stubs are lacking the necessary Classes(?)
Actually, the header should look like:
<SOAP-ENV:Header>
<ns2:verifyingToken>
<UserID>9</UserID>
<Token>29438094lkjslfkjlsdkjf</Token>
</ns2:verifyingToken>
</SOAP-ENV:Header>
So I tried as fallback going in between stub and ServiceClient:
ServiceClient sc = stub._getServiceClient();
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMElement omElement = omFactory.createOMElement(new QName("SOAP-ENV", "Header", "ver"), null);
OMElement omElementVeri = omFactory.createOMElement(new QName("", "verifyingToken", ""), omElement);
OMElement omElementUser = omFactory.createOMElement(new QName("", "UserID", ""), omElementVeri);
omElementUser.setText(""+userid);
OMElement omElementPass = omFactory.createOMElement(new QName("", "Token", ""), omElementVeri);
omElementPass.setText(""+token);
sc.addHeader(omElement);
eclipse is raising errors saying:
The method createOMElement(String, OMNamespace) in the type OMFactory is not applicable for the arguments (QName, null)
- The constructor QName(String, String, String) is undefined
Does anyone has a hint, what I should fix, to get this to work.
I really appreciate your help,
Alex
ServiceClient client = stub._getServiceClient();
SOAP11Factory factory = new SOAP11Factory();
OMNamespace SecurityElementNamespace = factory.createOMNamespace("http://schemas.xmlsoap.org/ws/2002/12/secext", "wss");
OMElement usernameTokenEl = factory.createOMElement("UsernameToken", SecurityElementNamespace);
OMElement usernameEl = factory.createOMElement("Username", SecurityElementNamespace);
usernameEl.setText("123");
usernameTokenEl.addChild(usernameEl);
OMElement passwordEl = factory.createOMElement("Password", SecurityElementNamespace);
passwordEl.setText("123");
usernameTokenEl.addChild(passwordEl);
SOAPHeaderBlockImpl block = new SOAP11HeaderBlockImpl("Security", SecurityElementNamespace, factory);
block.addChild(usernameTokenEl);
client.addHeader(block);