4.3.1.Actionì ìí - Anyframe
4.3.1.Actionì ìí - Anyframe
4.3.1.Actionì ìí - Anyframe
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Authentication and Authorizationtry {conn = dataSource.getConnection();pstmt = conn.prepareStatement(sqlQuery);pstmt.setString(1, userId);pstmt.setString(2, password);// 입력된 사용자 정보를 기반으로 등록된 사용자 정보 검색rsu = pstmt.executeQuery();if (rsu.next()) {userId = rsu.getString(1);String userName = rsu.getString(2);rsu.getString(3);String grade = rsu.getString(5);Set principals = new HashSet();Set credentials = new HashSet();principals.add(new TypedPrincipal(userName, TypedPrincipal.USER));StringTokenizer tokens = new StringTokenizer(grade, ",");while (tokens.hasMoreTokens()) {principals.add(new TypedPrincipal(tokens.nextToken(),TypedPrincipal.GROUP));}}}// 사용자 정보를 Subject 객체에 저장subject = new Subject(false, principals, credentials,credentials);} else {throw new FailedLoginException();}}catch (Exception e) {// 중략 ...} finally {// 중략 ...}return subject;다음은 앞서 구현한 DBAuthenticationServiceImpl 클래스의 속성 정의 파일인 context-authentication.xml의 일부이다. USER_ID와 PASSWORD 정보를 이용하여 사용자 정보와 그룹(Role) 정보를 조회하는 쿼리문을 속성값으로 정의하고 있음을 알 수 있다. 해당 서비스는 이 쿼리문을 이용하게 될 것이다.다음은 LoginAction.java 로, 앞서 정의한 서비스를 이용하여 사용자의 유효성을 체크하고, 유효한 사용자 정보를 Session에 저장하는 역할을 수행하고 있다.60