보안 속성을 전파하기 위해 기본 권한 부여 토큰 사용
이 주제는 WebSphere® Application Server가 기본 권한 부여 토큰을 사용하는 방법을 설명합니다. 다운스트림으로 전파된 문자열 속성을 추가할 장소를 찾고 있다면 기본 권한 부여 토큰을 사용할 것을 고려하십시오.
이 태스크 정보
그러나 권한 부여 토큰에 추가한 속성이 인증된 제목과 연관된 사용자에 고유한지 확인하십시오. 사용자에 고유하지 않으면 속성은 아마도 요청과 함께 전파되는 전파 토큰에 속합니다. 전파 토큰에 대한 자세한 정보는 보안 속성을 전파하기 위해 기본 전파 토큰 사용의 내용을 참조하십시오. 권한 부여 토큰에 속성을 추가하려면 사용자 정의 로그인 모듈을 구성된 다양한 시스템 로그인 모듈에 플러그인해야 합니다. 구성된 com.ibm.ws.security.server.lm.wsMapDefaultInboundLoginModule 구현이 있는 모든 로그인 모듈 구성은 전파된 정보를 받을 수 있고 다른 서버로 아웃바운드 전송될 수 있는 전파 정보를 생성할 수 있습니다.
전파된 속성이 초기 로그인 중에 로그인 구성에 제공되지 않으면 ltpaLoginModule 로그인 모듈에서 로그인이 발생한 후에 wsMapDefaultInboundLoginModule 로그인 모듈에서 기본 권한 부여 토큰이 작성됩니다. sharedState hashmap을 사용하여 로그인 메소드로부터 기본 권한 부여 토큰에 대한 참조를 구할 수 있습니다. 기본 권한 부여 토큰을 보려면 WebSphere Application Server의 wsMapDefaultInboundLoginModule 구현 후에 사용자 정의 로그인 모듈을 플러그인해야 합니다.
JAAS(Java™ Authentication and Authorization Service) 프로그래밍 모델에 대한 자세한 정보는 보안: 학습 자원 기사를 참조하십시오.
프로시저
예
public customLoginModule() { public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { // (For more information on initialization, see // JAAS를 위한 시스템 로그인 구성을 위한 사용자 정의 로그인 모듈 개발.) // Get a reference to the sharedState map that is passed in during initialization. _sharedState = sharedState; } public boolean login() throws LoginException { // (For more information on what to do during login, see // JAAS를 위한 시스템 로그인 구성을 위한 사용자 정의 로그인 모듈 개발.) // Look for the default AuthorizationToken in the shared state defaultAuthzToken = (com.ibm.wsspi.security.token.AuthorizationToken) sharedState.get (com.ibm.wsspi.security.auth.callback.Constants.WSAUTHZTOKEN_KEY); // Might not always have one of these generated. It depends on the login // configuration setup. if (defaultAuthzToken != null) { try { // Add a custom attribute defaultAuthzToken.addAttribute("key1", "value1"); // Determine all of the attributes and values that exist in the token. java.util.Enumeration listOfAttributes = defaultAuthorizationToken. getAttributeNames(); while (listOfAttributes.hasMoreElements()) { String key = (String) listOfAttributes.nextElement(); String[] values = (String[]) defaultAuthorizationToken.getAttributes (key); for (int i=0; i<values.length; i++) { System.out.println ("Key: " + key + ", Value[" + i + "]: " + values[i]); } } // Read the existing uniqueID attribute. String[] uniqueID = defaultAuthzToken.getAttributes (com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_UNIQUEID); // Getthe uniqueID from the String[] String unique_id = (uniqueID != null && uniqueID[0] != null) ? uniqueID[0] : ""; // Read the existing expiration attribute. String[] expiration = defaultAuthzToken.getAttributes (com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_EXPIRATION); // An example of getting a long expiration value from the string array. long expire_time = 0; if (expiration != null && expiration[0] != null) expire_time = Long.parseLong(expiration[0]); // Read the existing display name attribute. String[] securityName = defaultAuthzToken.getAttributes (com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_SECURITYNAME); // Get the display name from the String[] String display_name = (securityName != null && securityName[0] != null) ? securityName[0] : ""; // Read the existing long securityName attribute. String[] longSecurityName = defaultAuthzToken.getAttributes (com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_LONGSECURITYNAME); // Get the long security name from the String[] String long_security_name = (longSecurityName != null && longSecurityName[0] != null) ? longSecurityName[0] : ""; // Read the existing group attribute. String[] groupList = defaultAuthzToken.getAttributes (com.ibm.wsspi.security.token.AttributeNameConstants. WSCREDENTIAL_GROUPS); // Get the groups from the String[] ArrayList groups = new ArrayList(); if (groupList != null) { for (int i=0; i<groupList.length; i++) { System.out.println ("group[" + i + "] = " + groupList[i]); groups.add(groupList[i]); } } } catch (Exception e) { throw new WSLoginFailedException (e.getMessage(), e); } } } public boolean commit() throws LoginException { // (For more information on what to do during commit, see // JAAS를 위한 시스템 로그인 구성을 위한 사용자 정의 로그인 모듈 개발.) } private java.util.Map _sharedState = null; private com.ibm.wsspi.security.token.AuthorizationToken defaultAuthzToken = null; }.