Programming Web Services with SOAPn phần 7

Cuối cùng, chúng ta có thể sử dụng phím chuẩn bị để ký khẳng định. Các hoạt động ký vào các đối tượng SignatureContext xử lý các quá trình mã hóa phức tạp để tạo ra chữ ký (xem ví dụ 7-26). Sau khi khẳng định đã được ký kết, chúng tôi trở lại các phần tử DOM có chứa các chữ ký vừa tạo ra | Programming Web Services with SOAP KeyStore keystore JKS new FileInputStream keystorepath X509Certificate cert X509Certificate alias Key key alias if key null throw new IllegalArgumentException Invalid Key Info KeyInfo keyInfo new KeyInfo x5data new cert cert true true true new x5data keyInfo Finally we can use the prepared key to sign the assertion. The sign operation on the SignatureContext object handles the complex cryptographic processes to create the signature see Example 7-26 . Once the assertion has been signed we return the DOM element that contains the signature just created. Example 7-26. Signing the assertion Element sig SignatureContext context new SignatureContext sig key return sig The login operation The encryption code is used in the login operation shown in Example 7-27. It verifies the user s password generates the SAML assertion and signs it. Example 7-27. The login operation public static Element login String userid String password throws Exception Element el NodeList nl user for int n 0 n n Element e Element n if id .equals userid password .equals password AuthenticationAssertion aa new String new Long .toString new userid http new . getHostAddress page 135 Programming Web Services with SOAP .getHostName Element sa aa CodeShare CodeShareKeyPass CodeShareStorePass return sa return null .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.