source: TI12-security/trunk/python/ndg.security.common/ndg/security/common/ca/CertificateAuthority_services.py @ 2131

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/ndg.security.common/ndg/security/common/ca/CertificateAuthority_services.py@2131
Revision 2131, 3.4 KB checked in by pjkersha, 12 years ago (diff)

Updates to CA service.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1##################################################
2# simpleCA_services.py
3# generated by ZSI.wsdl2python
4#
5#
6##################################################
7
8
9import urlparse, types
10from ZSI.TCcompound import Struct
11from ZSI import client
12import ZSI
13
14class simpleCAServiceInterface:
15    def getsimpleCA(self, portAddress=None, **kw):
16        raise NonImplementationError, "method not implemented"
17
18
19class simpleCAServiceLocator(simpleCAServiceInterface):
20    simpleCA_address = "http://127.0.0.1:5000/simpleCA.wsdl"
21    def getsimpleCAAddress(self):
22        return simpleCAServiceLocator.simpleCA_address
23
24    def getsimpleCA(self, portAddress=None, **kw):
25        return simpleCABindingSOAP(portAddress or simpleCAServiceLocator.simpleCA_address, **kw)
26
27
28class simpleCABindingSOAP:
29
30    def __init__(self, addr, **kw):
31        netloc = (urlparse.urlparse(addr)[1]).split(":") + [80,]
32        if not kw.has_key("host"):
33            kw["host"] = netloc[0]
34        if not kw.has_key("port"):
35            kw["port"] = int(netloc[1])
36        if not kw.has_key("url"):
37            kw["url"] =  urlparse.urlparse(addr)[2]
38        self.binding = client.Binding(**kw)
39
40
41    def reqCert(self, request):
42        """
43        @param: request to reqCertRequest::
44          _usrCertReq: str
45
46        @return: response from reqCertResponse::
47          _errMsg: str
48          _usrCert: str
49        """
50
51        if not isinstance(request, reqCertRequest) and\
52            not issubclass(reqCertRequest, request.__class__):
53            raise TypeError, "%s incorrect request type" %(request.__class__)
54        kw = {}
55        response = self.binding.Send(None, None, request, soapaction="urn:simpleCA#reqCert", **kw)
56        response = self.binding.Receive(reqCertResponseWrapper())
57        if not isinstance(response, reqCertResponse) and\
58            not issubclass(reqCertResponse, response.__class__):
59            raise TypeError, "%s incorrect response type" %(response.__class__)
60        return response
61
62
63
64class reqCertRequest (ZSI.TCcompound.Struct): 
65    def __init__(self, name=None, ns=None):
66        self._usrCertReq = None
67
68        oname = None
69        if name:
70            oname = name
71            if ns:
72                oname += ' xmlns="%s"' % ns
73            ZSI.TC.Struct.__init__(self, reqCertRequest, [ZSI.TC.String(pname="usrCertReq",aname="_usrCertReq",optional=1),], pname=name, aname="_%s" % name, oname=oname )
74
75class reqCertRequestWrapper(reqCertRequest):
76    """wrapper for rpc:encoded message"""
77
78    typecode = reqCertRequest(name='reqCert', ns='urn:simpleCA')
79    def __init__( self, name=None, ns=None, **kw ):
80        reqCertRequest.__init__( self, name='reqCert', ns='urn:simpleCA' )
81
82class reqCertResponse (ZSI.TCcompound.Struct): 
83    def __init__(self, name=None, ns=None):
84        self._usrCert = None
85        self._errMsg = None
86
87        oname = None
88        if name:
89            oname = name
90            if ns:
91                oname += ' xmlns="%s"' % ns
92            ZSI.TC.Struct.__init__(self, reqCertResponse, [ZSI.TC.String(pname="usrCert",aname="_usrCert",optional=1),ZSI.TC.String(pname="errMsg",aname="_errMsg",optional=1),], pname=name, aname="_%s" % name, oname=oname )
93
94class reqCertResponseWrapper(reqCertResponse):
95    """wrapper for rpc:encoded message"""
96
97    typecode = reqCertResponse(name='reqCertResponse', ns='urn:simpleCA')
98    def __init__( self, name=None, ns=None, **kw ):
99        reqCertResponse.__init__( self, name='reqCertResponse', ns='urn:simpleCA' )
Note: See TracBrowser for help on using the repository browser.