示例#1
0
    def attribute_query(self,
                        subject_id,
                        destination,
                        issuer_id=None,
                        attribute=None,
                        sp_name_qualifier=None,
                        name_qualifier=None,
                        nameid_format=None,
                        real_id=None):
        """ Does a attribute request to an attribute authority, this is
        by default done over SOAP. Other bindings could be used but not
        supported right now.
        
        :param subject_id: The identifier of the subject
        :param destination: To whom the query should be sent
        :param issuer_id: Who is sending this query
        :param attribute: A dictionary of attributes and values that is asked for
        :param sp_name_qualifier: The unique identifier of the
            service provider or affiliation of providers for whom the
            identifier was generated.
        :param name_qualifier: The unique identifier of the identity
            provider that generated the identifier.
        :param nameid_format: The format of the name ID
        :param real_id: The identifier which is the key to this entity in the
            identity database
        :return: The attributes returned
        """

        session_id = sid()
        issuer = self._issuer(issuer_id)

        request = self.create_attribute_query(session_id,
                                              subject_id,
                                              destination,
                                              issuer,
                                              attribute,
                                              sp_name_qualifier,
                                              name_qualifier,
                                              nameid_format=nameid_format)

        logger.info("Request, created: %s" % request)

        soapclient = SOAPClient(destination,
                                self.config.key_file,
                                self.config.cert_file,
                                ca_certs=self.config.ca_certs)
        logger.info("SOAP client initiated")

        try:
            response = soapclient.send(request)
        except Exception, exc:
            logger.info("SoapClient exception: %s" % (exc, ))
            return None
示例#2
0
文件: client.py 项目: Wazoku/pysaml2
    def attribute_query(self, subject_id, destination, issuer_id=None,
                attribute=None, sp_name_qualifier=None, name_qualifier=None,
                nameid_format=None, log=None, real_id=None):
        """ Does a attribute request to an attribute authority, this is
        by default done over SOAP. Other bindings could be used but not
        supported right now.
        
        :param subject_id: The identifier of the subject
        :param destination: To whom the query should be sent
        :param issuer_id: Who is sending this query
        :param attribute: A dictionary of attributes and values that is asked for
        :param sp_name_qualifier: The unique identifier of the
            service provider or affiliation of providers for whom the
            identifier was generated.
        :param name_qualifier: The unique identifier of the identity
            provider that generated the identifier.
        :param nameid_format: The format of the name ID
        :param log: Function to use for logging
        :param real_id: The identifier which is the key to this entity in the
            identity database
        :return: The attributes returned
        """

        if log is None:
            log = self.logger

        session_id = sid()
        issuer = self._issuer(issuer_id)
        
        request = self.create_attribute_query(session_id, subject_id,
                    destination, issuer, attribute, sp_name_qualifier,
                    name_qualifier, nameid_format=nameid_format)
        
        if log:
            log.info("Request, created: %s" % request)
        
        soapclient = SOAPClient(destination, self.config.key_file,
                                self.config.cert_file,
                                ca_certs=self.config.ca_certs)
        if log:
            log.info("SOAP client initiated")

        try:
            response = soapclient.send(request)
        except Exception, exc:
            if log:
                log.info("SoapClient exception: %s" % (exc,))
            return None
示例#3
0
def send_using_soap(message, destination, key_file=None, cert_file=None, ca_certs=""):
    """ 
    Actual construction of the SOAP message is done by the SOAPClient
    
    :param message: The SAML message to send
    :param destination: Where to send the message
    :param key_file: If HTTPS this is the client certificate
    :param cert_file: If HTTPS this a certificates file 
    :param ca_certs: CA certificates to use when verifying server certificates
    :return: The response gotten from the other side interpreted by the 
        SOAPClient
    """
    soapclient = SOAPClient(destination, key_file, cert_file, ca_certs)
    logger.info("SOAP client initiated")
    try:
        response = soapclient.send(message)
    except Exception, exc:
        logger.info("SoapClient exception: %s" % (exc,))
        return None
示例#4
0
文件: binding.py 项目: evansd/pysaml2
def send_using_soap(message,
                    destination,
                    key_file=None,
                    cert_file=None,
                    ca_certs=""):
    """ 
    Actual construction of the SOAP message is done by the SOAPClient
    
    :param message: The SAML message to send
    :param destination: Where to send the message
    :param key_file: If HTTPS this is the client certificate
    :param cert_file: If HTTPS this a certificates file 
    :param ca_certs: CA certificates to use when verifying server certificates
    :return: The response gotten from the other side interpreted by the 
        SOAPClient
    """
    soapclient = SOAPClient(destination, key_file, cert_file, ca_certs)
    logger.info("SOAP client initiated")
    try:
        response = soapclient.send(message)
    except Exception, exc:
        logger.info("SoapClient exception: %s" % (exc, ))
        return None