Пример #1
0
 public override KeySelectorResult select(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo,
                                          Purpose purpose,
                                          AlgorithmMethod method,
                                          XMLCryptoContext context)
 {//throws KeySelectorException {
     return(new IAC_KeySelectorResult(this));
 }
Пример #2
0
        public void marshalParams(XMLStructure parent, XMLCryptoContext context)
        {
            //LOG.Log(POILogger.DEBUG, "marshallParams(parent,context)");
            DOMStructure domParent  = (DOMStructure)parent;
            Element      parentNode = (Element)domParent.Node;
            // parentNode.AttributeNS=(/*setter*/XML_NS, "xmlns:mdssi", XML_DIGSIG_NS);
            Document doc = parentNode.OwnerDocument;

            foreach (String sourceId in sourceIds)
            {
                RelationshipReferenceDocument relRef          = RelationshipReferenceDocument.Factory.NewInstance();
                relRef.AddNewRelationshipReference().SourceId = (/*setter*/ sourceId);
                Node n = relRef.RelationshipReference.DomNode;
                n = doc.ImportNode(n, true);
                parentNode.AppendChild(n);
            }
        }
Пример #3
0
        public void Init(XMLStructure parent, XMLCryptoContext context)
        {
            LOG.Log(POILogger.DEBUG, "Init(parent,context)");
            LOG.Log(POILogger.DEBUG, "parent java type: " + parent.Class.Name);
            DOMStructure domParent  = (DOMStructure)parent;
            Node         parentNode = domParent.Node;

            try {
                TransformDocument transDoc = TransformDocument.Factory.Parse(parentNode);
                XmlObject[]       xoList   = transDoc.Transform.SelectChildren(RelationshipReferenceDocument.type.DocumentElementName);
                if (xoList.Length == 0)
                {
                    //LOG.Log(POILogger.WARN, "no RelationshipReference/@SourceId parameters present");
                }
                foreach (XmlObject xo in xoList)
                {
                    String sourceId = ((CTRelationshipReference)xo).SourceId;
                    LOG.Log(POILogger.DEBUG, "sourceId: ", sourceId);
                    this.sourceIds.Add(sourceId);
                }
            } catch (XmlException e) {
                throw new InvalidAlgorithmParameterException(e);
            }
        }
Пример #4
0
 /**
  * Attempts to find a key that satisfies the specified constraints.
  *
  * @param keyInfo a <code>KeyInfo</code> (may be <code>null</code>)
  * @param purpose the key's purpose ({@link Purpose#SIGN},
  *    {@link Purpose#VERIFY}, {@link Purpose#ENCRYPT}, or
  *    {@link Purpose#DECRYPT})
  * @param method the algorithm method that this key is to be used for.
  *    Only keys that are compatible with the algorithm and meet the
  *    constraints of the specified algorithm should be returned.
  * @param context an <code>XMLCryptoContext</code> that may contain
  *    useful information for finding an appropriate key. If this key
  *    selector supports resolving {@link RetrievalMethod} types, the
  *    context's <code>baseURI</code> and <code>dereferencer</code>
  *    parameters (if specified) should be used by the selector to
  *    resolve and dereference the URI.
  * @return the result of the key selector
  * @throws KeySelectorException if an exceptional condition occurs while
  *    attempting to find a key. Note that an inability to find a key is not
  *    considered an exception (<code>null</code> should be
  *    returned in that case). However, an error condition (ex: network
  *    communications failure) that prevented the <code>KeySelector</code>
  *    from finding a potential key should be considered an exception.
  * @throws ClassCastException if the data type of <code>method</code>
  *    is not supported by this key selector
  */
 public abstract KeySelectorResult select(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo, Purpose purpose, 
 AlgorithmMethod method, XMLCryptoContext context);
Пример #5
0
     public override KeySelectorResult select(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo, 
 	Purpose purpose,
     AlgorithmMethod method, 
     XMLCryptoContext context)
     {
         //throws KeySelectorException {
          	return new IAC_KeySelectorResult(this);
     }
Пример #6
0
 public abstract Data transform(Data data, XMLCryptoContext context, java.io.OutputStream os);
Пример #7
0
 // Interface javax.xml.crypto.Transform
 public abstract Data transform(Data data, XMLCryptoContext context);
Пример #8
0
 /**
  * Marshals the algorithm-specific parameters. If there are no parameters
  * to be marshalled, this method returns without throwing an exception.
  *
  * @param parent a mechanism-specific structure containing the parent
  *    node that the marshalled parameters should be appended to
  * @param context the <code>XMLCryptoContext</code> containing
  *    additional context (may be <code>null</code> if not applicable)
  * @throws ClassCastException if the type of <code>parent</code> or
  *    <code>context</code> is not compatible with this
  *    <code>TransformService</code>
  * @throws NullPointerException if <code>parent</code> is <code>null</code>
  * @throws MarshalException if the parameters cannot be marshalled
  */
 public abstract void marshalParams(XMLStructure parent, XMLCryptoContext context);
Пример #9
0
 /**
  * Initializes this <code>TransformService</code> with the specified
  * parameters and document context.
  *
  * @param parent a mechanism-specific structure containing the parent
  *    structure
  * @param context the <code>XMLCryptoContext</code> containing
  *    additional context (may be <code>null</code> if not applicable)
  * @throws ClassCastException if the type of <code>parent</code> or
  *    <code>context</code> is not compatible with this
  *    <code>TransformService</code>
  * @throws NullPointerException if <code>parent</code> is <code>null</code>
  * @throws InvalidAlgorithmParameterException if the specified parameters
  *   are invalid for this algorithm
  */
 public abstract void init(XMLStructure parent, XMLCryptoContext context);
Пример #10
0
        ;//throws MarshalException;

        /**
         * Initializes this <code>TransformService</code> with the specified
         * parameters and document context.
         *
         * @param parent a mechanism-specific structure containing the parent
         *    structure
         * @param context the <code>XMLCryptoContext</code> containing
         *    additional context (may be <code>null</code> if not applicable)
         * @throws ClassCastException if the type of <code>parent</code> or
         *    <code>context</code> is not compatible with this
         *    <code>TransformService</code>
         * @throws NullPointerException if <code>parent</code> is <code>null</code>
         * @throws InvalidAlgorithmParameterException if the specified parameters
         *   are invalid for this algorithm
         */
        public abstract void init(XMLStructure parent, XMLCryptoContext context)
        ;//throws InvalidAlgorithmParameterException;
Пример #11
0
        public Data transform(Data data, XMLCryptoContext context)
        {
            LOG.Log(POILogger.DEBUG, "transform(data,context)");
            LOG.Log(POILogger.DEBUG, "data java type: " + data.Class.Name);
            OctetStreamData octetStreamData = (OctetStreamData)data;

            LOG.Log(POILogger.DEBUG, "URI: " + octetStreamData.URI);
            InputStream octetStream = octetStreamData.OctetStream;

            RelationshipsDocument relDoc;

            try {
                relDoc = RelationshipsDocument.Factory.Parse(octetStream);
            } catch (Exception e) {
                throw new TransformException(e.Message, e);
            }
            LOG.Log(POILogger.DEBUG, "relationships document", relDoc);

            CTRelationships           rels    = relDoc.Relationships;
            List <CTRelationship>     relList = rels.RelationshipList;
            Iterator <CTRelationship> relIter = rels.RelationshipList.Iterator();

            while (relIter.HasNext())
            {
                CTRelationship rel = relIter.Next();

                /*
                 * See: ISO/IEC 29500-2:2008(E) - 13.2.4.24 Relationships Transform
                 * Algorithm.
                 */
                if (!this.sourceIds.Contains(rel.Id))
                {
                    LOG.Log(POILogger.DEBUG, "removing element: " + rel.Id);
                    relIter.Remove();
                }
                else
                {
                    if (!rel.IsSetTargetMode())
                    {
                        rel.TargetMode = (/*setter*/ STTargetMode.INTERNAL);
                    }
                }
            }

            // TODO: remove non element nodes ???
            LOG.Log(POILogger.DEBUG, "# Relationship elements", relList.Size());

            //XmlSort.Sort(rels, new Comparator<XmlCursor>(){
            //    public int Compare(XmlCursor c1, XmlCursor c2) {
            //        String id1 = ((CTRelationship)c1.Object).Id;
            //        String id2 = ((CTRelationship)c2.Object).Id;
            //        return id1.CompareTo(id2);
            //    }
            //});

            try {
                MemoryStream bos = new MemoryStream();
                XmlOptions   xo  = new XmlOptions();
                xo.SaveNoXmlDecl;
                relDoc.Save(bos, xo);
                return(new OctetStreamData(new MemoryStream(bos.ToByteArray())));
            } catch (IOException e) {
                throw new TransformException(e.Message, e);
            }
        }
Пример #12
0
        public IKeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context)
        {
            if (null == keyInfo)
            {
                throw new Exception("no ds:KeyInfo present");
            }
            List <XMLStructure> keyInfoContent = keyInfo.Content;

            certChain.Clear();
            foreach (XMLStructure keyInfoStructure in keyInfoContent)
            {
                if (!(keyInfoStructure is X509Data))
                {
                    continue;
                }
                X509Data      x509Data     = (X509Data)keyInfoStructure;
                List <Object> x509DataList = x509Data.Content;
                foreach (Object x509DataObject in x509DataList)
                {
                    if (!(x509DataObject is X509Certificate))
                    {
                        continue;
                    }
                    X509Certificate certificate = (X509Certificate)x509DataObject;
                    certChain.Add(certificate);
                }
            }
            if (certChain.Count == 0)
            {
                throw new Exception("No key found!");
            }
            return(this);
        }
Пример #13
0
 ; //throws TransformException;
 public abstract Data transform(Data data, XMLCryptoContext context, java.io.OutputStream os)
 ; //throws TransformException;
Пример #14
0
        ;//throws InvalidAlgorithmParameterException;

        // Interface javax.xml.crypto.Transform
        public abstract Data transform(Data data, XMLCryptoContext context)
        ; //throws TransformException;
Пример #15
0
 /**
  * Attempts to find a key that satisfies the specified constraints.
  *
  * @param keyInfo a <code>KeyInfo</code> (may be <code>null</code>)
  * @param purpose the key's purpose ({@link Purpose#SIGN},
  *    {@link Purpose#VERIFY}, {@link Purpose#ENCRYPT}, or
  *    {@link Purpose#DECRYPT})
  * @param method the algorithm method that this key is to be used for.
  *    Only keys that are compatible with the algorithm and meet the
  *    constraints of the specified algorithm should be returned.
  * @param context an <code>XMLCryptoContext</code> that may contain
  *    useful information for finding an appropriate key. If this key
  *    selector supports resolving {@link RetrievalMethod} types, the
  *    context's <code>baseURI</code> and <code>dereferencer</code>
  *    parameters (if specified) should be used by the selector to
  *    resolve and dereference the URI.
  * @return the result of the key selector
  * @throws KeySelectorException if an exceptional condition occurs while
  *    attempting to find a key. Note that an inability to find a key is not
  *    considered an exception (<code>null</code> should be
  *    returned in that case). However, an error condition (ex: network
  *    communications failure) that prevented the <code>KeySelector</code>
  *    from finding a potential key should be considered an exception.
  * @throws ClassCastException if the data type of <code>method</code>
  *    is not supported by this key selector
  */
 public abstract KeySelectorResult select(javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo, Purpose purpose,
                                          AlgorithmMethod method, XMLCryptoContext context)
 ;// throws KeySelectorException;
Пример #16
0
 public Data transform(Data data, XMLCryptoContext context, OutputStream os)
 {
     //LOG.Log(POILogger.DEBUG, "transform(data,context,os)");
     return(null);
 }
Пример #17
0
        ;//throws InvalidAlgorithmParameterException;

        /**
         * Marshals the algorithm-specific parameters. If there are no parameters
         * to be marshalled, this method returns without throwing an exception.
         *
         * @param parent a mechanism-specific structure containing the parent
         *    node that the marshalled parameters should be appended to
         * @param context the <code>XMLCryptoContext</code> containing
         *    additional context (may be <code>null</code> if not applicable)
         * @throws ClassCastException if the type of <code>parent</code> or
         *    <code>context</code> is not compatible with this
         *    <code>TransformService</code>
         * @throws NullPointerException if <code>parent</code> is <code>null</code>
         * @throws MarshalException if the parameters cannot be marshalled
         */
        public abstract void marshalParams
            (XMLStructure parent, XMLCryptoContext context)
        ;//throws MarshalException;