View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/security/PayloadResolver.java,v 1.1 2002/11/15 09:02:42 skchonghk Exp $ 3 * 4 */ 5 package com.sun.ebxml.registry.security; 6 7 import java.io.*; 8 9 import javax.xml.soap.SOAPMessage; 10 import javax.xml.soap.MimeHeaders; 11 import javax.mail.internet.MimeMultipart; 12 import javax.mail.BodyPart; 13 import javax.mail.MessagingException; 14 15 import org.w3c.dom.Attr; 16 import org.apache.xml.security.signature.XMLSignatureInput; 17 import org.apache.xml.security.utils.resolver.ResourceResolverException; 18 import org.apache.xml.security.utils.resolver.ResourceResolverSpi; 19 import org.apache.xml.security.signature.XMLSignatureInput; 20 import org.apache.xml.security.utils.resolver.ResourceResolverException; 21 22 /*** 23 It is ResourceResolver for signing payload and verifying payload signature 24 */ 25 26 public class PayloadResolver extends ResourceResolverSpi { 27 28 private MimeMultipart multipart; 29 private String id; 30 31 public PayloadResolver(MimeMultipart multipart, String id) { 32 this.multipart = multipart; 33 this.id = id; 34 } 35 36 public boolean engineCanResolve(Attr uriAttr, String baseURI) { 37 try { 38 String uri = uriAttr.getNodeValue(); 39 BodyPart payloadPart = multipart.getBodyPart("payload2"); 40 if (payloadPart==null) { 41 return false; 42 } 43 return true; 44 } 45 catch(MessagingException e) { 46 e.printStackTrace(); 47 return false; 48 } 49 } 50 51 public XMLSignatureInput engineResolve(Attr uriAttr, String baseURI) throws 52 ResourceResolverException { 53 String uri = uriAttr.getNodeValue(); 54 try { 55 BodyPart payloadPart = multipart.getBodyPart("payload2"); 56 XMLSignatureInput sigInput = new XMLSignatureInput(payloadPart.getInputStream()); 57 sigInput.setSourceURI(uri); 58 sigInput.setMIMEType(payloadPart.getContentType()); 59 return sigInput; 60 } 61 catch(MessagingException e) { 62 e.printStackTrace(); 63 throw new ResourceResolverException(id, e, uriAttr, baseURI); 64 } 65 catch(IOException e) { 66 e.printStackTrace(); 67 throw new ResourceResolverException(id, e, uriAttr, baseURI); 68 } 69 } 70 } 71

This page was automatically generated by Maven