customPasswordEncryption 제공자 개발
Liberty 서버에서 제공되는 com.ibm.wsspi.security.crypto.CustomPasswordEncryption 인터페이스를 구현함으로써 J2EE(Java™ Platform, Enterprise Edition) 애플리케이션에 대한 사용자 정의 권한 부여 의사결정을 수행하는 데 필요한 customPasswordEncryption 제공자를 개발할 수 있습니다.
이 태스크 정보
참고: 다음 선택적 단계는 명령행 유틸리티 지원을 위한 것입니다. 제공자가
서버 런타임 환경만을 지원하려는 경우 이들 단계는 건너뛸 수 있습니다.
customPassworedEncryption 제공자는 다음 세 파일로 구성됩니다.
- 실행 파일을 포함하는 OSGi 번들 파일.
- customPasswordEncryption 제공자의 사용자 기능을 정의하는 기능 Manifest 파일. 이 파일에는 필수 번들의 위치와 기능의 속성 및 패키징되는 경우 확장 Manifest 파일이 들어 있습니다. 이 정보는 서버 런타임이 이용합니다.
- customPasswordEncryption 제공자의 필수 번들 파일 및 구현 클래스 이름을 정의하는 확장 Manifest 파일. 이 파일은 선택사항이며 명령행 유틸리티 지원을 위해 필요합니다.
프로시저
- com.ibm.wsspi.security.crypto.CustomPasswordEncryption 인터페이스를 구현하는
서비스를 제공하는 OSGi 컴포넌트를 작성하십시오.
CustomPasswordEncryption 인터페이스는 decrypt(문자열을 복호화하기 위해 Liberty 서버 런타임에서 호출함), encrypt(문자열을 암호화하기 위해 Liberty 서버 런타임이 호출함) 및 initialize(향후 사용을 위해 예약됨)라는 세 가지 메소드를 정의합니다.
다음 예에서는 OSGi 선언 서비스 어노테이션을 사용합니다.package com.mycompany.custom; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.ConfigurationPolicy; import org.osgi.service.component.annotations.Deactivate; import org.osgi.service.component.annotations.Modified; import com.ibm.wsspi.security.crypto.CustomPasswordEncryption; import com.ibm.wsspi.security.crypto.EncryptedInfo; import com.ibm.wsspi.security.crypto.PasswordDecryptException; import com.ibm.wsspi.security.crypto.PasswordEncryptException; /** */ @Component(service = CustomPasswordEncryption.class, immediate = true, name = "com.mycompany.CustomPasswordEncryptionImpl", configurationPolicy = ConfigurationPolicy.OPTIONAL, property = { "someKey=someValue" }) public class CustomPasswordEncryptionImpl implements CustomPasswordEncryption { @Activate protected synchronized void activate(ComponentContext cc, Map<String, Object> props) { } @Modified protected synchronized void modify(Map<String, Object> props) { } @Deactivate protected void deactivate(ComponentContext cc) {} /** * The encrypt operation takes a UTF-8 encoded String in the form of a byte[]. * The byte[] is generated from String.getBytes("UTF-8"). An encrypted byte[] * is returned from the implementation in the EncryptedInfo object. * Additionally, a logically key alias is returned in EncryptedInfo so which * is passed back into the decrypt method to determine which key was used to * encrypt this password. The WebSphere Application Server runtime has no * knowledge of the algorithm or key used to encrypt the data. * * @param decrypted_bytes * @return com.ibm.wsspi.security.crypto.EncryptedInfo * @throws com.ibm.wsspi.security.crypto.PasswordEncryptException **/ @Override public EncryptedInfo encrypt(byte[] input) throws PasswordEncryptException { byte[] output = null; String key = null; try { : <do some encryption> : return new EncryptedInfo(output, key); } catch (Exception e) { throw new PasswordEncryptException("Exception is caught", e); } } /** * The decrypt operation takes the EncryptedInfo object containing a byte[] * and the logical key alias and converts it to the decrypted byte[]. The * WebSphere Application Server runtime will convert the byte[] to a String * using new String (byte[], "UTF-8"); * * @param info * @return byte[] * @throws PasswordEncryptException * @throws com.ibm.wsspi.security.crypto.PasswordDecryptException **/ @Override public byte[] decrypt(EncryptedInfo info) throws PasswordDecryptException { byte[] input = info.getEncryptedBytes(); String key = info.getKeyAlias(); byte[] output = null; try { : <do some decryption> : return output; } catch (Exception e) { throw new PasswordEncryptException("Exception is caught", e); } } /** * This is reserved for future use and is currently not called by the * WebSphere Application Server runtime. * * @param initialization_data **/ @SuppressWarnings("rawtypes") @Override public void initialize(Map initialization_data) {} }
- 사용자 기능의 일부인 OSGi 번들에 컴포넌트를 패키지하십시오. 번들에 OSGi 서비스 Manifest가 포함되는지 확인하십시오. OSGi 서비스 Manifest의 컨텐츠를 보여주는 예는 다음과 같습니다.
<?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.mycompany.custom.CustomPasswordEncryptionImpl" configuration-policy="optional" immediate="true" activate="activate" deactivate="deactivate" modified="modify"> <implementation class="com.mycompany.custom.CusomPasswordEncryptionImpl"/> <service> <provide interface="com.ibm.wsspi.security.crypto.CustomPasswordEncryption"/> </service> <property name="<someKey>" type="String" value="<someValue>"/> </scr:component>
- 기능 Manifest 파일이 start-phase:="SERVICE_EARLY"를 갖는
OSGi 서브시스템 컨텐츠를 포함하는지 확인하십시오. 선택적 단계가 완료된 경우, 확장 Manifest 파일의
위치는 Subsystem-Content 헤더에 있습니다. 예:
Manifest-Version: 1.0 IBM-Feature-Version: 2 IBM-ShortName: customPasswordEncryption-1.0 Subsystem-Type: osgi.subsystem.feature Subsystem-Version: 1.0.0 Subsystem-ManifestVersion: 1.0 Subsystem-SymbolicName: customPasswordEncryption-1.0;visibility:=public Subsystem-Content: com.mycompany.custom; version="[1,1.0.100)"; start-phase:="SERVICE_EARLY", customEncryption.jar; type=file; \ location:="bin/tools/extensions/ws-customPasswordEncryption/customEncryption.jar” Subsystem-Description: MyCompany custom password encryption
- 기능이 사용자 제품 확장 위치에 설치된 후, 기능 이름으로 server.xml 파일을 구성하십시오.
<featureManager> ... <feature>usr:customPasswordEncryption-1.0</feature> </featureManager>
설치가 서버 런타임 환경에 대해 성공적이었는지 확인하려면 CWWKS1850I 메시지가 message.log 파일에 로깅되는지 확인하십시오.
- 선택사항: customPasswordEncryption 제공자를 SecurityUtility
같은 명령행 유틸리티에 연결하기 위해 필요한 확장 Manifest 파일을
작성하십시오. 확장 Manifest 파일은 JAR 파일이며, MANIFEST.MF
파일을 포함하고 있습니다. 확장 Manifest의 필수 헤더는 다음과 같습니다.
- Require-Bundle: 로드되어야 하는 번들의 목록을 정의합니다. 형식은 OSGi 번들 Manifest 파일과 동일합니다.
- IBM-ImplementationClass: com.ibm.wsspi.security.crypto.CustomPasswordEncryption 인터페이스를 구현하는 구현 클래스를 정의합니다.
다음은 MANIFEST.MF 파일 예입니다.
Require-Bundle: com.mycompany.custom; version="[1,1.0.100)"; location="usr/extension/lib" IBM-ImplementationClass: com.mycompany.custom.CusomPasswordEncryptionImpl
확장 Manifest 파일을 패키징하려면 jar 명령을 사용하십시오. 예:jar cfm customEncryption.jar MANIFEST.MF
JAR 파일을 wlp/bin/tools/extensions/ws-customPasswordEncryption에 배치하십시오. 확장 Manifest 파일의 위치가 기능 Manifest 파일의 Subsystem-Content 헤더 섹션에 있는지 확인하십시오.
이들 파일은 특정 디렉토리에 있어야 합니다. 다음은 파일들의 관계를 묘사합니다.그림 1. customPassworedEncryption 제공자 파일 - 선택사항: 5단계가 완료된 경우, 다음 명령행 유틸리티 명령을 사용하여
설치가 성공했는지 확인할 수 있습니다.
wlp/bin/securityUtility encode --listCustom
예상되는 출력은 customPasswordEncryption의 정보입니다. 예:[{"name":"custom","featurename":"usr:customPasswordEncryption-1.0","description":"MyCompany custom password encryption"}]
모든 필수 파일이 존재하고 파일의 컨텐츠가 정확한지 확인하십시오.
상위 주제: Liberty 보안 인프라에 대한 확장기능 개발


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