java - Spring keystore bean

标签 java spring keystore

在 spring.application 中,我指定了 keystore 名称和密码。 我想使用来自 java security 的 Signature.sign() 对一些数据进行签名,但为此我需要 Keystore。有没有办法获取 Spring 管理的 keystore bean,或者我是否必须创建自己的 keystore ,即使它已被 spring 使用?

最佳答案

你可以直接使用

@Autowired
private KeyStore keyStore;

如果你像这样在 XML/Java 配置中正确配置它

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:crypt="http://springcryptoutils.com/schema/crypt"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
                       http://springcryptoutils.com/schema/crypt http://springcryptoutils.com/schema/crypt.xsd">

    <crypt:keystore id="keystore"
                location="somePath}"
                password="somePassword"/>
</beans>

关于java - Spring keystore bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44285426/

相关文章:

java - 正则表达式匹配 "PATH environment variable"之类的字符串

java - 在 Spring Boot 中设置自己的安全性

android - 我要买一台新电脑,如何导出我的 Eclipse keystore ?请帮忙?

类对象的 Java vector

java - Future Cancel 是否也会终止数据库端的 Oracle 查询

java - Spring 启动测试 : @Sql annotation Unable to locate sql files placed in src/test/resources

位于 tomcat 库中的 Java keystore

android - 为什么我会得到 "Not a valid keystore file"错误

java - 如何从方法 Collectors.groupingBy 获取有序类型的 map

java - 如何将 Bean Validation (JSR 303) 约束显式分配给 bean 属性?