WSSVerifyPart API를 사용하여 서명 파트 검증

이용자 측에서 SOAP 메시지를 보안 설정하려면 WSS API(Web Services Security API)를 사용하여 응답 이용자(클라이언트 측)에서 이용자 바인딩에 대해 검증 파트 정보를 구성하십시오. 검증할 알고리즘 메소드 및 SOAP 메시지 파트를 지정할 수 있습니다. WSSVerifyPart API를 사용하여 요약 메소드 또는 변환 메소드를 변경하십시오. WSSVerifyPart API는 com.ibm.websphere.wssecurity.wssapi.verification 패키지의 파트입니다.

시작하기 전에

서명 검증 정보를 사용하여 SOAP 메시지를 보안 설정하려면 다음 태스크 중 하나를 완료해야 합니다.

  • WSSVerification API를 사용하여 서명 검증 정보를 구성합니다.
  • 필요에 따라 WSSVerifyPart API를 사용하여 검증 파트를 구성합니다.
WSSVerifyPart는 검증을 위한 변환 또는 요약 메소드를 지정하는 데 사용됩니다. WSSVerifyPart API를 사용하거나 관리 콘솔을 사용하여 정책 세트를 구성하십시오.

이 태스크 정보

WebSphere® Application Server는 기본 이용자의 서명 정보를 사용하여 메시지의 서명 파트를 검증합니다. WSSVerifyPart API는 응답 이용자(요청자)에서만 지원됩니다.

다음 테이블은 디지털 서명 보안 제한조건(무결성)이 정의되는 경우의 필수 검증 파트를 표시합니다.

표 1. 파트 정보 검증. 파트 검증을 사용하여 서명 검증 정보로 메시지를 보안 설정하십시오.
파트 정보 검증 설명
키워드 다음 키워드를 사용하여 검증 파트를 설정합니다.
  • BODY
  • ADDRESSING_HEADERS
  • TIMESTAMP

WS-Addressing 헤더는 복호화되지 않지만 서명 및 검증할 수 있습니다.

xpath XPath 표현식을 사용하여 검증 파트를 설정합니다.
header QName이 지정한 헤더를 필수 검증 파트로 설정합니다.

서명 검증의 경우 특정 기본 동작이 발생합니다. WSSVerification API를 사용하는 가장 단순한 방법은 기본 동작을 사용하는 것입니다(예제 코드 참조). 서명 알고리즘 및 정규화 알고리즘과 검증 파트에 대한 기본값은 WSS API에 의해 정의됩니다.

표 2. 검증 파트 기본 동작 . 기본적으로 검증 파트의 여러 특성이 구성됩니다.
검증 파트 결정 기본 동작
지정할 키워드

메시지 보호를 위해 서명하고 사용할 여러 SOAP 메시지 파트입니다. WebSphere Application Server는 다음 키워드를 지원합니다.

  • WSSVerification.BODY
  • WSSVerification.ADDRESSING_HEADERS
  • WSSVerification.TIMESTAMP
사용할 변환 메소드(알고리즘) 변환 메소드를 추가합니다. 변환 알고리즘은 <Transform> 요소 내에서 지정되고 서명에 대한 변환 알고리즘을 지정합니다. 기본 변환 방법은 TRANSFORM_EXC_C14N입니다.

WebSphere Application Server는 다음 사전 구성된 변환 알고리즘을 지원합니다.

  • WSSVerifyPart.TRANSFORM_EXC_C14N(기본값): http://www.w3.org/2001/10/xml-exc-c14n#
  • WSSVerifyPart.TRANSFORM_XPATH2_FILTER: http://www.w3.org/2002/06/xmldsig-filter2

    BSP(Basic Security Profile)를 준수하도록 하려면 이 변환 메소드를 사용하십시오.

  • WSSVerifyPart.TRANSFORM_STRT10: http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform
  • WSSVerifyPart.TRANSFORM_ENVELOPED_SIGNATURE: http://www.w3.org/2000/09/xmldsig#enveloped-signature
사용할 요약 메소드(알고리즘) 요약 알고리즘 메소드를 설정합니다. <DigestMethod> 요소 내에 지정되는 요약 메소드 알고리즘은 <SigningInfo> 요소에서 사용됩니다. 기본 다이제스트 메소드는 SHA1입니다.
WebSphere Application Server는 다음 요약 메소드 알고리즘을 지원합니다.
  • WSSVerifyPart.SHA1: http://www.w3.org/2000/09/xmldsig#sha1
  • WSSVerifyPart.SHA256: http://www.w3.org/2001/04/xmlenc#sha256
  • WSSVerifyPart.SHA512: http://www.w3.org/2001/04/xmlenc#sha512

프로시저

  1. WSSVerifyPart API를 사용하여 서명 파트를 검증하려면 먼저 애플리케이션 서버가 설치되어 있는지 확인하십시오.
  2. 웹 서비스 보안 API를 사용하여 SOAP 메시지의 검증을 검증하십시오. 서명을 검증하기 위한 WSS API 프로세스는 다음과 같은 프로세스 단계를 따릅니다.
    1. WSSFactory.getInstance()를 사용하여 WSS API 구현 인스턴스를 가져오십시오.
    2. WSSFactory 인스턴스로부터 WSSConsumingContext 인스턴스를 작성하십시오. JAX-WS 제공자 구현 클래스에서 WSSConsumingContext가 호출되는지 확인하십시오. JAX-WS 프로그래밍 모델 특성으로 인해 JAX-WS 제공자를 구현해야 하고 WSSConsumingContext를 호출하여 SOAP 메시지 서명을 검증해야 합니다.
    3. 검증에 사용할 CallbackHandler를 작성하십시오.
    4. WSSFactory 인스턴스에서 WSSVerification 오브젝트를 작성하십시오.
    5. WSSFactory 인스턴스에서 WSSVerifyPart를 작성하십시오.
    6. 기본 파트가 적당하지 않은 경우 검증할 파트를 설정합니다.
    7. 기본값이 적당하지 않은 경우 요약 메소드 후보를 설정합니다.
    8. 기본값이 적당하지 않은 경우 변환 메소드 후보를 설정합니다.
    9. WSSVerifyPart를 WSSVerification에 추가합니다.
    10. WSSVerification을 WSSConsumingContext에 추가합니다.
    11. SOAPMessageContext와 함께 WSSConsumingContext.process()를 호출합니다.

결과

이용자 측의 서명 파트를 검증하기 위한 단계를 완료했습니다. 서명 정보를 검증할 대 오류 조건이 있는 경우 WSSException이 제공됩니다. 성공할 경우 WSSConsumingContext.process()가 호출되고 웹 서비스 보안이 SOAP 메시지에 대해 검증됩니다.

다음 예제는 SOAP 메시지의 서명 정보를 검증하기 위한 WSSVerification API 프로세스의 샘플 코드를 제공합니다.

// Get the message context
   Object msgcontext = getMessageContext();

// Generate the WSSFactory instance (step: a)
   WSSFactory factory = WSSFactory.getInstance();

// Generate the WSSConsumingContext instance (step: b)
   WSSConsumingContext concont = factory.newWSSConsumingContext();

// Generate the certificate list
   String certpath = 
   "c:/WebSphere/AppServer/etc/ws-security/samples/intca2.cer";
// The location of the X509 certificate file
   X509Certificate x509cert = null;
      try {
          InputStream is = new FileInputStream(certpath);
          CertificateFactory cf = CertificateFactory.getInstance("X.509");
          x509cert = (X509Certificate)cf.generateCertificate(is);
      } catch(FileNotFoundException e1){
            throw new WSSException(e1);
      } catch (CertificateException e2) {
            throw new WSSException(e2);
      }

      Set<Object> eeCerts = new HashSet<Object>();
      eeCerts.add(x509cert);  
// create certStore
      java.util.List<CertStore> certList = new 
          java.util.ArrayList<CertStore>();
      CollectionCertStoreParameters certparam = new 
          CollectionCertStoreParameters(eeCerts);
      CertStore cert = null;
      try {
	        cert = CertStore.getInstance("Collection", 
              certparam, "IBMCertPath");
      } catch (NoSuchProviderException e1) {
           throw new WSSException(e1);
      } catch (InvalidAlgorithmParameterException e2) {
           throw new WSSException(e2);
      } catch (NoSuchAlgorithmException e3) {
           throw new WSSException (e3);
      }
      if(certList != null ){
      certList.add(cert);
      }

// generate callback handler (step: c)  
   X509ConsumeCallbackHandler callbackHandler = new 
       X509ConsumeCallbackHandler(
                                  "dsig-receiver.ks", 
                                  "jks",
                                  "server".toCharArray(), 
                                  certList, 
       java.security.Security.getProvider("IBMCertPath")
);

// Generate the WSSVerification instance (step: d)
   WSSVerification ver = factory.newWSSVerification(X509Token.class, 
       callbackHandler);

// Set the part to be specified by WSSVerifyPart (step: e)
   WSSVerifyPart verPart = factory.newWSSVerifyPart();

// Set the part to be specified by the keyword (step: f)
   verPart.setRequiredVerifyPart(WSSVerification.BODY);

// Set the candidates for the digest method for verification (step: g)
// DEFAULT : WSSVerifyPart.SHA1
   verPart.addAllowedDigestMethod(WSSVerifyPart.SHA256);

// Set the candidates for the transform method for verification (step: h)
// DEFAULT : WSSVerifypart.TRANSFORM_EXC_C14N : String
   verPart.addAllowedTransform(WSSVerifyPart.TRANSFORM_STRT10);

// Set WSSVerifyPart to WSSVerification (step: i)
   ver.addRequiredVerifyPart(verPart);

// Add WSSVerification to WSSConsumingContext (step: j)
   concont.add(ver);

//Validate the WS-Security header (step: k)
concont.process(msgcontext);

다음에 수행할 작업

검증할 서명 파트 구성을 완료했습니다.

주제 유형을 표시하는 아이콘 태스크 주제



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