JAAS를 위한 프로그램 로그인

프로그램 로그인은 인증을 위해 애플리케이션 프리젠테이션 사이트에 특정한 로그인 양식을 지원하는 로그인 양식 유형입니다.

엔터프라이즈 Bean 클라이언트 애플리케이션이 사용자에게 식별 정보를 제공하도록 요구할 경우, 애플리케이션의 작성자는 해당 정보를 수집하여 사용자를 인증해야 합니다. 프로그래머의 작업은 실제 사용자 인증이 수행되는 위치에 따라 크게 분류될 수 있습니다.

웹 애플리케이션의 사용자는 인증 데이터에 대한 프롬프트를 여러 가지 방식으로 수신할 수 있습니다. 웹 애플리케이션 배치 디스크립터 파일의 <login-config> 요소는 이 정보를 수집하는 데 사용되는 메커니즘을 정의합니다. 브라우저의 401 대화 창과 같은 일반적인 용도의 디바이스에 의존하지 않고 로그인 절차를 사용자 정의하려는 프로그래머의 경우, 양식 기반 로그인을 사용하여 로그인 정보를 수집하기 위한 애플리케이션 특정 HTML 양식을 제공할 수 있습니다.

관리 보안이(가) 사용 불가능하면 인증이 발생하지 않습니다. 웹 애플리케이션에 대해 양식 기반 로그인을 사용할 경우, 각 웹 애플리케이션의 배치 디스크립터에 있는 <login-config> 요소의 auth-method 태그에서 FORM을 지정해야 합니다.

애플리케이션이 WebSphere® Application Server 양식 로그인 유형을 사용하여 사이트별 로그인 양식을 제공할 수 있습니다. Java™ EE(Java Platform, Enterprise Edition) 스펙에서는 양식 로그인을 웹 애플리케이션의 인증 메소드 중 하나로 정의합니다. WebSphere Application Server는 양식 로그아웃 메커니즘을 제공합니다.

JAAS(Java Authentication and Authorization Service) 프로그램 로그인

JAAS(Java Authentication and Authorization Service)는 WebSphere Application Server에서 새로운 기능입니다. 이 기능은 Java EE 1.4 스펙에서도 요구합니다. JAAS는 CORBA(Common Object Request Broker Architecture) 프로그램 로그인 API를 대체하는 WebSphere Application Server 계획 인증 API(Application Programming Interface) 콜렉션입니다. WebSphere Application Server는 JAAS에 대한 몇 가지 확장을 제공합니다.

프로그램 방식 로그인 API 개발을 시작하기 전에 다음을 고려하십시오.
  • 순수 Java 클라이언트 애플리케이션 또는 클라이언트 컨테이너 애플리케이션의 경우 JAAS 로그인을 수행하기 전에 클라이언트 오브젝트 요청 브로커(ORB) 보안을 초기화하십시오. JAAS 로그인 전에 다음 코드를 실행하여 이를 수행하십시오.
    ...
    import java.util.Hashtable;
    import javax.naming.Context;  
    import javax.naming.InitialContext;
    ...
    // Perform an InitialContext and default lookup prior to logging 
    // in to initialize ORB security and for the bootstrap host/port 
    // to be determined for SecurityServer lookup. If you do not want 
    // to validate the userid/password during the JAAS login, disable 
    // the com.ibm.CORBA.validateBasicAuth property in the 
    // sas.client.props file.
    
       Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
              "com.ibm.websphere.naming.WsnInitialContextFactory");
    env.put(Context.PROVIDER_URL, 
         "corbaloc:iiop:myhost.mycompany.com:2809");
       Context initialContext = new InitialContext(env);
    Object obj = initialContext.lookup("");
    [z/OS]참고: z/OS® 서버에 연결할 때는 항상 com.ibm.CORBA.validateBasicAuth=false로 설정하십시오. SecurityServer는 z/OS 시스템에서 승인되지 않는 "UNAUTHENTICATED" 프린시펄을 사용하여 찾으므로 이 기능은 현재 z/OS 서버로 분배되는 클라이언트에서 작동되지 않습니다.
  • 순수 Java 클라이언트 애플리케이션 또는 클라이언트 컨테이너 애플리케이션의 경우 대상 JNDI(Java Naming and Directory Interface) 부트스트랩 특성의 포트 번호와 호스트 이름이 올바르게 지정되었는지 확인하십시오. 세부사항은 CosNaming(CORBA 네이밍 인터페이스)을 사용하는 애플리케이션 개발 절을 참조하십시오.
  • 애플리케이션이 사용자 정의 JAAS 로그인 구성을 사용할 경우, 사용자 정의 JAAS 로그인 구성이 제대로 정의되었는지 확인하십시오. 세부사항은 Java Authentication and Authorization Service의 프로그램 로그인 구성 절을 참조하십시오.
  • 일부 JAAS API는 Java 2 보안 권한으로 보호됩니다. 애플리케이션 코드에서 이러한 API를 사용할 경우 이러한 권한이 애플리케이션 was.policy 파일에 추가되었는지 확인하십시오. 세부사항은 was.policy 파일을 Java 2 보안을 위한 애플리케이션에 추가, PolicyTool을 사용하여 Java 2 보안을 위해 정책 파일 편집Java 2 보안을 위해 was.policy 파일 구성 절을 참조하십시오. Java 2 보안 권한으로 보호되는 API의 세부사항은 IBM® 개발자 킷, Java Technology Edition을 참조하십시오. 자세한 정보는 JAAS 및 WebSphere Application Server 공용 API 문서를 참조하십시오. 다음 목록에는 이 문서에 제공된 샘플 코드에서 사용되는 API가 포함됩니다.
    • javax.security.auth.login.LoginContext 생성자는 javax.security.auth.AuthPermission "createLoginContext"에 의해 보호됩니다.
    • javax.security.auth.Subject.doAs and com.ibm.websphere.security.auth.WSSubject.doAs는 javax.security.auth.AuthPermission "doAs"에 의해 보호됩니다.
    • javax.security.auth.Subject.doAsPrivileged and com.ibm.websphere.security.auth.WSSubject.doAsPrivileged는 javax.security.auth.AuthPermission "doAsPrivileged"에 의해 보호됩니다.
  • com.ibm.websphere.security.auth.WSSubject: JAAS 버전 1.0의 설계 누락으로 인해 javax.security.auth.Subject.getSubject는 java.security.AccessController.doPrivileged 코드 블록 내의 실행 스레드와 연관된 Subject를 리턴하지 않습니다. 이는 일관성 없는 작동을 나타내어 문제가 될 수 있으며 이로 인해 문제점 해결을 위한 원하지 않는 노력을 기울여야 합니다. com.ibm.websphere.security.auth.WSSubject API는 Subject를 실행 스레드와 연관시키는 방안을 제공합니다. com.ibm.websphere.security.auth.WSSubject API는 권한 검사를 위해 Java EE 자원으로 JAAS 모델을 확장합니다. com.ibm.websphere.security.auth.WSSubject.doAs 또는 com.ibm.websphere.security.auth.WSSubject.doAsPrivileged 코드 블록 내의 실행 스레드와 연관된 Subject는 Java EE 자원 권한 검사에 사용됩니다.
  • 새 JAAS 로그인 구성 정의를 위한 관리 콘솔 지원: 관리 콘솔에서 JAAS 로그인 구성을 구성하여 WebSphere Application Server 구성 API에 저장할 수 있습니다. 애플리케이션은 관리 콘솔에서 새 JAAS 로그인 구성을 정의할 수 있으며 데이터는 WebSphere Application Server 구성 API로 저장되는 구성 저장소에서 지속됩니다. 그러나 WebSphere Application Server는 JAAS 기본 구현에서 제공하는 기본 JAAS 로그인 구성 형식을 계속 지원합니다. 중복 로그인 구성이 WebSphere Application Server 구성 API 및 일반 텍스트 파일 형식 모두에 정의된 경우, WebSphere Application Server 구성 API의 로그인 구성이 우선순위를 갖습니다. WebSphere Application Server 구성 API에서 로그인 구성을 정의하면 다음과 같은 장점이 있습니다.
    • 관리 콘솔을 사용하여 JAAS 로그인 구성 정의
    • JAAS 로그인 구성 중앙 관리
    • WebSphere Application Server, Network Deployment 설치 시 JAAS 로그인 구성 분배
  • WebSphere Application Server에 대한 JAAS 로그인 구성: WebSphere Application Server는 JAAS 로그인 구성을 제공하여 애플리케이션이 WebSphere Application Server 보안 런타임에 대한 프로그램적 인증을 수행하도록 합니다. 이러한 WebSphere Application Server의 JAAS 로그인 구성은 구성된 인증 메커니즘, SWAM(Simple WebSphere Authentication Mechanism) 또는 LTPA(Lightweight Third-Party Authentication) 및 제공된 인증 데이터에 기반한 사용자 레지스트리(로컬 OS, LDAP 또는 사용자 정의)에 대한 인증을 수행합니다. 이러한 JAAS 로그인 구성에서 인증된 주제에는 Java EE 역할 기반 보호 자원에 대한 권한 검사를 수행하기 위해 WebSphere Application Server 보안 런타임에서 사용할 수 있는 필수 프린시펄과 신임이 포함됩니다.
    참고: SWAM은 WebSphere Application Server 버전 9.0에서 더 이상 사용되지 않고 이후 릴리스에서는 제거됩니다.
    다음은 WebSphere Application Server가 제공하는 JAAS 로그인 구성입니다.
    • WSLogin JAAS 로그인 구성: Java 클라이언트, 클라이언트 컨테이너 애플리케이션, 서블릿, JSP 파일, 엔터프라이즈 Bean 등이 사용자 ID와 비밀번호 또는 WebSphere Application Server 보안 런타임에 대한 토큰에 기반하여 인증을 수행하는 데 사용할 수 있는 일반적인 JAAS 로그인 구성입니다. 그러나 이 구성은 클라이언트 컨테이너 배치 디스크립터에서 지정된 CallbackHandler 핸들러를 지원하지 않습니다.
    • 클라이언트 컨테이너 JAAS 로그인 구성: 이 JAAS 로그인 구성은 클라이언트 컨테이너 배치 디스크립터에 지정된 CallbackHandler 핸들러를 인식합니다. 이 로그인 구성의 로그인 모듈은 하나의 CallbackHandler 핸들러가 지정된 경우, 또한 애플리케이션 코드가 로그인 컨텍스트에 하나의 CallbackHandler 핸들러를 지정한 경우에도 클라이언트 컨테이너 배치 디스크립터의 CallbackHandler 핸들러를 사용합니다. 이는 클라이언트 컨테이너 애플리케이션을 위한 것입니다.
    • 이전에 언급한 JAAS 로그인 구성을 사용하여 인증된 Subject는 com.ibm.websphere.security.auth.WSPrincipal 프린시펄과 com.ibm.websphere.security.auth.WSCredential 신임을 포함합니다. 인증된 주제가 com.ibm.websphere.security.auth.WSSubject.doAs 메소드 또는 다른 doAs 메소드로 전달되면 WebSphere Application Server 보안 런타임이 주제 com.ibm.websphere.security.auth.WSCredential 신임에 기반하여 Java EE 자원에 대한 권한 검사를 수행할 수 있습니다.
  • 사용자 정의 JAAS 로그인 구성: 기타 JAAS 로그인 구성을 정의할 수 있습니다. 세부사항은 Java Authentication and Authorization Service의 프로그램 로그인 구성의 내용을 참조하십시오.사용자 정의 인증 메커니즘에 대해 프로그램적 인증을 수행하려면 이러한 로그인 구성을 사용하십시오. 그러나 이러한 고객 정의 JAAS 로그인 구성의 주제에 필수 프린시펄 및 신임이 없는 경우 WebSphere Application Server 보안 런타임에서 권한 검사를 수행하는 데 이 주제를 사용하지 않을 수 있습니다.

JAAS 로그인에서 루트 원인 로그인 예외 찾기:

LoginContext.login API를 발행한 후 LoginException 예외가 발생하는 경우 구성된 사용자 레지스트리에서 근본 원인이 되는 예외를 찾을 수 있습니다. 로그인 모듈에서 레지스트리 예외는 com.ibm.websphere.security.auth.WSLoginFailedException 클래스로 랩핑됩니다. 이 예외에는 위의 명령을 발행한 후 랩핑된 예외를 확인할 수 있는 getCause 메소드가 있습니다.

항상 WSLoginFailedException 예외가 발생하는 것은 아니지만 사용자 레지스트리에서 생성되는 대부분의 예외는 여기에 표시됩니다. 다음 예에서는 연관된 발견 블록이 있는 LoginContext.login API를 보여줍니다. getCause API를 발행하려면 WSLoginFailedException 예외를 com.ibm.websphere.security.auth.WSLoginFailedException 클래스에 캐스트하십시오.

다음 determineCause 예는 CustomUserRegistry 예외 유형을 처리하는 데 사용할 수 있습니다.
try 
    {
                  lc.login(); 
    } 
    catch (LoginException le)
    {
		// drill down through the exceptions as they might cascade through the runtime
		Throwable root_exception = determineCause(le);
	
		// now you can use "root_exception" to compare to a particular exception type
		// for example, if you have implemented a CustomUserRegistry type, you would 
  //  know what to look for here.
    }


/* Method used to drill down into the WSLoginFailedException to find the 
"root cause" exception */

    public Throwable determineCause(Throwable e) 
      {
					Throwable root_exception = e, temp_exception = null;

					// keep looping until there are no more embedded WSLoginFailedException or 
				// WSSecurityException exceptions
         while (true)
				{
								if (e instanceof com.ibm.websphere.security.auth.WSLoginFailedException)
						{
														temp_exception = ((com.ibm.websphere.security.auth.WSLoginFailedException)
														e).getCause();
						}
							else if (e instanceof com.ibm.websphere.security.WSSecurityException)
						{
														temp_exception = ((com.ibm.websphere.security.WSSecurityException)
														e).getCause();
						}
												else if (e instanceof javax.naming.NamingException)
																// check for Ldap embedded exception
								{
													temp_exception = ((javax.naming.NamingException)e).getRootCause();
								}
								else if (e instanceof your_custom_exception_here)
						{
											// your custom processing here, if necessary
						}
						else 
						{
											// this exception is not one of the types we are looking for,
											// lets return now, this is the root from the WebSphere 
								//  Application Server perspective
											return root_exception;
						}
						if (temp_exception != null)
						{
																// we have an exception; go back and see if this has another
								//  one embedded within it.
											root_exception = temp_exception;
											e = temp_exception;
								continue;
						}
						else 
						{
								// we finally have the root exception from this call path, this
											// has to occur at some point
											return root_exception;
						}
				}
		}

서블릿 필터에서 루트 원인 로그인 예외 찾기:

또한 사후 양식 로그인 처리를 다룰 때 서블릿 필터에서 근본 원인 예외를 수신할 수 있습니다. 이 예외는 발생한 사항을 표시하므로 사용자에게 유용합니다. 다음 API를 발행하여 근본 원인 예외를 확인할 수 있습니다.
Throwable t = com.ibm.websphere.security.auth.WSSubject.getRootLoginException();  
if (t != null)  	
         t = determineCause(t);

예외가 생성되면 위의 determineCause 예를 통해 실행하여 기본 레지스트리 근본 원인을 확인할 수 있습니다.

순수 Java 클라이언트에 대한 근본 원인 로그인 예외 전파 허용:

현재는, 보안상의 이유로 루트 원인이 순수한 클라이언트에 전파되지 않습니다. 그러나 신뢰하는 환경에서는 순수 클라이언트에 루트 원인을 전파하기 원할 것입니다. 단일 클라이언트에 대한 근본 원인 로그인 예외 전파를 사용하려는 경우, WebSphere Application Server 관리 콘솔의 보안 > 글로벌 보안 > 사용자 정의 특성을 클릭하고 다음과 같은 특성을 설정하십시오.

com.ibm.websphere.security.registry.propagateExceptionsToClient=true

비프롬프트 프로그램상의 로그인

WebSphere Application Server는 com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl인 javax.security.auth.callback.CallbackHandler 인터페이스의 비프롬프트 구현을 제공합니다. 애플리케이션은 이 인터페이스를 사용하여 인증을 수행할 WebSphere LoginModule 인스턴스에 인증 데이터를 넣을 수 있습니다. 이 기능은 서버측 애플리케이션 코드가 ID를 인증하고 해당 ID를 사용하여 다운스트림 Java EE 자원을 호출할 경우 유용합니다.
javax.security.auth.login.LoginContext lc = null;

try { 
lc = new javax.security.auth.login.LoginContext("WSLogin",
new com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl("user", 
      "securityrealm", "securedpassword"));

// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determine how authentication data is collected
// in this case, the authentication data is "push" to the authentication mechanism
//   implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: " 
+ e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resource using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  // where bankAccount is a protected EJB
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
+ e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}

순수 Java 클라이언트, 클라이언트 애플리케이션 컨테이너, 엔터프라이즈 Bean, JSP(JavaServer Pages) 파일, 서블릿 또는 기타 Java EE(Java 2 Platform, Enterprise Edition) 자원으로 com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl 콜백 핸들러를 사용할 수 있습니다.

참고: WSCallbackHandlerImpl 콜백 핸들러는 WebSphere Application Server 보안 또는 웹 서비스 보안 사용 여부에 따라 다릅니다. 이 핸들러는 sas.jar 파일(보안을 사용하는 경우) 또는 was-wssecurity.jar 파일(웹 서비스 보안을 사용하는 경우)에 있습니다.

사용자 인터페이스 프로그래밍상의 로그인

또한 WebSphere Application Server는 사용자 인터페이스 로그인 프롬프트를 통해 사용자의 인증 데이터를 수집하는 javax.security.auth.callback.CallbackHandler 구현의 사용자 인터페이스 구현을 제공합니다. com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl 콜백 핸들러는 인증 데이터에 사용자를 프롬프트하기 위하여 사용자 인터페이스 로그인 패널을 표시합니다.
[z/OS][AIX HP-UX Solaris]참고: 이 작동을 수행하려면 DISPLAY 환경에서 X11 서버를 호출할 필요가 있습니다.
javax.security.auth.login.LoginContext lc = null;

try { 
lc = new javax.security.auth.login.LoginContext("WSLogin",
new com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl());

// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determine how authentication data is collected
// in this case, the authentication date is collected by GUI login prompt
//   and pass to the authentication mechanism implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: " 
+ e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resources using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  // where bankAccount is a protected 엔터프라이즈 Bean
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
+ e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}
주의: 엔터프라이즈 Bean, 서블릿, JSP 파일 등과 같은 서버측 자원에는 com.ibm.websphere.security.auth.callback.WSGUICallbackHandlerImpl 콜백 핸들러를 사용하지 마십시오. 사용자 인터페이스 로그인 프롬프트는 사용자 입력을 위해 서버를 블로킹합니다. 이 작동은 서버 프로세스에는 적합하지 않습니다.

WebSphere Application Server는 또한 javax.security.auth.callback.CallbackHandler 인터페이스의 Kerberos 신임 캐시 구현을 제공합니다. 콜백 핸들러는 com.ibm.websphere.security.auth.callback.WSCcacheCallBackHandlerImpl입니다. 이 인터페이스를 사용하여 애플리케이션은 인증을 수행할 WebSphere LoginModule 인스턴스에 인증 데이터를 넣을 수 있습니다.

이 기능은 클라이언트측 애플리케이션 코드에서 Kerberos 신임 캐시가 있는 WebSphere Application Server를 인증하는 데에만 사용됩니다.

wsjaas_client.conf 파일에 다음 옵션이 있는 경우 옵션을 false로 설정합니다.

   useDefaultKeytab=false
   useDefaultCcache=false
   tryFirstPass=false
   useFirstPass=false
   forwardable=false
   renewable=false
   renewable=false
   noaddress=false

javax.security.auth.login.LoginContext lc = null;

String krb5Ccache = /etc/krb5/krb5cc_utle;

try { 
lc = new javax.security.auth.login.LoginContext("WSKRB5Login",
new com.ibm.websphere.security.auth.callback.WSCcacheCallBackHandlerImpl(user, krb5Realm, krb5Ccache, false));
// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determines how authentication data is collected
// in this case, the authentication date is collected by stdin prompt
// and passed to the authentication mechanism implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: 
          " + e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resource using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  
// where bankAccount is a protected enterprise bean
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
       + e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}

Application Server with the default Kerberos credential cache.

javax.security.auth.login.LoginContext lc = null;

try { 
lc = new javax.security.auth.login.LoginContext("WSKRB5Login",
new com.ibm.websphere.security.auth.callback.WSCcacheCallBackHandlerImpl(user, krb5Realm, null, true));
// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determines how authentication data is collected
// in this case, the authentication date is collected by stdin prompt
// and passed to the authentication mechanism implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: 
          " + e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resource using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  
// where bankAccount is a protected enterprise bean
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
       + e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}

Application Server with the Microsoft native Kerberos credential cache. The client must
login to the Microsoft Domain Controller.

javax.security.auth.login.LoginContext lc = null;

try { 
lc = new javax.security.auth.login.LoginContext("WSKRB5Login",
new com.ibm.websphere.security.auth.callback.WSCcacheCallBackHandlerImpl(null, null, null, true));
// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determines how authentication data is collected
// in this case, the authentication date is collected by stdin prompt
// and passed to the authentication mechanism implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: 
          " + e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resource using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  
// where bankAccount is a protected enterprise bean
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
       + e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}

WSKRB5Login 모듈

WSKRB5Login JAAS 로그인 구성: 이 구성은 Java 클라이언트, 클라이언트 컨테이너 애플리케이션, 서블릿, JSP 파일 또는 엔터프라이즈 Bean이 WebSphere Application Server 보안 런타임에 대한 Kerberos 신임 캐시 및 Kerberos 프린시펄 이름 비밀번호에 기초하여 인증을 수행하는 데 사용할 수 있는 일반적인 JAAS 로그인 구성입니다. 그러나 이 구성은 클라이언트 컨테이너 배치 디스크립터에서 지정된 CallbackHandler 핸들러를 지원하지 않습니다.

작성한 krb5.ini 또는 krb5.conf 파일을 기본 위치에 지정하십시오. 파일이 기본 위치에 없는 경우 java.security.krb5.conf JVM 시스템 특성을 올바른 경로와 Kerberos 구성 파일 이름으로 설정해야 합니다.

Windows® 플랫폼의 경우 기본 위치는 c:\winnt\krb5.ini입니다.

Linux® 플랫폼의 경우 기본 위치는 /etc/krb5.conf입니다.

기타 Unix 플랫폼의 경우 기본 위치는 /etc/krb5/krb5.conf입니다.

z/OS 플랫폼의 경우 기본 위치는 /etc/krb5/krb5.conf입니다.

Kerberos 구성 설정값, Kerberos KDC(Key Distribution Center) 이름 및 범주 설정은 Kerberos 구성 파일 또는 java.security.krb5.kdc 및 java.security.krb5.realm 시스템 특성 파일을 통해 제공됩니다.

Stdin 프롬프트 프로그래밍상의 로그인

WebSphere Application Server는 또한 javax.security.auth.callback.CallbackHandler 인터페이스의 stdin 구현을 제공합니다. com.ibm.websphere.security.auth.callback.WSStdinCallbackHandlerImpl 콜백 핸들러는 stdin 프롬프트를 통해 사용자에게 인증 정보를 입력하도록 프롬프트하여 수집합니다.
javax.security.auth.login.LoginContext lc = null;

try { 
lc = new javax.security.auth.login.LoginContext("WSLogin",
new com.ibm.websphere.security.auth.callback.WSStdinCallbackHandlerImpl());

// create a LoginContext and specify a CallbackHandler implementation
// CallbackHandler implementation determines how authentication data is collected
// in this case, the authentication date is collected by stdin prompt
// and passed to the authentication mechanism implemented by the LoginModule.
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: failed to instantiate a LoginContext and the exception: 
          " + e.getMessage());
e.printStackTrace();

// maybe javax.security.auth.AuthPermission "createLoginContext" is not granted
//   to the application, or the JAAS login configuration is not defined.
}

if (lc != null)
try { 
lc.login();  // perform login
javax.security.auth.Subject s = lc.getSubject();
// get the authenticated subject

// Invoke a Java EE resource using the authenticated subject
com.ibm.websphere.security.auth.WSSubject.doAs(s,
new java.security.PrivilegedAction() {
public Object run() {
try { 
bankAccount.deposit(100.00);  
// where bankAccount is a protected enterprise bean
} catch (Exception e) {
System.out.println("ERROR: error while accessing EJB resource, exception: " 
       + e.getMessage());
e.printStackTrace();
}
return null;
}
}
);
} catch (javax.security.auth.login.LoginException e) {
System.err.println("ERROR: login failed with exception: " + e.getMessage());
e.printStackTrace();

// login failed, might want to provide relogin logic
}
주의: 엔터프라이즈 Bean, 서블릿, JSP 파일 등과 같은 서버측 자원에는 com.ibm.websphere.security.auth.callback.WSStdinCallbackHandlerImpl 콜백 핸들러를 사용하지 마십시오. STDIN 프롬프트부터 입력은 서버 환경에서 전송되지 않습니다. 대부분의 서버가 백그라운드에서 실행하고 서버에는 콘솔이 없습니다. 그러나 서버에 콘솔이 있는 경우, stdin 프롬프트는 사용자 입력을 위해 서버를 블로킹합니다. 이 작동은 서버 프로세스에는 적합하지 않습니다.

주제 유형을 표시하는 아이콘 개념 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=csec_programlog
파일 이름:csec_programlog.html