使用标准JDK在Java中生成安全随机AES密钥的推荐方法是什么?
在其他帖子中,我发现了这一点,但使用a SecretKeyFactory可能是一个更好的主意:
KeyGenerator keyGen = KeyGenerator.getInstance("AES");
SecureRandom random = new SecureRandom(); // cryptograph. secure random
keyGen.init(random);
SecretKey secretKey = keyGen.generateKey();
Run Code Online (Sandbox Code Playgroud)
如果答案包括解释为什么它是生成随机密钥的好方法,那将是很好的.谢谢!
我在Maven有一个声纳配置文件.除代码覆盖率指标外,一切正常.我想让Sonar只为代码覆盖率指标忽略一些类.我有以下个人资料:
<profile>
<id>sonar</id>
<properties>
<sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/*Suite*.java</exclude>
<exclude>**/*RemoteTest.java</exclude>
<exclude>**/*SpringTest.java</exclude>
<exclude>**/*CamelTest.java</exclude>
<exclude>**/*FunctionalTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*DaoBeanTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
请帮忙.我试着添加类似的东西
<exclude>com/qwerty/dw/publisher/Main.class</exclude>
Run Code Online (Sandbox Code Playgroud)
但它没有帮助
UPDATE
我有一个正确的Cobertura配置文件.我试图将它添加到Sonar配置文件中,但我仍然有53%而不是Cobertura配置文件中的95%
<profile>
<id>sonar</id>
<properties>
<sonar.exclusions>**/beans/jaxb/**</sonar.exclusions>
<sonar.core.codeCoveragePlugin>cobertura</sonar.core.codeCoveragePlugin>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<excludes>
<exclude>**/*Suite*.java</exclude>
<exclude>**/*RemoteTest.java</exclude>
<exclude>**/*SpringTest.java</exclude>
<exclude>**/*CamelTest.java</exclude>
<exclude>**/*FunctionalTest.java</exclude>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*DaoBeanTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.maven.plugin.version}</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/qwerty/dw/dao/*</exclude>
<exclude>com/qwerty/dw/domain/*</exclude>
<exclude>com/qwerty/dw/beans/**/*</exclude>
<exclude>com/qwerty/dw/daemon/exception/*</exclude>
<exclude>com/qwerty/dw/daemon/Main.class</exclude>
<exclude>com/qwerty/dw/sink/Main.class</exclude>
<exclude>com/qwerty/dw/publisher/Main.class</exclude>
<exclude>com/qwerty/dw/publisher/dao/*</exclude>
<exclude>com/qwerty/dw/publisher/domain/*</exclude>
</excludes>
</instrumentation>
<formats>
<format>html</format>
</formats>
<aggregate>true</aggregate> …Run Code Online (Sandbox Code Playgroud) 在我在Windows XP上的批处理文件中,我想使用%*扩展到除第一个之外的所有参数.
测试文件(foo.bat):
@echo off
echo %*
shift
echo %*
Run Code Online (Sandbox Code Playgroud)
呼叫:
C:\> foo a b c d e f
Run Code Online (Sandbox Code Playgroud)
实际结果:
a b c d e f
a b c d e f
Run Code Online (Sandbox Code Playgroud)
期望的结果:
a b c d e f
b c d e f
Run Code Online (Sandbox Code Playgroud)
我怎样才能达到预期的效果?谢谢!!
我刚刚在Eclipse Juno中安装(并重新安装)了Findbugs,每当我尝试在任何项目中运行它时,我都会收到以下错误:
An internal error occurred during: "Finding bugs in <project name>...".
java.lang.ArrayIndexOutOfBoundsException
Run Code Online (Sandbox Code Playgroud)
谷歌搜索没有提供任何有用的结果.有任何想法吗?
编辑:我尝试(并且可能失败)在Eclipse中安装Java 8的测试版本来试用Java 8的lambdas和其他功能.也许它与Findbugs无法正常运行有关?
我在对项目进行声纳分析时遇到OutOfMemoryException.下面是堆栈跟踪:
14:55:55.433 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@5a7b5cb8[id=1,key=myProj_web,qualifier=TRK], with key batch-myProj_web
14:55:55.711 DEBUG - To prevent a memory leak, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 12:48.979s
Final Memory: 33M/910M
INFO: ------------------------------------------------------------------------
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.api.utils.SonarException: Can …Run Code Online (Sandbox Code Playgroud) java garbage-collection memory-management findbugs sonarqube
是什么区别GWT-user.jar和GWT-dev.jar?看看他们的内容,我看不清他们为什么打包它们.
我特别想知道如何使用这两个JAR进行编译和部署.
我需要哪两个......
javac(.java到.class)?任何关于这些用途的澄清,或者更好的解释为什么会这样做,将不胜感激.
要导入什么来使用SuppressFBWarnings?我通过help/install新软件安装了findbugs插件当我输入import edu.时,我无法通过ctrl空间来获取选项.
例
try {
String t = null;
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value="NP_ALWAYS_NULL",
justification="I know what I'm doing")
int sl = t.length();
System.out.printf( "Length is %d", sl );
} catch (Throwable e) {
...
}
Run Code Online (Sandbox Code Playgroud)
有错误"edu无法解析为某种类型"
我们通过Maven为我们的Java项目运行SonarQube分析.Maven以某种方式自动完成这项工作; 我们所做的只是添加sonar-maven-plugin到我们的pom.xml:
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</pluginManagement>
Run Code Online (Sandbox Code Playgroud)
这很好用.
但现在我们需要两次运行SonarQube分析,并使用不同的质量配置文件.由于您无法从Maven轻松更改项目密钥,因此我们使用SonarQube的branch属性区分SonarQube项目,如此(再次从pom.xml):
<properties>
<sonar.profile>MyQualityProfile1</sonar.profile>
<sonar.branch>Dev_${sonar.profile}</sonar.branch>
...
</properties>
Run Code Online (Sandbox Code Playgroud)
这样,我们最终在SonarQube UI中有两个项目条目,这两个条目都包含完全相同的代码,但根据其质量配置文件(一个使用质量配置文件1,另一个使用质量配置文件2)有不同的问题.
问题:为了实现这一点,我必须手动更改pom.xml属性并运行整个构建两次.
问题:如何将maven配置为只sonar:sonar使用不同的属性运行两次目标?
这将为我们的构建节省大量时间.我已经找到了类似的问题,但到目前为止还没有答案.谢谢!
!mapData.get("PARTY_ID").equals("") // <-- gives SonarQube error
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我得到"字符串文字表达式应该在等于比较的左侧"这个错误在Sonar中.那么我们如何才能避免它.
我试过这个:
("").equals(!mapData.get("CON_PTY_PARTY_ID"))
Run Code Online (Sandbox Code Playgroud)
但它不起作用.给点建议......
我使用Android Studio创建了一个Android项目.在build.gradle应用程序添加:
apply from: '../config/quality.gradle'
Run Code Online (Sandbox Code Playgroud)
然后我config用两个文件创建目录:quality.gradle如:
apply plugin: 'checkstyle'
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/checkstyle.xml")
source 'src'
include '**/*.java'
exclude '**/gen/**'
classpath = files()
}
Run Code Online (Sandbox Code Playgroud)
并checkstyle.xml喜欢:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="NeedBraces">
<property name="tokens" value="LITERAL_CASE, LITERAL_DEFAULT"/>
<property name="allowSingleLineStatement" value="true"/>
</module>
</module>
</module>
Run Code Online (Sandbox Code Playgroud)
跑步gradle checkstyle给我以下错误:
Executing external task 'checkstyle'...
:app:checkstyle FAILED
FAILURE: Build failed with an exception.
* What went …Run Code Online (Sandbox Code Playgroud) java ×6
sonarqube ×4
findbugs ×3
maven ×2
aes ×1
batch-file ×1
checkstyle ×1
encryption ×1
gradle ×1
gwt ×1
include ×1
java-8 ×1
jce ×1
pmd ×1
pom.xml ×1
spotbugs ×1
windows-xp ×1