示例#1
0
    def request(self, path):
        # A little non-SSL test code commented out, for when you just
        # want to see what the request looks like (for example).
        #from httplib import HTTPConnection
        #conn = HTTPConnection("localhost", 4242)
        conn = HTTPSConnection("www.wesabe.com")

        headers = {'Authorization': "Basic " + self.encoded_credentials,
                   # Wesabe used to let you download OFX[2].  No
                   # longer since their site redesign.  Haven't seen
                   # movement from them on this.  The below fix was
                   # suggested, but had no effect.
                   #"Accept": "*/*; application/x-ofx; application/xml",
                   }
        conn.request("GET", path, headers=headers)
        response = conn.getresponse()
        if response.status != 200:
            print response.getheaders()
            print response.reason
            print response.msg
            raise Exception("request for %r returned status %r"
                            % (path, response.status))
        return response.read()
示例#2
0
        <samlp:AttributeQuery xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" Version="2.0" IssueInstant="2010-10-22T10:32:07.585451Z" ID="bf152f2e-d00f-44a3-93ea-968445bbeb4a">
            <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName">/O=STFC/OU=BADC/CN=Test</saml:Issuer>
            <saml:Subject xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
                <saml:NameID Format="urn:esg:openid">https://ceda.ac.uk/openid/Philip.Kershaw</saml:NameID>
            </saml:Subject>
            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="GroupRole" Name="urn:esg:group:role" NameFormat="groupRole"></saml:Attribute>
            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="LastName" Name="urn:esg:last:name" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="EmailAddress" Name="urn:esg:email:address" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
            <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" FriendlyName="FirstName" Name="urn:esg:first:name" NameFormat="http://www.w3.org/2001/XMLSchema#string"></saml:Attribute>
        </samlp:AttributeQuery>
    </soap11:Body>
</soap11:Envelope>
'''
ctx = SSL.Context()
ctx.load_verify_locations(capath=caDir)
ctx.set_verify(SSL.verify_peer, 9)
con = HTTPSConnection(hostname, ssl_context=ctx)
con.putrequest('POST', path)
con.putheader('Content-Type', 'text/xml')
con.putheader('Content-Length', str(len(body)))
con.endheaders()
con.send(body)
resp = con.getresponse()
print resp.read()

#con = HTTPSConnection(hostname)
#con.putrequest('GET', path)
#con.endheaders()
#resp = con.getresponse()
#print resp.read()