我有一个简单的应用程序,我可以注册用户并验证它们.我已经使用密码编码并成功验证了它们.我在我的应用程序中使用Spring 3,Spring Security 3和Hibernate 3.
现在我想用他们的用户ID来限制他们的密码,但是我无法实现这个功能.有人可以帮我实现吗?我一直试图这么做但却无法完成它.
这是我用来为用户提供ID并对其进行身份验证的代码.
XYZ-security.xml文件
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/welcome.do" access="hasRole('ROLE_USER')" />
<form-login login-page="/login.do" authentication-failure-url="/login.do?login_error=1"/>
<logout invalidate-session="true" logout-url="/logout" logout-success-url="/"/>
</http>
<beans:bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="userDetailsService"/>
</beans:bean>
<beans:bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
<beans:property name="providers">
<beans:list>
<beans:ref local="daoAuthenticationProvider" />
</beans:list>
</beans:property>
</beans:bean>
<authentication-manager>
<authentication-provider user-service-ref="userDetailsService">
<password-encoder ref="passwordEncoder">
<salt-source ref="saltSource"/>
</password-encoder>
</authentication-provider>
</authentication-manager>
<!-- For hashing and salting user passwords -->
<beans:bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.ShaPasswordEncoder"/>
<beans:bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource"
p:userPropertyToUse="id"/>
Run Code Online (Sandbox Code Playgroud)
UserDetailsAdapter.java
@Service("userDetailsAdapter")
public class UserDetailsAdapter {
private Long id;
org.springframework.security.core.userdetails.User buildUserFromUserEntity(User userEntity) { …Run Code Online (Sandbox Code Playgroud) 我无法javax.jms.ConnectionFactory注入我的独立JMS客户端.我得到一个java.lang.NullPointerException在connectionFactory.createConnection()下面的代码.
JmsClient.java
public class JmsClient {
@Resource(mappedName="jms/QueueConnectionFactory")
private static ConnectionFactory connectionFactory;
@Resource(mappedName="jms/ShippingRequestQueue")
private static Destination destination;
public static void main(String[] args) {
try {
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
ObjectMessage message = session.createObjectMessage();
ShippingRequestQueue shippingRequest = new ShippingRequestQueue(1, "107, Old Street");
message.setObject(shippingRequest);
producer.send(message);
session.close();
connection.close();
System.out.println("Shipping request message sent ..");
} catch (Throwable ex) {
ex.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我使用Glassfish 3.1管理控制台在Open MQ(MoM)上创建了相应的连接工厂和目标资源.
有人能帮我理解我错过了什么吗?
我无法在eclipse ide中运行maven java web应用程序项目到配置的tomcat.
最初我可以右键单击项目并在tomcat服务器上运行它,但自从我将项目共享到存储库后,我无法做到这一点.
我将项目从存储库中断开,现在我甚至看不到eclipse ide中的Run as - > Run on Server选项.
我正在使用m2e插件版本.0.12.1和eclipse helios和tomcat 6.
有人能帮助我理解我在这里缺少什么吗?
谢谢.
我如何使用 @NamedQuery 来获取定义为 LocalDateTime 类型的 LocalDate 类型的列。我该怎么做?
我编写了一个Web服务并将其部署在Glassfish 3.1上,但我无法在" Action "列下看到" View Endpoint "链接.我在' myapp ' 下的' Application '下的' http:// localhost:4848 / ' 处使用' Glassfish 3.1管理工具 '.在部署了Web服务之后,我确实在" 引擎 " 列下添加了" webservices ".我需要该链接来查找" Web服务端点信息 ",以便我可以使用Glassfish 3.1提供的测试器功能查看WSDL并测试Web服务.
有人能帮助我了解whay我不是能看到" 查看端点 "的"下链接行动的"列通用 "部分.
谢谢.
我正在编码接口.
我有一个接口A和一个实现它的B类.
有人告诉我,我可以覆盖B的通过扩展它的功能Ç但我问摸既不乙也不Ç,再后来代替乙与ç作为实现类的一个在配置文件中.
我想,我需要的,是不是在使用方法一,所以我需要一个方法添加到一个我能在实现Ç.但我不准碰一个.
有人可以帮助我完成它吗?
谢谢.
编辑: 示例代码:
A.java
public interface A {
void X();
void Y();
}
Run Code Online (Sandbox Code Playgroud)
B.java
public class B implements A {
public void X() {//something interesting}
public void Y() {//something not very interesting}
}
Run Code Online (Sandbox Code Playgroud)
现在因为我不被允许触摸任何一个A或者B我必须写另一个类C并从B扩展它来做我的事情.
C.java
public class C extends B {
public …Run Code Online (Sandbox Code Playgroud) 我已经完成了使用Nodemailer和AngularJS以及NodeJS发送电子邮件的基本电子邮件设置,我已经在heroku上部署了项目.
当我在heroku上运行应用程序时,电子邮件似乎工作得很好,但是当我将它部署到Heroku时,没有发送电子邮件.
为了验证我使用的是gmail地址,我还有bcc另一个gmail地址.因此from,bcc地址是两个不同的Gmail地址.该from地址与用于身份验证的地址相同.
有人可以帮我解决这个问题吗?
编辑:添加代码
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: 'foobar@gmail.com',
pass: 'foobar'
}
});
router.post('/send',function(req,res){
var mailOptions = {
from: 'Foo Bar ? <foobar@gmail.com>',
to: req.body.email,
subject: "Hello " + req.body.email,
text: 'Hello ' + req.body.email + '?',
html: "<p>Hello " + req.body.email + " </p>",
bcc: "fred@gmail.com"
};
transporter.sendMail(mailOptions, function(error, info){
if(error){
console.log(error);
}else{
console.log('Message sent: ' + info.response);
res.send(200);
}
}); …Run Code Online (Sandbox Code Playgroud) 情况是这样的:
我有一个实体书,与章保持一对多的关系.
现在,如果我尝试查询" from Book book inner join book.chapters chapter where chapter.title like '%hibernate%'",它会给我想要的结果.
但是,如果我尝试," from Book where book.chapters.title like '%hibernate%'",我得到错误非法尝试取消引用收集.
问题是我只想要Book对象的集合,而不是我对前一个查询得到的Book和Chapter对象的集合.
有人可以帮我理解吗?
有人可以告诉我stmt.close();,以下JDBC代码中是否需要首先针对两个不同的表执行两个不同的SQL查询?
public class MyService {
private Connection connection = null;
public void save(Book book) {
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "password");
PreparedStatement stmt = connection.prepareStatement("INSERT INTO PUBLISHER (CODE, PUBLISHER_NAME) VALUES (?, ?)");
stmt.setString(1, book.getPublisher().getCode());
stmt.setString(2, book.getPublisher().getName());
stmt.executeUpdate();
stmt.close(); //1
stmt = connection.prepareStatement("INSERT INTO BOOK (ISBN, BOOK_NAME, PUBLISHER_CODE) VALUES (?, ?, ?)");
stmt.setString(1, book.getIsbn());
stmt.setString(2, book.getName());
stmt.setString(3, book.getPublisher().getCode());
stmt.executeUpdate();
stmt.close(); //2
} catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); }
finally { connection.close(); …Run Code Online (Sandbox Code Playgroud) hibernate ×4
glassfish-3 ×2
java ×2
jpa ×2
angularjs ×1
deployment ×1
eclipse ×1
email ×1
heroku ×1
hql ×1
inheritance ×1
interface ×1
java-ee-6 ×1
jdbc ×1
jms ×1
localdate ×1
m2eclipse ×1
mapping ×1
named-query ×1
node.js ×1
nodemailer ×1
one-to-one ×1
salt ×1
sql ×1
tomcat6 ×1
web-services ×1