Hello, everyone.
I am new to Spring Security, so I got a problem with user registration. I have some AuthenticationJdbcDao with 2 methods addUser and addUserAuthority.
All I want to do is simply register new user like thisCode:public class AuthenticationJdbcDao extends JdbcDaoImpl implements AuthenticationDao { private static final String ADD_USER_QUERY = "INSERT INTO users (username, password, enabled) VALUES (?, ?, ?)"; private static final String ADD_USER_AUTHORITY_QUERY = "INSERT INTO authorities (username, authority) VALUES (?, ?)"; public void addUser(String name, String password) { getJdbcTemplate().update(ADD_USER_QUERY, new Object[] {name, password, true}); } public void addUserAuthority(String name, Authority authority) { getJdbcTemplate().update(ADD_USER_AUTHORITY_QUERY, new Object[] {name, authority.name()}); } }
But when I try invoke code above I getCode:User user = new User(); user.setName(name); userDao.save(user); String userId = "" + user.getId(); logger.debug("Trying add user with id " + userId); authenticationDao.addUser(userId, password); // <- exception here authenticationDao.addUserAuthority(userId, Authority.USER_ROLE);
Caused by: org.postgresql.util.PSQLException: ERROR: permission denied for relation users
at org.postgresql.core.v3.QueryExecutorImpl.receiveEr rorResponse(QueryExecutorImpl.java:1592)
at org.postgresql.core.v3.QueryExecutorImpl.processRe sults(QueryExecutorImpl.java:1327)
at org.postgresql.core.v3.QueryExecutorImpl.execute(Q ueryExecutorImpl.java:192)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execut e(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execut eWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execut eUpdate(AbstractJdbc2Statement.java:304)
at org.apache.commons.dbcp.DelegatingPreparedStatemen t.executeUpdate(DelegatingPreparedStatement.java:1 02)
at org.springframework.jdbc.core.JdbcTemplate$2.doInP reparedStatement(JdbcTemplate.java:798)
at org.springframework.jdbc.core.JdbcTemplate.execute (JdbcTemplate.java:591)
... 38 more
I would be very thankful if anyone could explain me how can get rid of it.


