操作系统:Windows 7 x64
Eclipse平台:3.7.2.M20120208
m2e:1.0.200.20111228-1245
有这个bug的类似问题.package-info.java文件/src和/test文件夹中有一堆文件,所以它们有相同的包.Eclipse显示错误:
"The type **package-info** is already defined"
Run Code Online (Sandbox Code Playgroud)
我可以删除package-info.java文件/test或/src避免问题指示.但是这种解决方法不太舒服,因为我使用SCM并且需要在更新后一直删除这些文件.同为Eclipse平台4.2.0.I20120608-1400
简单的问题:在成功身份验证中向HttpSession添加属性(属性)的最佳方法是什么?例如,userID.
现在我在UsernamePasswordAuthenticationFilter中使用我自己的SimpleUrlAuthenticationSuccessHandler实现并按如下方式执行:
public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication auth)
throws IOException, ServletException {
PersonBean person = (PersonBean) auth.getPrincipal();
request.getSession().setAttribute("currentUserId", person .getId().toString());
super.onAuthenticationSuccess(request, response, auth);
Run Code Online (Sandbox Code Playgroud)
但我不认为这是一种很好的方法,因为有另一种方法可以进行身份验证(例如,RememberMe).
那么我需要在这里使用什么?
使用密码编码的简单Spring Security webapp:
<security:authentication-manager alias="authenticationManager">
<security:authentication-provider user-service-ref="personService">
<security:password-encoder hash="md5" ref="passwordEncoder">
<!-- <security:salt-source user-property="username"/> -->
</security:password-encoder>
</security:authentication-provider>
</security:authentication-manager>
Run Code Online (Sandbox Code Playgroud)
编码也很简单:
person.setPassword(encoder.encodePassword(person.getPassword(), null));
Run Code Online (Sandbox Code Playgroud)
所以在DataBase中,所有密码都将被编码.现在我想在apllication中使用某个用户名对某些用户进行身份验证.之前(当密码是纯文本时)它是这样的:
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
username, password);
Authentication authentication = authenticationManager.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(authentication);
Run Code Online (Sandbox Code Playgroud)
但现在我从DB获得编码密码,并且不能像以前一样进行身份验证.
问题.Spring不知道密码来自已编码的UsernamePasswordAuthenticationToken.他正在第二次编码.谁可以帮忙?
编辑
所以我在这看到两个解决方案:
还有其他人?哪个最好?
抱歉非常愚蠢的问题.我正在使用Morphia 1.00.有一些实体:
@Entity("Vacancy")
public class Vacancy {
@Id
private ObjectId id;
@Version
long version;
private String title;
Run Code Online (Sandbox Code Playgroud)
和其他一些领域,二传手和吸气剂.试图保存相同的实例:
Vacancy vacancy1 = new Vacancy();
vacancy1.setTitle("Dumm");
Vacancy vacancy2 = new Vacancy();
vacancy2.setTitle("Dumm");
vacancyDao.getDatastore().save(vacancy1);
vacancyDao.getDatastore().save(vacancy2);
Run Code Online (Sandbox Code Playgroud)
据我所知,mongoDb必须执行upsert命令(意思是"如果存在则更新;如果缺少则插入(单个文档)").但是,mongo不是仅仅更新_id字段,而是在DB中保存新实体.
我无法找到如何创建HttpServletRequest中的java.security.Principal - 谁负责?怎么做的?是否必须保留在Session中?
它是如何连接到Spring Security的?
是否有使用Principal进行用户授权/身份验证的Spring Security的替代方案?
如何实现自己的用户授权/身份验证,以便Principal包含当前用户?
java authentication model-view-controller authorization spring-security
在RCP应用程序中使用某种DI的最简单方法是什么?我需要注册依赖项并在应用程序的不同部分使用它们:向导,对话框,属性页等.
我拥有的东西:带有大量插件的产品.
我需要的是:在Eclipse RCP产品开始时,我需要读取一些文件,将这些数据保存在内存中,并使其可以访问不同的UI元素(在不同的插件中)而不使用单例.
在创建消费者时,我无法在构造函数中传递此数据,因为消费者是通常由RCP平台创建的UI元素,我没有直接访问它们的创建.
当使用SVMlight或LIBSVM为了将短语分类为正面或负面时(情感分析),有没有办法确定哪些是影响算法决策的最有影响力的单词?例如,发现该单词"good"有助于将短语确定为正面等.
nlp machine-learning svm sentiment-analysis text-classification