小编mma*_*ran的帖子

为什么我不能在eclipse中获得wss4j maven依赖?

我总是从http://mvnrepository.com获得我的依赖项.每次都有效.但我似乎无法让wss4j工作.我的POM是这样的:

<dependencies>
 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.2.1.RELEASE</version>
 </dependency>
 <dependency>
    <groupId>org.apache.wss4j</groupId>
    <artifactId>wss4j</artifactId>
    <version>2.1.3</version>
 </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

我可以让Spring很好,但我一直得到"找不到依赖"的错误.我甚至使用-U选项,我得到了这个:

Downloading: http://repo1.maven.org/maven2/org/org/apache/wss4j/wss4j/2.1.3/wss4j-2.1.3.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/wss4j/wss4j/2.1.3/wss4j-2.1.3.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.411s
[INFO] Finished at: Sat Oct 10 14:31:51 EDT 2015
[INFO] Final Memory: 9M/303M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project crypt.lib: Could not resolve dependencies for project mmaceachran:crypt.lib:jar:0.0.1-SNAPSHOT: Could not find artifact org.apache.wss4j:wss4j:jar:2.1.3 in mvnrepository (http://repo1.maven.org/maven2/org/) -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

但是有下载!!! 我究竟做错了什么?

更新:
我使用-e选项,我发现它找不到工件:

Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Could …
Run Code Online (Sandbox Code Playgroud)

java eclipse wss4j maven

4
推荐指数
1
解决办法
2252
查看次数

org.apache.ws.security.WSSecurityException:一般安全错误(未找到用于解密的证书 (KeyId))

我继承了一些 WSS4J 安全网络服务的代码。它基于这个流行的教程:http : //distributedsenses.blogspot.com/2008/09/configuring-cxf-for-web-service.html

现在服务器端正在与其他客户端一起工作,但我的不是。:(

我为 tomcat 生成了一个密钥库,导出了公钥,并将其安装在服务器上。但是当我尝试调用时,服务器回复错误没有找到用于解密的证书(KeyId)

现在我没有对代码进行一些更改,但是我确实更改了包名称(我认为这对 SOAP 调用无关紧要)——我没有更改名称空间。

我什至在服务器上导出了证书,以确保我正确导入了它,并且它与客户端上的公钥完全匹配。所以我知道服务器有我的证书。

这是我的 OutInterceptor

 <bean 
   class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"
    id="TimestampSignEncrypt_Request">
    <constructor-arg>
        <map>
            <entry key="action" value="Timestamp Signature Encrypt"/>
            <entry key="user" value="clientwin"/>
            <entry key="encryptionUser" value="tomcat2"/>
            <entry key="signatureKeyIdentifier" value="DirectReference"/>
            <entry key="signaturePropFile" value="clientSign.properties"/>
            <entry key="encryptionPropFile" value="clientEncrypt.properties"/>
            <entry key="passwordCallbackClass" value="ClientKeystorePasswordCallback"/>
            <entry key="signatureParts" value="{Element}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
            <entry key="encryptionParts" value="{Element}{http://www.w3.org/2000/09/xmldsig#}Signature;{Content}{http://schemas.xmlsoap.org/soap/envelope/}Body"/>
            <entry key="encryptionSymAlgorithm" value="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
            <entry key="encryptionKeyTransportAlgorithm" value="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/>
            <entry key="signatureAlgorithm" value="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
        </map>
    </constructor-arg>
</bean>
Run Code Online (Sandbox Code Playgroud)

还有我的 clientSign.properties

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=changeit
org.apache.ws.security.crypto.merlin.keystore.alias=clientwin
org.apache.ws.security.crypto.merlin.file=C:\\apache-tomcat-7.0.55\\ssl\\.keystore
Run Code Online (Sandbox Code Playgroud)

我收到此错误的任何原因。我知道我的公钥在服务器的信任库中。这适用于其他客户。知道我做错了什么吗?

java security encryption web-services wss4j

3
推荐指数
1
解决办法
1万
查看次数

Freemarker URLTemplate 加载器向模板名称添加国际化并且多个加载器不起作用

我有一个 Spring MVC 应用程序,我正在尝试将 freemarker 作为视图解析器。我正在尝试设置它,以便它首先检查不同的服务器,然后在本地检查。这是相关的代码:

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
  <property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
  <property name="preTemplateLoaders" ref="myTemplateLoader"/>
</bean>

<bean  class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="cache" value="true"/>
        <property name="prefix" value=""/>
        <property name="suffix" value=".ftl"/>
        <property name="order" value="2" />
    </bean>

    <bean id="myTemplateLoader" class="com.xxx.MyURLTemplateLoader">
        <property name="baseUrl" value="http://10.0.0.5:8080/ftl/"/>
    </bean>
Run Code Online (Sandbox Code Playgroud)

这个类看起来像这样:

public class MyURLTemplateLoader extends URLTemplateLoader  {

private String baseUrl;

@Override
protected URL getURL(String arg0){
    URL url = null;
    try {
        url = new URL(baseUrl+arg0);
        System.out.println("URL Being used:"+url.toString());
    } catch (Exception s) {
        s.printStackTrace();
    }
    return url;
}

public String getBaseUrl() …
Run Code Online (Sandbox Code Playgroud)

java spring freemarker spring-mvc

3
推荐指数
1
解决办法
1283
查看次数

将 buld 和提交哈希添加到清单

我正在尝试将 jenkins 内部版本号、git commit hash 等添加到 MANIFEST.MF 文件中。我正在关注本教程:http : //akeffalas.github.io/blog/2014/04/jenkins-build-info-maven-artifacts.html

这是我的 POM 的构建部分:

    <build>
    <finalName>common</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                        <manifestEntries>
                            <Build-Time>${maven.build.timestamp}</Build-Time>  
                        </manifestEntries>
                        <manifestSections>
                            <manifestSection>
                                <name>${build.manifest.section}</name>
                                <manifestEntries>
                                    <Implementation-Title>com.mycompany.stuff</Implementation-Title>
                                    <Implementation-Version>${project.version}</Implementation-Version>
                                    <Implementation-Build-Number>${build.number}</Implementation-Build-Number>
                                    <Implementation-SCM-Revision>${build.revision}</Implementation-SCM-Revision>
                                </manifestEntries>
                            </manifestSection>
                        </manifestSections>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

但是当我构建它时,我得到的只是:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jenkins
Build-Jdk: 1.8.0_74
Run Code Online (Sandbox Code Playgroud)

我的构建参数是:

clean install -Dbuild.number=${BUILD_NUMBER} -Dbuild.revision=${GIT_COMMIT}
Run Code Online (Sandbox Code Playgroud)

但是在日志中,我没有看到正在调用的程序集插件,我看到了 clean、compile、resources、jar 和 install。但没有组装。

我需要做什么特别的事情来运行这个插件吗?还是我做错了,我完全需要别的东西?

java git maven jenkins

3
推荐指数
1
解决办法
6434
查看次数

我在同一个 Spring Boot 中有 2 个 CommandLineRunner

我在 Spring Boot 中有 2 个实现命令行运行程序的类。它们基本上是这样的:

 @SpringBootApplication
 @ComponentScan("com.xxxx")
 public class Application implements CommandLineRunner {
Run Code Online (Sandbox Code Playgroud)

第二个看起来像:

 @SpringBootApplication
 @ComponentScan("com.xxxx")
 public class ApplicationWorklfow implements CommandLineRunner {
Run Code Online (Sandbox Code Playgroud)

他们编译得很好。但是当我尝试使用 java -jar 运行它时,我可能会收到一个错误,因为 spring 不知道要运行哪个。

是否有我可以使用的命令来告诉 jar 我正在尝试运行哪个应用程序?

spring-boot

3
推荐指数
1
解决办法
1670
查看次数

Git自动合并提交消息

我将一个巨大的仓库分成了几个小仓库。旧的存储库仍在提交中,因此我必须不断更新我的新的较小的存储库。

我是通过这样做来做到这一点的:

git subtree split -P some-sub-directory-in-my-large-repo/ -b branch-name-I-split
Run Code Online (Sandbox Code Playgroud)

显然,我正在尝试编写这个脚本,但我无法克服这个:

cd my-smaller-repo
git pull /path-to-large-repo/ branch-name-I-split
Run Code Online (Sandbox Code Playgroud)

这当然让我想到了编辑。

我需要接受默认消息并继续...

有任何想法吗?

git

3
推荐指数
1
解决办法
7191
查看次数

@JsonFormat 不适用于嵌套对象

我有一个非常简单的bean:

public class StatusBean {

 private String name;
 @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="MM-dd-yyyy")
 private Date startDate;
 @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="MM-dd-yyyy")
 private Date endDate;

 public String getName() {
    return name;
 }
 public void setName(String name) {
    this.name = name;
 }
 public Date getStartDate() {
    return startDate;
 }
 public void setStartDate(Date startDate) {
    this.startDate = startDate;
 }
 public Date getEndDate() {
    return endDate;
 }
 public void setEndDate(Date endDate) {
    this.endDate = endDate;
 }
}
Run Code Online (Sandbox Code Playgroud)

我将它包装在另一个 bean 中,我用它来包装带有消息和内容的漂亮 json 格式的对象:

public class ResponseBean {

private boolean success = …
Run Code Online (Sandbox Code Playgroud)

java spring json

2
推荐指数
1
解决办法
1万
查看次数

JDBCTemplate Boolean 未与 BeanPropertyRowMapper 正确映射

我有一个带有用户表的标准 MySql 数据库。在这个表中有一个名为“isApproved”的 TINYINT(4)

对于这个用户,它被设置为“1”(我相信这是真的)我的 bean 属性看起来像这样:

private boolean isApproved;
Run Code Online (Sandbox Code Playgroud)

和适当的吸气剂/二传手:

public boolean isApproved() {
    return isApproved;
}
public void setApproved(boolean isApproved) {
    this.isApproved = isApproved;
}
Run Code Online (Sandbox Code Playgroud)

我有一个 jdbcTemplate 正在拉正确的用户,它看起来像这样:

public UserBean findUserByUserName(String userName) {
    String sql = "SELECT * FROM User WHERE name = ?";
    return (UserBean)getJdbcTemplate().queryForObject(sql, new BeanPropertyRowMapper<UserBean>(UserBean.class), userName);
}
Run Code Online (Sandbox Code Playgroud)

所以我想我可能犯了一个简单的错误,我将它添加到日志中:

logger.debug("User from DB isApproved:"+userFromDb.isApproved());
Run Code Online (Sandbox Code Playgroud)

即使数据库中有“1”,这也会返回“false”。

我如何使这个映射正确,isApproved 是“1”,它应该等同于作为布尔值的 true。

java spring jdbctemplate

2
推荐指数
1
解决办法
2102
查看次数

如何在Spring Java配置中设置日志记录属性?

我正在使用Spring 5 MVC应用程序。我正在尝试进行纯Java配置。我注意到我的日志记录不起作用。我的application.properties中有这个:

logging.level.org.springframework.web=ERROR
logging.level.org.springframework.security=ERROR
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE 
Run Code Online (Sandbox Code Playgroud)

现在,我当然不在使用application.properties,那么如何在我的@Configuration类之一中以纯Java方式设置它呢?

java spring spring-mvc

1
推荐指数
1
解决办法
998
查看次数

与ConditionalOnMissingBean相反

所以我有一个标准的Spring Boot Web应用程序.我需要允许多种身份验证机制.所以我希望能够拥有处理不同身份验证的jar文件.一个用于SAML服务器,CAS,OAuth等......

我希望我的"基础"war文件使用标准的jdbc(它现在可以使用)但是我希望能够将我的CAS-security.jar放在类路径中并让spring使用它的AuthenticationProvider.现在我在我的Application.java类中有这个

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
    .authenticationProvider(authenticationProvider)
    .userDetailsService(userDetailsService);
}
Run Code Online (Sandbox Code Playgroud)

我@Autowire提供者和服务,被定义为@Bean正常......

但我想注释(我认为)那些@Bean定义说"如果有另一个可用,请不要使用它"

我想要与ConditionalOnMissingBean完全相反.现在我想我可以使用该注释,并列出我可以使用的每个可能的插件类,但这是不好的形式,因为我不想每次创建新的安全插件时重新编译/重新部署.

UseThisIfNoOtherBeanExists类型注释吗?

事实上,我真正想要的是,我有所有安全性的东西,例如SecurityConfiguration,用@Configuration注释,并且如果可用的话,将整个类替换为其他东西.

java spring spring-boot

0
推荐指数
1
解决办法
178
查看次数

SimpleDateFormat 抛出无法解析的异常

我知道有很多这样的,但我似乎无法找到这种日期格式的魔法字符串:

String textDate = "2018-04-25T18:23:57.556Z";
Run Code Online (Sandbox Code Playgroud)

我的代码是:

String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
simpleDateFormat.parse(textDate)
Run Code Online (Sandbox Code Playgroud)

奇怪的是日期字符串本身中有一个“Z”,所以我不确定时区如何在这个字符串上工作。

如果我将日期格式更改为:

"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
Run Code Online (Sandbox Code Playgroud)

它有效,但我不确定如何获得时区...

java

-1
推荐指数
1
解决办法
45
查看次数

字符串替换所有不适用于$

我试图从第三方(蠢货)生成的HTML代码中删除某些"<"和">"

我正在为我们的ETL人员没有接收到的某些遗留条件做替换.

I have this string:  "<$200"  and I need it to be XML compliant like "&lt;$200"

string.replaceAll("<$200","&lt;$200");
Run Code Online (Sandbox Code Playgroud)

不起作用.我认为这是一些regEx的时髦.这样做的正确方法是什么?

java regex

-2
推荐指数
1
解决办法
104
查看次数