title: Sonarqube “Insufficient privileges” - Encoding issue suspected
body: <p>After an upgrade of Sonar from the version 4.5 to the version 5.1.1, a lot of jobs are failing now. But some projects are succesfully analysed .</p>
  
  <p>The issue seems to be the same of these posts : <a href="https://stackoverflow.com/questions/31534221/sonarqube-insufficient-privileges">SonarQube &quot;Insufficient privileges&quot;</a> &amp; <a href="https://stackoverflow.com/questions/28391746/insufficient-privileges-error-with-sonarrunner">Insufficient privileges error with sonarRunner</a></p>
  
  <p><strong>but</strong> this is not a credential bug because some of my projects are successfully analysed.</p>
  
  <p>I have this message on Jenkins side (Sonar runner log) when the problem occurs:</p>
  
  <pre><code>[INFO] BUILD FAILURE
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 2:26.443s
  [INFO] Finished at: Fri Aug 07 10:35:46 CEST 2015
  [INFO] Final Memory: 54M/765M
  [INFO] ------------------------------------------------------------------------
  [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project XXXX: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/XXXXXXX/XXXXjs,path=src/main/webapp/js/XXXX/XXXX/XXXX.js,filename=XXXXX.js,language=JavaScript]': Insufficient privileges -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project Opale: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/XXXX/XXXXX/XXXXX.js,path=src/main/webapp/js/XXXX/XXXX/XXXX.js,filename=XXXX.js,language=JavaScript]'
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
      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:601)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
  Caused by: org.apache.maven.plugin.MojoExecutionException: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,path=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,filename=DetailCompositionTsfController.js,language=JavaScript]'
      at org.codehaus.mojo.sonar.bootstrap.ExceptionHandling.handle(ExceptionHandling.java:41)
      at org.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:139)
      at org.codehaus.mojo.sonar.SonarMojo.execute(SonarMojo.java:132)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
      ... 19 more
  Caused by: org.sonar.api.utils.SonarException: Fail to decorate 'org.sonar.api.resources.File@23e88d14[key=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,path=src/main/webapp/js/etiquetage/compositionTsf/DetailCompositionTsfController.js,filename=DetailCompositionTsfController.js,language=JavaScript]'
      at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:104)
      at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:87)
      at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
      at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:79)
      at org.sonar.batch.phases.DecoratorsExecutor.execute(DecoratorsExecutor.java:71)
      at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:127)
      at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      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.scanRecursively(ProjectScanContainer.java:228)
      at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
      at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
      at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
      at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
      at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
      at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
      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:601)
      at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
      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.codehaus.mojo.sonar.bootstrap.RunnerBootstraper.execute(RunnerBootstraper.java:135)
      ... 22 more
  Caused by: java.lang.IllegalStateException: Insufficient privileges
      at org.sonar.batch.bootstrap.ServerClient.handleHttpException(ServerClient.java:137)
      at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:107)
      at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:99)
      at org.sonar.batch.bootstrap.ServerClient.request(ServerClient.java:87)
      at org.sonar.batch.issue.tracking.DefaultServerLineHashesLoader.loadHashesFromWs(DefaultServerLineHashesLoader.java:47)
      at org.sonar.batch.issue.tracking.DefaultServerLineHashesLoader.getLineHashes(DefaultServerLineHashesLoader.java:38)
      at org.sonar.batch.issue.tracking.SourceHashHolder.initHashes(SourceHashHolder.java:52)
      at org.sonar.batch.issue.tracking.SourceHashHolder.getHashedSource(SourceHashHolder.java:65)
      at org.sonar.batch.issue.tracking.IssueTracking.setChecksumOnNewIssues(IssueTracking.java:66)
      at org.sonar.batch.issue.tracking.IssueTracking.track(IssueTracking.java:51)
      at org.sonar.batch.issue.tracking.IssueTrackingDecorator.doDecorate(IssueTrackingDecorator.java:139)
      at org.sonar.batch.issue.tracking.IssueTrackingDecorator.decorate(IssueTrackingDecorator.java:113)
      at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:96)
      ... 57 more
  [ERROR] 
  [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  [ERROR] 
  [ERROR] For more information about the errors and possible solutions, please read the following articles:
  [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  Sonar analysis completed: FAILURE
  Build step 'Sonar' changed build result to FAILURE
  Build step 'Sonar' marked build as failure
  </code></pre>
  
  <p>And when I check the SonarQube's access log and I found that :</p>
  
  <pre><code>127.0.0.1 - - [07/Aug/2015:03:38:14 +0200] "GET /sonar/api/sources/hash?key=XXX.YYY%3AZZZZZ%3Asrc%2Fmain%2Fwebapp%2Fjs%2FXXXX%2FXXXX%2FXXXXXX.js HTTP/1.0" 403 46 "-" "SonarQube Maven/3.0.5"
  </code></pre>
  
  <p>We see that server returns a 403 error. Then it's normal that sonarrunner print an authentification issue in its log.</p>
  
  <p>However, When I compare source code with my project which build successfully, I observe they contains UTF-8 source with no accented characters.</p>
  
  <p>Then I've add an accented char into a source file and the analysis has failed.</p>
  
  <p>I suspect a problem with the hash method on source files which contains accented symbols.</p>