JAAS를 위한 시스템 로그인 구성을 위한 사용자 정의 로그인 모듈 개발
WebSphere® Application Server의 경우 여러 Java™ Authentication and Authorization Service(JAAS) 플러그인 지점은 시스템 로그인 구성을 위해 존재합니다. WebSphere Application Server는 시스템 로그인 구성을 사용하여 수신 요청, 나가는 요청 및 내부 서버 로그인을 인증합니다.
이 태스크 정보
- WEB_INBOUND
- RMI_OUTBOUND
- RMI_INBOUND
- DEFAULT
프로시저
- WEB_INBOUND 로그인 구성을 사용하여 웹 요청을 인증하십시오.
WEB_INBOUND 로그인 구성이 웹 요청을 인증합니다.
해당 연관된 콜백을 포함하여 WEB_INBOUND 구성에 대한 m자세한 정보는 JAAS(Java Authentication and Authorization Service)의 시스템 로그인 구성 항목 설정에서 "RMI_INBOUND, WEB_INBOUND, DEFAULT"를 참조하십시오.
그림 1은 WEB_INBOUND 로그인 구성으로 전달되는 초기 정보로 제목을 작성하는 신뢰 연관 인터셉터(TAI)를 사용하는 구성의 예를 보여줍니다. 신뢰 연관 인터셉터가 구성되지 않은 경우에는 인증 프로세스는 WEB_INBOUND 시스템 로그인 구성으로 직접 이동하고, 이는 그림 1에 결합된 모든 로그인 모듈로 구성되어 있습니다. 그림 1은 사용자 정의 로그인 모듈을 플러그인할 수 있는 위치와 ltpaLoginModule 및 wsMapDefaultInboundLoginModule 로그인 모듈이 필요한 위치를 보여줍니다.그림 1. WEB_INBOUND 로그인 구성 - RMI_OUTBOUND 로그인 구성으로 아웃바운드 요청을 처리하십시오.
RMI_OUTBOUND 로그인 구성은 아웃바운드 요청을 처리하기 위한 플러그 지점입니다. WebSphere Application Server는 이 플러그 지점을 사용하여 전달된 호출 제목을 기반으로 하여 다운스트림으로 전송된 일련화된 정보 및 전파 토큰 등과 같은 다른 보안 컨텍스트 정보를 작성합니다. 사용자 정의 로그인 모듈은 이 플러그 지점을 사용하여 ID를 변경할 수 있습니다. 자세한 정보는 다른 대상 영역에 아웃바운드 ID 맵핑 구성의 내용을 참조하십시오. 그림 2는 사용자 정의 로그인 모듈을 플러그인할 수 있는 위치를 보여주고 wsMapCSIv2OutboundLoginModule 로그인 모듈이 필요한 위치를 보여줍니다.
그림 2. RMI_OUTBOUND 로그인 구성해당 연관된 콜백을 포함하여 RMI_OUTBOUND 로그인 구성에 대한 자세한 정보는 JAAS(Java Authentication and Authorization Service)의 시스템 로그인 구성 항목 설정에서 "RMI_OUTBOUND"를 참조하십시오.
- RMI_INBOUND 로그인 구성이 있는 엔터프라이즈 Bean 요청을 위한 인바운드 인증을 처리하십시오.
RMI_INBOUND 로그인 구성은 엔터프라이즈 Bean 요청의 인바운드 인증을 처리하는 플러그 지점입니다. WebSphere Application Server는 초기 로그인 또는 전파 로그인을 위해 이 플러그 지점을 사용합니다. 두 개의 로그인 유형에 대한 자세한 정보는 보안 속성 전파의 내용을 참조하십시오. 전파 로그인 동안 이 플러그 지점은 업스트림 서버에서 받은 정보를 일련화 해제하는 데 사용됩니다. 사용자 정의 로그인 모듈은 이 플러그 지점을 사용하여 ID를 변경하고, 사용자 정의 토큰을 처리하고, 사용자 정의 오브젝트를 제목에 추가하는 등등을 수행합니다. 그림 3에 참조된 해시 테이블 오브젝트를 사용하여 ID를 변경하는 방법에 대한 자세한 정보는 인바운드 ID 맵핑 구성의 내용을 참조하십시오. 그림 3은 사용자 정의 로그인 모듈을 플러그인할 수 있는 위치를 보여주고 ltpaLoginModule 및 wsMapDefaultInboundLoginModule 로그인 모듈이 필요함을 보여줍니다.
그림 3. RMI_INBOUND 로그인 구성해당 연관된 콜백을 포함하여 RMI_INBOUND 구성에 대한 자세한 정보는 JAAS(Java Authentication and Authorization Service)의 시스템 로그인 구성 항목 설정에서 "RMI_INBOUND, WEB_INBOUND, DEFAULT"를 참조하십시오.
- DEFAULT 로그인 구성이 있는 다른 모든 인증 요청 유형을 처리하십시오. DEFAULT 로그인 구성
DEFAULT 로그인 구성은 관리 SOAP 요청 및 서버 ID의 내부 인증을 포함하여 다른 모든 인증 요청 유형을 처리하는 플러그인 지점입니다. 전파 로그인은 일반적으로 이 플러그 지점에서는 발생하지 않습니다.
해당 연관된 콜백을 포함하여 DEFAULT 로그인 구성에 대한 자세한 정보는 JAAS(Java Authentication and Authorization Service)의 시스템 로그인 구성 항목 설정에서 "RMI_INBOUND, WEB_INBOUND, DEFAULT"를 참조하십시오.
- 특정 정보가 언제 존재하는지와 이 정보를 사용하는 방법에 대해 알고 싶으면 로그인
구성 로직을 개발하십시오. 로그인 모듈 쓰기WebSphere Application Server 애플리케이션 로그인 또는 시스템 로그인 구성에 플러그인되는 로그인 모듈을 쓸 때 http://java.sun.com/products/jaas에 있는 JAAS 프로그래밍 모델을 읽으십시오. JAAS 프로그래밍 모델은 JAAS에 대한 기본 정보를 제공합니다. 그러나 WebSphere Application Server 환경에 대한 로그인 모듈을 쓰기 전에 다음 섹션을 읽으십시오.
- 사용 가능한 콜백
- 공유된 상태 변수
- 초기 대 전파 로그인
- 샘플 사용자 정의 로그인 모듈
사용 가능한 콜백
각 로그인 구성은 로그인 구성에 의해 인지되는 콜백을 문서화해야 합니다. 그러나 콜백은 항상 데이터를 전달하지는 않습니다. 로그인 구성에는 언제 특정 정보가 존재하는지와 정보를 사용하는 방법에 대해서 알기 위해서는 로직을 포함해야 합니다. 예를 들어, 앞서 언급된 사전 구성된 시스템 로그인 구성 네 개 모두에 플러그인할 수 있는 사용자 정의 로그인 모듈을 쓰는 경우에는 콜백의 세 세트가 요청을 인증하게 위해 표시될 수도 있습니다. 다른 콜백은 전파 및 다른 정보를 로그인 구성에 사용 가능하게 만드는 등의 이유로 표시될 수도 있습니다.
로그인 정보는 다음 조합으로 표시될 수 있습니다.- 사용자 이름(NameCallback) 및 비밀번호(PasswordCallback)
- 이 정보는 일반적인 인증 조합입니다.
- 사용자 이름만(NameCallback)
- 이 정보는 ID 어설션, 신뢰 연관 인터셉터(TAI) 로그인 및 인증서 로그인에 사용됩니다.
- 토큰(WSCredTokenCallbackImpl)
- 이 정보는 LTPA(Lightweight Third Party Authentication) 토큰 유효성 검증을 위한 것입니다.
- 전파 토큰 목록(WSTokenHolderCallback)
- 이 정보는 전파 로그인에 사용됩니다.
처음 세 개의 조합은 일반 인증에 사용됩니다. 그러나 WSTokenHolderCallback 콜백이 처음 세 개의 정보 조합 중 하나에 추가로 표시되면 로그인은 전파 로그인이라고 불립니다. 전파 로그인은 일부 보안 속성이 또 다른 서버로부터 이 서버로 전파됨을 의미합니다. 인증 정보가 성공적으로 유효성 검증하면 서버는 이러한 보안 속성을 재사용할 수 있습니다. 일부 경우에 WSTokenHolderCallback 콜백은 전체 로그인을 위한 충분한 속성이 없을 수도 있습니다. 새 로그인이 필요한지 판별하려면 WSTokenHolderCallback 콜백에서 requiresLogin 메소드를 확인하십시오. 언제든지 requiresLogin 메소드가 리턴하는 정보를 무시할 수 있지만 그 결과로 정보가 중복될 수 있습니다. 다음 목록에는 시스템 로그인 구성에 표시될 수도 있는 콜백이 포함됩니다. 목록에는 콜백 이름과 책임에 대한 설명이 포함됩니다.- callbacks[0] = 새 javax.security.auth.callback.NameCallback("사용자 이름: ");
- 이 콜백 핸들러는 로그인을 위해 사용자 이름을 수집합니다. 결과는 기본 인증 로그인(사용자 이름 및 비밀번호)를 위한 사용자 이름이거나 어설션 로그인을 위한 사용자 이름일 수 있습니다.
- callbacks[1] = 새 javax.security.auth.callback.PasswordCallback("비밀번호: ", false);
- 이 콜백 핸들러는 로그인을 위한 비밀번호를 수집합니다.
- callbacks[2] = 새 com.ibm.websphere.security.auth.callback.WSCredTokenCallbackImpl("신임 토큰:");
- 이 콜백 핸들러는 LTPA(Lightweight Third Party Authentication) 토큰 또는 로그인을 위한 다른 토큰 유형을 수집합니다. 이 콜백 핸들러는 일반적으로 사용자 이름과 비밀번호가 존재하지 않을 때 존재합니다.
- callbacks[3] = 새 com.ibm.wsspi.security.auth.callback.WSTokenHolderCallback("인증 토큰 목록:");
- 이 콜백 핸들러는 Common Secure Interoperability Version 2(CSIv2) 인증 토큰을 입력으로 사용하여 호출에서 WSOpaqueTokenHelper.createTokenHolderListFromOpaqueToken API로 리턴되는 TokenHolder 오브젝트의 ArrayList를 수집합니다.
- callbacks[4] = 새 com.ibm.websphere.security.auth.callback.WSServletRequestCallback("HttpServletRequest:" );
- 이 콜백 핸들러는 HTTP 서블릿 요청 오브젝트(있는 경우)를 수집합니다. 이 콜백 핸들러를 사용하면 로그인 모듈이 로그인에 사용하기 위해 HTTP 요청으로부터 정보를 구할 수 있고, WEB_INBOUND 로그인 구성에서만 표시됩니다.
- callbacks[5] = 새 com.ibm.websphere.security.auth.callback.WSServletResponseCallback("HttpServletResponse:");
- 이 콜백 핸들러는 HTTP 서블릿 응답 오브젝트(있는 경우)를 수집합니다. 이 콜백 핸들러를 사용하면 로그인 모듈이 로그인의 결과로서 정보를 HTTP 응답에 넣을 수 있습니다. 이 상황의 예제는 SingleSignonCookie 쿠키를 응답에 추가하는 것일 수 있습니다. 이 콜백 핸들러는 WEB_INBOUND 로그인 구성에서만 표시됩니다.
- callbacks[6] = 새 com.ibm.websphere.security.auth.callback.WSAppContextCallback("ApplicationContextCallback:");
- 이 콜백 핸들러는 로그인 중에 사용되는 웹 애플리케이션 컨텍스트를 수집합니다. 이 콜백 핸들러는 애플리케이션 이름 및 경로 재지정 웹 주소(있는 경우)를 포함하는 HashMap 오브젝트로 구성됩니다. 콜백 핸들러는 WEB_INBOUND 로그인 구성에서만 표시됩니다.
- callbacks[7] = 새 WSRealmNameCallbackImpl("영역 이름:", default_realm);
- 이 콜백 핸들러는 로그인 정보의 영역 이름을 수집합니다. 영역 정보는 항상 제공되지는 않을 수도 있습니다. 영역 정보가 제공되지 않으면 현재 영역이라고 가정하십시오.
- callbacks[8] = 새 WSX509CertificateChainCallback("X509Certificate[]: ");
- 이 콜백 핸들러에는 로그인 소스가 SSL 클라이언트 인증으로부터의 X509Certificate인 경우 SSL(Secure Sockets Layer)에 의해 유효성 검증된 인증이 포함됩니다. ltpaLoginModule은 버전 6.1 이전의 WebSphere Application Server 릴리스와 동일한 맵핑 함수를 호출합니다. 그러나, 이를 로그인으로 전달하면 사용자 정의 로그인 모듈에 인증서를 사용자 정의 방식으로 맵핑할 수 있는 기회를 제공합니다. 그런 다음 해시 테이블 로그인을 수행합니다. 해시 테이블 로그인에 대한 자세한 정보는 인바운드 ID 맵핑 구성의 내용을 참조하십시오.
- 로그인 단계(Phase) 동안 로그인 모듈 간에 정보를 공유하려면
공유된 상태 변수를 사용하십시오. WebSphere Application Server가 로그인 중에 작성한 오브젝트에 액세스하려면 다음 공유된 상태 변수를 참조하십시오. 변수는 ltpaLoginModule, swamLoginModule 및 wsMapDefaultInboundLoginModule의 로그인 모듈에 설정됩니다.
- 공유 상태 변수
- com.ibm.wsspi.security.auth.callback.Constants.WSPRINCIPAL_KEY
- 목적
- com.ibm.websphere.security.auth.WSPrincipal 오브젝트를 지정합니다. API(Application Programming Interface) 사용법에 대한 WebSphere Application Server API 문서를 참조하십시오. 이 공유 상태 변수는 읽기 전용 용도입니다. 이 변수를 사용자 정의 로그인 모듈을 위한 공유 상태에 설정하지 마십시오.
- 변수가 설정되는 로그인 모듈
- ltpaLoginModule, swamLoginModule 및 wsMapDefaultInboundLoginModule
- 공유 상태 변수
- com.ibm.wsspi.security.auth.callback.Constants.WSCREDENTIAL_KEY
- 목적
- com.ibm.websphere.security.cred.WSCredential 오브젝트를 지정합니다. API 사용법에 대한 WebSphere Application Server API 문서를 참조하십시오. 이 공유 상태 변수는 읽기 전용 용도입니다. 이 변수를 사용자 정의 로그인 모듈을 위한 공유 상태에 설정하지 마십시오.
- 변수가 설정되는 로그인 모듈
- wsMapDefaultInboundLoginModule
- 공유 상태 변수
- com.ibm.wsspi.security.auth.callback.Constants.WSAUTHZTOKEN_KEY
- 목적
- 기본 com.ibm.wsspi.security.token.AuthorizationToken 오브젝트를 지정합니다. 로그인 모듈은 이 오브젝트를 사용하여 wsMapDefaultInboundLoginModule 로그인 모듈 뒤에 플러그인 된 사용자 정의 속성을 설정할 수 있습니다. 여기에 설정된 정보는 다운스트림으로 전파되고 애플리케이션에서 사용 가능합니다. API 사용법에 대한 WebSphere Application Server API 문서를 참조하십시오.
초기 대 전파 로그인
앞서 언급한 대로, 일부 로그인은 다음 이유로 인해 초기 로그인으로 간주됩니다.- WebSphere Application Server에 처음 인증 정보가 제공됩니다.
- 로그인 정보는 보안 속성을 전파하지 않는 서버로부터 수신되므로 이 정보는 사용자 레지스트리로부터 수집되어야 합니다.
WSTokenHolderCallback 콜백이 존재하고 발신 서버로부터 WebSphere Application Server 런타임이 필요로 하는 모든 필수 오브젝트를 재작성하기에 충분한 정보를 포함하는 경우에는 또 다른 로그인은 전파 로그인으로 간주됩니다. WebSphere Application Server 런타임을 위한 충분한 정보가 있는 경우에는 사용자가 제목에 추가한 정보는 이전 로그인부터 존재했을 수 있습니다. 오브젝트가 존재하는지 검증하기 위해 WSTokenHolderCallback 콜백에 있는 ArrayList 오브젝트에 대한 액세스를 구하고 각 이 목록을 검색하여 각 TokenHolder getName 메소드를 볼 수 있습니다. 이 검색은 WebSphere Application Server가 이 로그인 중에 사용자 정의 오브젝트를 일련화 해제하는지 여부를 판별하는 데 사용됩니다. 런타임이 어떤 제목이 일련화 해제 후에 사용자 정의 오브젝트를 추가하도록 설정되어 있는지를 알기 위해 이름 끝에 추가 정보를 추가할 수 있으므로 startsWith 메소드 문자열을 사용하여 getName 메소드로부터 반환된 클래스 이름을 확인하십시오.
- 충분한 정보가 존재하는 시기를 판별하려면 login() 메소드를 코딩하십시오.
다음 코드 스니펫은 언제 충분한 정보가 존재하는지를 판별하기 위해 login() 메소드에 사용될 수 있습니다. 또 다른 예는 인바운드 ID 맵핑 구성의 내용을 참조하십시오.
// This is a hint provided by WebSphere Application Server that // sufficient propagation information does not exist and, therefore, // a login is required to provide the sufficient information. In this // situation, a Hashtable login might be used. boolean requiresLogin = ((com.ibm.wsspi.security.auth.callback. WSTokenHolderCallback) callbacks[1]).requiresLogin(); if (requiresLogin) { // Check to see if your object exists in the TokenHolder list, if not, add it. java.util.ArrayList authzTokenList = ((WSTokenHolderCallback) callbacks[6]). getTokenHolderList();boolean found = false; if (authzTokenList != null) { Iterator tokenListIterator = authzTokenList.iterator(); while (tokenListIterator.hasNext()) { com.ibm.wsspi.security.token.TokenHolder th = (com.ibm.wsspi.security.token. TokenHolder) tokenListIterator.next(); if (th != null && th.getName().startsWith("com.acme.myCustomClass")) { found=true; break; } } if (!found) { // go ahead and add your custom object. } } } else { // This code indicates that sufficient propagation information is present. // User registry calls are not needed by WebSphere Application Server to // create a valid Subject. This code might be a no-op in your login module. }
샘플 사용자 정의 로그인 모듈
다음 샘플을 사용하여 일부 콜백 및 공유된 상태 변수를 사용하는 방법에 대한 아이디어를 얻을 수 있습니다.
{ // Defines your login module variables com.ibm.wsspi.security.token.AuthenticationToken customAuthzToken = null; com.ibm.wsspi.security.token.AuthenticationToken defaultAuthzToken = null; com.ibm.websphere.security.cred.WSCredential credential = null; com.ibm.websphere.security.auth.WSPrincipal principal = null; private javax.security.auth.Subject _subject; private javax.security.auth.callback.CallbackHandler _callbackHandler; private java.util.Map _sharedState; private java.util.Map _options; public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { _subject = subject; _callbackHandler = callbackHandler; _sharedState = sharedState; _options = options; } public boolean login() throws LoginException { boolean succeeded = true; // Gets the CALLBACK information javax.security.auth.callback.Callback callbacks[] = new javax.security. auth.callback.Callback[7]; callbacks[0] = new javax.security.auth.callback.NameCallback( "Username: "); callbacks[1] = new javax.security.auth.callback.PasswordCallback( "Password: ", false); callbacks[2] = new com.ibm.websphere.security.auth.callback. WSCredTokenCallbackImpl ("Credential Token: "); callbacks[3] = new com.ibm.wsspi.security.auth.callback. WSServletRequestCallback ("HttpServletRequest: "); callbacks[4] = new com.ibm.wsspi.security.auth.callback. WSServletResponseCallback ("HttpServletResponse: "); callbacks[5] = new com.ibm.wsspi.security.auth.callback. WSAppContextCallback ("ApplicationContextCallback: "); callbacks[6] = new com.ibm.wsspi.security.auth.callback. WSTokenHolderCallback ("Authz Token List: "); try { callbackHandler.handle(callbacks); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } // Sees which callbacks contain information uid = ((NameCallback) callbacks[0]).getName(); char password[] = ((PasswordCallback) callbacks[1]).getPassword(); byte[] credToken = ((WSCredTokenCallbackImpl) callbacks[2]).getCredToken(); javax.servlet.http.HttpServletRequest request = ((WSServletRequestCallback) callbacks[3]).getHttpServletRequest(); javax.servlet.http.HttpServletResponse response = ((WSServletResponseCallback) callbacks[4]).getHttpServletResponse(); java.util.Map appContext = ((WSAppContextCallback) callbacks[5]).getContext(); java.util.List authzTokenList = ((WSTokenHolderCallback) callbacks[6]).getTokenHolderList(); // Gets the SHARED STATE information principal = (WSPrincipal) _sharedState.get(com.ibm.wsspi.security. auth.callback.Constants.WSPRINCIPAL_KEY); credential = (WSCredential) _sharedState.get(com.ibm.wsspi.security. auth.callback.Constants.WSCREDENTIAL_KEY); defaultAuthzToken = (AuthorizationToken) _sharedState.get(com.ibm. wsspi.security.auth.callback.Constants.WSAUTHZTOKEN_KEY); // What you tend to do with this information depends upon the scenario // that you are trying to accomplish. This example demonstrates how to // access various different information: // - Determine if a login is initial versus propagation // - Deserialize a custom authorization token (For more information, see // 보안 속성 전파 // - Add a new custom authorization token (For more information, see // 보안 속성 전파 // - Look for a WSCredential and read attributes, if found. // - Look for a WSPrincipal and read attributes, if found. // - Look for a default AuthorizationToken and add attributes, if found. // - Read the header attributes from the HttpServletRequest, if found. // - Add an attribute to the HttpServletResponse, if found. // - Get the web application name from the appContext, if found. // - Determines if a login is initial versus propagation. This is most // useful when login module is first. boolean requiresLogin = ((WSTokenHolderCallback) callbacks[6]).requiresLogin(); // initial login - asserts privilege attributes based on user identity if (requiresLogin) { // If you are validating a token from another server, there is an // application programming interface (API) to get the uniqueID from it. if (credToken != null && uid == null) { try { String uniqueID = WSSecurityPropagationHelper. validateLTPAToken(credToken); String realm = WSSecurityPropagationHelper.getRealmFromUniqueID (uniqueID); // Now set it to the UID so you can use that to either map or // login with. uid = WSSecurityPropagationHelper.getUserFromUniqueID (uniqueID); } catch (Exception e) { // handle exception } } // Adds a Hashtable to shared state. // Note: You can perform custom mapping on the NameCallback value returned // to change the identity based upon your own mapping rules. uid = mapUser (uid); // Gets the default InitialContext for this server. javax.naming.InitialContext ctx = new javax.naming.InitialContext(); // Gets the local UserRegistry object. com.ibm.websphere.security.UserRegistry reg = (com.ibm.websphere.security. UserRegistry) ctx.lookup("UserRegistry"); // Gets the user registry uniqueID based on the uid specified in the // NameCallback. String uniqueid = reg.getUniqueUserId(uid); uid = WSSecurityPropagationHelper.getUserFromUniqueID (uniqueID); // Gets the display name from the user registry based on the uniqueID. String securityName = reg.getUserSecurityName(uid); // Gets the groups associated with this uniqueID. java.util.List groupList = reg.getUniqueGroupIds(uid); // Creates the java.util.Hashtable with the information you gathered from // the UserRegistry. java.util.Hashtable hashtable = new java.util.Hashtable(); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_UNIQUEID, uniqueid); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_SECURITYNAME, securityName); hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_GROUPS, groupList); // Adds a cache key that is used as part of the lookup mechanism for // the created Subject. The cache key can be an Object, but should // implement the toString() method. Make sure the cacheKey contains // enough information to scope it to the user and any additional // attributes that you use. If you do not specify this property the // Subject is scoped to the WSCREDENTIAL_UNIQUEID returned, by default. hashtable.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_CACHE_KEY, "myCustomAttribute" + uniqueid); // Adds the hashtable to the sharedState of the Subject. _sharedState.put(com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_PROPERTIES_KEY,hashtable); } // propagation login - process propagated tokens else { // - Deserializes a custom authorization token. For more information, see // 보안 속성 전파. // This can be done at any login module plug in point (first, // middle, or last). if (authzTokenList != null) { // Iterates through the list looking for your custom token for (int i=0; i<authzTokenList.size(); i++) { TokenHolder tokenHolder = (TokenHolder)authzTokenList.get(i); // Looks for the name and version of your custom AuthorizationToken // implementation if (tokenHolder.getName().equals("com.ibm.websphere.security.token. CustomAuthorizationTokenImpl") && tokenHolder.getVersion() == 1) { // Passes the bytes into your custom AuthorizationToken constructor // to deserialize customAuthzToken = new com.ibm.websphere.security.token. CustomAuthorizationTokenImpl(tokenHolder.getBytes()); } } } // - Adds a new custom authorization token (For more information, // see 보안 속성 전파) // This can be done at any login module plug in point (first, middle, // or last). else { // Gets the PRINCIPAL from the default AuthenticationToken. This must // match all of the tokens. defaultAuthToken = (com.ibm.wsspi.security.token.AuthenticationToken) sharedState.get(com.ibm.wsspi.security.auth.callback.Constants. WSAUTHTOKEN_KEY); String principal = defaultAuthToken.getPrincipal(); // Adds a new custom authorization token. This is an initial login. // Pass the principal into the constructor customAuthzToken = new com.ibm.websphere.security.token. CustomAuthorizationTokenImpl(principal); // Adds any initial attributes if (customAuthzToken != null) { customAuthzToken.addAttribute("key1", "value1"); customAuthzToken.addAttribute("key1", "value2"); customAuthzToken.addAttribute("key2", "value1"); customAuthzToken.addAttribute("key3", "something different"); } } } // - Looks for a WSCredential and read attributes, if found. // This is most useful when plugged in as the last login module. if (credential != null) { try { // Reads some data from the credential String securityName = credential.getSecurityName(); java.util.ArrayList = credential.getGroupIds(); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Looks for a WSPrincipal and read attributes, if found. // This is most useful when plugged as the last login module. if (principal != null) { try { // Reads some data from the principal String principalName = principal.getName(); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Looks for a default AuthorizationToken and add attributes, if found. // This is most useful when plugged in as the last login module. if (defaultAuthzToken != null) { try { // Reads some data from the defaultAuthzToken String[] myCustomValue = defaultAuthzToken.getAttributes ("myKey"); // Adds some data if not present in the defaultAuthzToken if (myCustomValue == null) defaultAuthzToken.addAttribute ("myKey", "myCustomData"); } catch (Exception e) { // Handles exceptions throw new WSLoginFailedException (e.getMessage(), e); } } // - Reads the header attributes from the HttpServletRequest, if found. // This can be done at any login module plug in point (first, middle, // or last). if (request != null) { java.util.Enumeration headerEnum = request.getHeaders(); while (headerEnum.hasMoreElements()) { System.out.println ("Header element: " + (String)headerEnum.nextElement()); } } // - Adds an attribute to the HttpServletResponse, if found // This can be done at any login module plug in point (first, middle, // or last). if (response != null) { response.addHeader ("myKey", "myValue"); } // - Gets the web application name from the appContext, if found // This can be done at any login module plug in point (first, middle, // or last). if (appContext != null) { String appName = (String) appContext.get(com.ibm.wsspi.security.auth. callback.Constants.WEB_APP_NAME); } return succeeded; } public boolean commit() throws LoginException { boolean succeeded = true; // Add any objects here that you have created and belong in the // Subject. Make sure the objects are not already added. If you added // any sharedState variables, remove them before you exit. If the abort() // method gets called, make sure you cleanup anything added to the // Subject here. if (customAuthzToken != null) { // Sets the customAuthzToken token into the Subject try { // Do this in a doPrivileged code block so that application code // does not need to add additional permissions java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { public Object run() { try { // Adds the custom authorization token if it is not // null and not already in the Subject if ((customAuthzTokenPriv != null) && (!_subject.getPrivateCredentials().contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials().add(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } public boolean abort() throws LoginException { boolean succeeded = true; // Makes sure to remove all objects that have already been added (both into the // Subject and shared state). if (customAuthzToken != null) { // remove the customAuthzToken token from the Subject try { final AuthorizationToken customAuthzTokenPriv = customAuthzToken; // Do this in a doPrivileged block so that application code does not need // to add additional permissions java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() { public Object run() { try { // Removes the custom authorization token if it is not // null and not already in the Subject if ((customAuthzTokenPriv != null) && (_subject.getPrivateCredentials(). contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials(). remove(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } public boolean logout() throws LoginException { boolean succeeded = true; // Makes sure to remove all objects that have already been added // (both into the Subject and shared state). if (customAuthzToken != null) { // Removes the customAuthzToken token from the Subject try { final AuthorizationToken customAuthzTokenPriv = customAuthzToken; // Do this in a doPrivileged code block so that application code does // not need to add additional permissions java.security.AccessController.doPrivileged(new java.security. PrivilegedAction() { public Object run() { try { // Removes the custom authorization token if it is not null and not // already in the Subject if ((customAuthzTokenPriv != null) && (_subject. getPrivateCredentials(). contains(customAuthzTokenPriv))) { _subject.getPrivateCredentials().remove(customAuthzTokenPriv); } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } return null; } }); } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } return succeeded; } }
- 사용자 정의 로그인 모듈을 위해 시스템 로그인을 구성하십시오.
시스템 로그인 구성을 위해 사용자 정의 로그인 모듈을 개발한 후에는 관리 콘솔을 사용하거나 wsadmin 유틸리티를 사용하여 시스템 로그인을 구성할 수 있습니다. 관리 콘솔을 사용하여 시스템 로그인을 구성하려면 보안 > 글로벌 보안을 클릭하십시오. Java Authentication and Authorization Service 아래에서 시스템 로그인을 클릭하십시오. 시스템 로그인 구성을 위해 wsadmin 유틸리티 사용에 대한 자세한 정보는 서버측 Java Authentication and Authorization Service 인증 및 로그인 구성 사용자 정의의 내용을 참조하십시오. 또한 시스템 로그인 모듈에 대한 정보와 추가 로그인 모듈을 추가할지 여부를 판별하려면 해당 기사를 참조하십시오.
하위 주제
Java Authentication and Authorization Service로 애플리케이션 로그인 사용자 정의
JAAS(Java Authentication and Authorization Service)를 사용하면 사용자의 애플리케이션 로그인을 사용자 정의할 수 있습니다.


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tsec_jaascustlogmod
파일 이름:tsec_jaascustlogmod.html