powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / проблемы с реализацией Spring Security
4 сообщений из 4, страница 1 из 1
проблемы с реализацией Spring Security
    #39022176
goldenhawk
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Пытаюсь реализовать spring-security.
При аутентификации я обращаюсь к базе данных, где проверяю логин и пароль в контроллере.
в role есть два значения admin и user.

У меня такие страницы и такие права хочу сделать.
В таблице Users находится login, password, role (текстовое поле admin или user)

Колонки ID_USER,EMAIL,LOGIN,PASSWORD,ROLE
Значения 1,Alexmail.ru,Alex,123,admin

url адреса
/nhlcup/login -admin,user
/nhlcup/logout -admin,user
/nhlcup/products -admin,user
/nhlcup/products/create -admin
/nhlcup/products/*/update -admin
/nhlcup/myproducts -admin,user
/nhlcup/products/*/buy -admin,user


Сейчас вылетает такой ексепшн

PreparedStatementCallback; uncategorized SQLException for SQL [select u.login,u.password from zzz.users u where u.login=?]; SQL state [90008]; error code [90008]; Недопустимое значение "3" для параметра "columnIndex"

spring-security.xml
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
<beans:beans xmlns="http://www.springframework.org/schema/security"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
	http://www.springframework.org/schema/security
	http://www.springframework.org/schema/security/spring-security-4.0.xsd">
		
	<!-- enable use-expressions -->
	<http auto-config="true" use-expressions="true">
		<intercept-url pattern="/myproducts*" access="hasAnyRole('admin','user')" />
		<intercept-url pattern="/products/create*" access="hasAnyRole('admin')" />
		<intercept-url pattern="/products/*" access="hasAnyRole('admin','user')" />
		<intercept-url pattern="/products/*/*" access="hasAnyRole('admin','user')" />
		
		<!-- access denied page -->
		<access-denied-handler error-page="/403" />
		<form-login 
		    login-page="/login" 
		    default-target-url="/products" 
			authentication-failure-url="/login" 
			username-parameter="login"
			password-parameter="password" />
		<logout logout-success-url="/products"  />
		
	</http>
	
	<!-- Select users and user_roles from database -->
	<authentication-manager>
		<authentication-provider>
			<jdbc-user-service data-source-ref="dataSource"
				users-by-username-query=
					"select u.login,u.password  from zzz.users u where u.login=? "
				authorities-by-username-query=
					"select u.login,u.password, u.role from zzz.users u where login =? and u.password=? " />
		</authentication-provider>
	</authentication-manager>

</beans:beans>



pom.xml

Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
  <dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-web</artifactId>
			<version>4.0.0.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-config</artifactId>
			<version>4.0.0.RELEASE</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.security</groupId>
			<artifactId>spring-security-core</artifactId>
			<version>4.0.0.RELEASE</version>
		</dependency>




web.xml
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
<filter>
		<filter-name>springSecurityFilterChain</filter-name>
		<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>springSecurityFilterChain</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
...
Рейтинг: 0 / 0
проблемы с реализацией Spring Security
    #39022184
goldenhawk
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Выложил архив своего проекта
...
Рейтинг: 0 / 0
проблемы с реализацией Spring Security
    #39022281
Atum1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
тут полные примеры как нужно делать :

https://github.com/spring-projects/spring-security/tree/master/samples


http://habrahabr.ru/post/203318/
...
Рейтинг: 0 / 0
проблемы с реализацией Spring Security
    #39023903
goldenhawk
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Сделал таблицу ZZZ.USERS
Колонки ID_USER,EMAIL,LOGIN,PASSWORD,ROLE,ENABLED( все значения 1)

Ввожу логин и пароль , страница логина просто обновляется.
И как сделать, чтобы страница логина отображалась как у меня в jsp , а не стандартная ?
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / проблемы с реализацией Spring Security
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]