コード例 #1
0
ファイル: tmpl.py プロジェクト: delfick/sshephalopod
 def ensureEncProperties(self, id=None):
   ep = self.find(enc("EncryptionProperties"))
   if ep is None:
     ep = mkse(self, enc("EncryptionProperties"),
                     attrib=id and dict(Id=id) or None,
                     )
   return ep
コード例 #2
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def addKeyReference(self, uri=None):
     rl = self.find(enc("ReferenceList"))
     if rl is None:
         rl = mke(enc("ReferenceList"))
         self.insert(0, rl)
     return mkse(rl,
                 enc("KeyReference"),
                 attrib=uri and dict(URI=uri) or None)
コード例 #3
0
ファイル: tmpl.py プロジェクト: delfick/sshephalopod
 def addKeyReference(self, uri=None):
   rl = self.find(enc("ReferenceList"))
   if rl is None:
     rl = mke(self, enc("ReferenceList"))
     self.insert(0, rl)
   return mkse(rl, enc("KeyReference"),
                     attrib=uri and dict(URI=uri) or None
                     )
コード例 #4
0
 def ensureCipherReference(self, uri=None):
     cd = self.find(enc("CipherData"))
     cr = cd.find(enc("CipherReference"))
     if cr is None:
         if len(cd):
             raise ValueError("`CipherData` can only contain a single element")
         cr = mkse(cd, enc("CipherReference"), attrib=uri and dict(URI=uri) or None)
     return cr
コード例 #5
0
 def ensureCipherValue(self):
     cd = self.find(enc("CipherData"))
     cv = cd.find(enc("CipherValue"))
     if cv is None:
         if len(cd):
             raise ValueError("`CipherData` can only contain a single element")
         cv = mkse(cd, enc("CipherValue"))
     return cv
コード例 #6
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def ensureCipherValue(self):
     cd = self.find(enc("CipherData"))
     cv = cd.find(enc("CipherValue"))
     if cv is None:
         if len(cd):
             raise ValueError(
                 "`CipherData` can only contain a single element")
         cv = mkse(cd, enc("CipherValue"))
     return cv
コード例 #7
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def ensureEncProperties(self, id=None):
     ep = self.find(enc("EncryptionProperties"))
     if ep is None:
         ep = mkse(
             self,
             enc("EncryptionProperties"),
             attrib=id and dict(Id=id) or None,
         )
     return ep
コード例 #8
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def ensureCipherReference(self, uri=None):
     cd = self.find(enc("CipherData"))
     cr = cd.find(enc("CipherReference"))
     if cr is None:
         if len(cd):
             raise ValueError(
                 "`CipherData` can only contain a single element")
         cr = mkse(cd,
                   enc("CipherReference"),
                   attrib=uri and dict(URI=uri) or None)
     return cr
コード例 #9
0
ファイル: tmpl.py プロジェクト: delfick/sshephalopod
def _EncType_(tag, encMethod=None, id=None, type=None, mimeType=None, encoding=None, recipient=None, nsPrefix=None):
  attrib = {}
  if id: attrib["Id"] = id
  if type: attrib["Type"] = type
  if mimeType: attrib["MimeType"] = mimeTpye
  if encoding: attrib["Encoding"] = encoding
  if recipient: attrib["Recipient"] = recipient
  nsmap = nsPrefix and dict(nsPrefix=EncNs) or EncNsMap
  et = mke(enc(tag), attrib=attrib, nsmap=nsmap)
  if encMethod:
    mkse(et, enc("EncryptionMethod"), Algorithm=encMethod.href)
  mkse(et, enc("CipherData"))
  return et
コード例 #10
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def addEncProperty(self, id=None, target=None):
     attrib = {}
     if id: attrib["Id"] = id
     if target: attrib["Target"] = target
     return mkse(self.ensureEncProperties(),
                 enc("EncryptionProperty"),
                 attrib=attrib)
コード例 #11
0
 def addEncProperty(self, id=None, target=None):
     attrib = {}
     if id:
         attrib["Id"] = id
     if target:
         attrib["Target"] = target
     return mkse(self.ensureEncProperties(), enc("EncryptionProperty"), attrib=attrib)
コード例 #12
0
 def ensureKeyInfo(self, id=None):
     ki = self.find(dsig("KeyInfo"))
     if ki is None:
         ki = mke(dsig("KeyInfo"), attrib=id and dict(Id=id) or None)
         kii = self.find(enc("EncryptionMethod")) is not None and 1 or 0
         self.insert(kii, ki)
     return ki
コード例 #13
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def ensureKeyInfo(self, id=None):
     ki = self.find(dsig("KeyInfo"))
     if ki is None:
         ki = mke(
             dsig("KeyInfo"),
             attrib=id and dict(Id=id) or None,
         )
         kii = self.find(enc("EncryptionMethod")) is not None and 1 or 0
         self.insert(kii, ki)
     return ki
コード例 #14
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
def _EncType_(tag,
              encMethod=None,
              id=None,
              type=None,
              mimeType=None,
              encoding=None,
              recipient=None,
              nsPrefix=None):
    attrib = {}
    if id: attrib["Id"] = id
    if type: attrib["Type"] = type
    if mimeType: attrib["MimeType"] = mimeTpye
    if encoding: attrib["Encoding"] = encoding
    if recipient: attrib["Recipient"] = recipient
    nsmap = nsPrefix and {nsPrefix: EncNs} or EncNsMap
    et = mke(enc(tag), attrib=attrib, nsmap=nsmap)
    if encMethod:
        mkse(et, enc("EncryptionMethod"), Algorithm=encMethod.href)
    mkse(et, enc("CipherData"))
    return et
コード例 #15
0
 def addTransform(self, transform):
     ts = self.find(enc("Transforms"))
     if ts is None:
         ts = mkse(self, enc("Transforms"))
     t = mkse(ts, dsig("Transform"), Algorithm=transform.href)
     return t
コード例 #16
0
 def addOAEPparams(self, params):
     # may need to control position
     return mkse(self, enc("OAEPParams"), params.encode("base64"))
コード例 #17
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def addTransform(self, transform):
     ts = self.find(enc("Transforms"))
     if ts is None: ts = mkse(self, enc("Transforms"))
     t = mkse(ts, dsig("Transform"), Algorithm=transform.href)
     return t
コード例 #18
0
ファイル: tmpl.py プロジェクト: cybniv/dm.xmlsec.binding
 def addOAEPparams(self, params):
     # may need to control position
     return mkse(self, enc("OAEPParams"), params.encode("base64"))