今天我将我正在处理的应用程序的spring安全版本从3.1.3升级到3.1.4,我注意到了org.springframework.security.authentication.encoding.ShaPasswordEncoder类上的弃用警告.
所以我切换到了新的org.springframework.security.crypto.password.StandardPasswordEncoder实现.
我有它工作,我能够注册一个新用户并登录我的应用程序,但是,我担心,我无法使用以前的ShaPasswordEncoder和我的自定义盐生成的密码登录.
由于我有一个已经注册了许多用户的数据库,我该怎么做才能切换实现而不会使旧的编码密码失效?它甚至可能吗?
我试图嘲笑restTemplate.exchangeSpring Rest 的方法.
在同一个测试中,我有多个调用,它们只有返回类型不同.
以下是我创建的模拟方法
第一
// Original method
restTemplate.exchange(UrlMap.SEARCH + '?' + searchDocsForm.toQueryParams(),
HttpMethod.GET, null, new ParameterizedTypeReference<SearchResultsDTO<SolrDocumentDTO>>() {
})
// Mock
when(restTemplate.exchange(any(String.class), any(HttpMethod.class), any(), Matchers.<ParameterizedTypeReference<SearchResultsDTO<SolrDocumentDTO>>>any())).thenReturn(
new ResponseEntity<>(searchResultsDTO, HttpStatus.OK));
Run Code Online (Sandbox Code Playgroud)
第二
// Original method
restTemplate.exchange(UrlMap.ALL_DOCUS_TOPICS,
HttpMethod.GET, null, new ParameterizedTypeReference<List<SelectItem>>() {
}).getBody();
// Mock
when(restTemplate.exchange(any(String.class), any(HttpMethod.class), any(), Matchers.<ParameterizedTypeReference<List<SelectItem>>>any())).thenReturn(
new ResponseEntity<>(selectItems, HttpStatus.OK));
Run Code Online (Sandbox Code Playgroud)
ParameterizedTypeReference模拟不考虑通用参数,最后定义的模拟胜过前者.
有没有办法使它工作?
我的配置在这里。
我根据帖子中的答案进行了一些修改。
filterMultipartResolver
@Bean
public StandardServletMultipartResolver filterMultipartResolver() {
return new StandardServletMultipartResolver();
}
Run Code Online (Sandbox Code Playgroud)
AppInitializer
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
// Create the 'root' Spring application context
final WebApplicationContext context = getContext();
// Manage the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(context));
final Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
dispatcher.setMultipartConfig(getMultipartConfigElement());
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
private static AnnotationConfigWebApplicationContext getContext() {
final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(AppConfig.class);
return context;
}
private …Run Code Online (Sandbox Code Playgroud) 我正在使用 WireMock 来模拟 SOAP 服务。
它工作得很好,但其中一项服务包含附件。有没有办法用 WireMock 来模拟它?
谢谢
我有一个应用程序,使用MySQL和通过REST,Neo4j服务器版本执行一些批处理作业.
我无法弄清楚如何让它们正确地协同工作:我可以让它们同时工作,但不能同时工作.我发现的帖子并不是特定于Neo4j的服务器版本,也许这就是问题所在,因为其他一切对我来说都没问题.
我的配置:
JpaConfig
@Configuration
@EnableTransactionManagement(order=Ordered.HIGHEST_PRECEDENCE)
@PropertySource("META-INF/database.properties")
@ImportResource("classpath*:META-INF/repository.xml")
public class JpaConfig {
@Autowired
Environment env;
@Bean(destroyMethod = "close")
public DataSource dataSource() {
DataSource dataSource = new DataSource();
dataSource.setDriverClassName(env.getProperty("database.driverClassName"));
dataSource.setUrl(env.getProperty("database.url"));
dataSource.setUsername(env.getProperty("database.username"));
dataSource.setPassword(env.getProperty("database.password"));
dataSource.setTestOnBorrow(true);
dataSource.setTestOnReturn(true);
dataSource.setTestWhileIdle(true);
dataSource.setTimeBetweenEvictionRunsMillis(1800000);
dataSource.setNumTestsPerEvictionRun(3);
dataSource.setMinEvictableIdleTimeMillis(1800000);
dataSource.setValidationQuery("SELECT 1");
return dataSource;
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
LocalContainerEntityManagerFactoryBean entityManagerFactory = new LocalContainerEntityManagerFactoryBean();
entityManagerFactory.setDataSource(dataSource());
entityManagerFactory.setPackagesToScan("it.smartblue.mcba.domain");
entityManagerFactory.setJpaDialect(new HibernateJpaDialect());
Map<String, String> jpaProperties = new HashMap<>();
jpaProperties.put("hibernate.connection.charSet", "UTF-8");
jpaProperties.put("hibernate.ejb.naming_strategy", "org.hibernate.cfg.EJB3NamingStrategy");
jpaProperties.put("hibernate.bytecode.provider", "javassist");
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.MySQL5InnoDBDialect");
entityManagerFactory.setJpaPropertyMap(jpaProperties);
entityManagerFactory.setPersistenceProvider(new HibernatePersistence());
return entityManagerFactory;
}
@Bean
public PlatformTransactionManager transactionManager() …Run Code Online (Sandbox Code Playgroud) 我正在使用Spring Framework 4.1.5,Spring Security 4.0.0.RC2,Spring Webflow 2.4.0.RELEASE和Tomcat 8.0.15.
我按照webflow 文档中的示例进行操作,但是我无法在表单bean中获取该文件.
表格
<form:form action="${flowExecutionUrl}" method="post" commandName="fileForm" enctype="multipart/form-data">
<form:input type="file" value="" path="multipartFileUpload"/>
<button type="submit" name="_eventId_forward"><spring:message code="signup.forward"/></button>
<sec:csrfInput/>
</form:form>
Run Code Online (Sandbox Code Playgroud)
表单bean
public class FileForm implements Serializable {
private static final long serialVersionUID = 1L;
private transient MultipartFile multipartFileUpload;
public MultipartFile getMultipartFileUpload() {
return multipartFileUpload;
}
public void setMultipartFileUpload(final MultipartFile multipartFileUpload) {
this.multipartFileUpload = multipartFileUpload;
}
}
Run Code Online (Sandbox Code Playgroud)
流动
<view-state id="companyLogo" view="signup/company-logo" model="fileForm">
<var name="fileForm" class="it.openex.pmcommonw.form.FileForm"/>
<transition on="back" to="chooseProfile" bind="false" validate="false"/>
<transition on="forward" to="companyInfo">
<evaluate …Run Code Online (Sandbox Code Playgroud)