2017-04-22 13 views
1

login.xhtml 페이지로 리디렉션되는 대신이 페이지를로드하려고 시도 할 때 index.jsp 페이지에서 인증을 적용하려고합니다. 나는 크롬 창에서 이것을 얻는다.JDBCRealm FORM 기반 인증이 로그인 페이지로 리디렉션되지 않음

:

this is realm tag from servlet.xml

<Realm className="org.apache.catalina.realm.JDBCRealm" 

     driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
    connectionURL="jdbc:sqlserver://DESKTOP-ND3EINK\SQLEXPRESS;databaseName=HRSystem;user=ram;password=ram" 

     userTable="HR.users" userNameCol="user_name" userCredCol="user_pass" 
    userRoleTable="HR.user_roles" roleNameCol="role_name"/> 

내가 바람둥이-users.xml에서

<role rolename="tomcat"/> 
    <role rolename="HRPersonnel"/> 

    <user username="tomcat" password="tomcat" roles="tomcat"/> 
    <user username="[email protected]" password="111111" roles="HRPersonnel"/> 

과의 web.xml에 사용자를 추가 한 것이다 영역 태그 server.xml에 추가

<security-constraint> 

     <display-name>SecurityConstraint</display-name> 

     <web-resource-collection> 
      <web-resource-name>foo bar</web-resource-name> 
      <url-pattern>/index.jsp</url-pattern> 
<!-- 
      <http-method>GET</http-method> 
      <http-method>PUT</http-method> 
      <http-method>POST</http-method> 
      <http-method>DELETE</http-method> --> 

     </web-resource-collection> 

     <auth-constraint> 
      <role-name>HRPersonnel</role-name> 
     </auth-constraint> 

     <user-data-constraint> 
      <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
     </user-data-constraint> 

    </security-constraint> 


    <login-config> 
     <auth-method> FORM</auth-method> 
     <realm-name>org.apache.catalina.realm.JDBCRealm</realm-name> 
     <form-login-config> 
      <form-login-page>/login2.xhtml</form-login-page> 
      <form-error-page>/error.xhtml</form-error-page> 
     </form-login-config> 
    </login-config> 

데이터베이스의 테이블입니다

create table HR.users(
name varchar(50), 
user_name varchar(50) primary key, 
user_pass varchar(50) not null, 
phone varchar (14), 
address varchar(100), 
) 

create table HR.user_roles (
    user_name   varchar(50) not null foreign key references HR.users(user_name), 
    role_name varchar(50) not null CHECK (role_name = 'Applicant' OR role_name = 'Manager' OR role_name = 'SME' or role_name = 'HRPersonnel') 

    primary key (user_name, role_name) 
); 

Catalina.log에는 경고가 있지만 오류는 없습니다.

22-Apr-2017 19:00:21.929 WARNING [main] org.apache.catalina.startup.ClassLoaderFactory.validateFile Problem with directory [C:\Program Files\Java\apache-tomcat-9.0.0.M13\bin\com.microsoft.sqlserver.jdbc.SQLServerDriver], exists: [false], isDirectory: [false], canRead: [false] 
+0

catalina.log를 표시하십시오. – minus

답변

0

그 이유를 모르지만

<user-data-constraint> 
      <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
     </user-data-constraint> 

것은 작동하지 않는, 나는 NONE에 기밀 변경하고 그것은 작동하기 시작했다.

-1

JDBCRealm을 정의하는 경우 DB에 사용자 테이블을 정의해야합니다.

사용자를 HR.users 테이블에 정의해야합니다.

자세한 내용은 catalina 로그 파일을 확인하십시오.

+0

나는 그것을 이미 정의했다. –