def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    ip_address = Framework.getTriggerCIDataAsList('ip_address')
    ip_domain = Framework.getTriggerCIDataAsList('ip_domain')
    credentialIds = Framework.getAvailableProtocols(ip_address[0], ProtocolManager.UDDI_REGISTRY)
    logger.debug('Len of credentials: %s' %str(len(credentialIds)))
    logger.debug('Start on Address:', ip_address[0], ',  Domain:', ip_domain[0])

    if credentialIds.__len__() == 0:
        msg = errormessages.makeErrorMessage(ProtocolManager.UDDI_REGISTRY, pattern=errormessages.ERROR_NO_CREDENTIALS)
        errobj = errorobject.createError(errorcodes.NO_CREDENTIALS_FOR_TRIGGERED_IP, [ProtocolManager.UDDI_REGISTRY], msg)
        logger.reportErrorObject(errobj)

    ip_domain = Framework.getDestinationAttribute("ip_domain")
    for credentialId in credentialIds:
        url = Framework.getProtocolProperty(credentialId, CollectorsConstants.UDDI_PROTOCOL_ATTRIBUTE_URL, '')
        if url == '':
            Framework.reportError('URL attribute is not specified in the UDDI protocol')
            continue

        # Check the URL
        try:
            logger.debug("Checking availability of %s" % url)
            netutils.doHttpGet(url, 20000, 'header').strip()
        except:
            Framework.reportWarning('Failed to connect to UDDI Registry using URL: ' + url)
            logger.debugException("Cannot connect to UDDI server")
        else:
            properties = Properties()
            properties.setProperty(CollectorsConstants.UDDI_PROTOCOL_ATTRIBUTE_URL, url)
            properties.setProperty("ip_domain", ip_domain)

            connected = False
            version = 0
            for uddiVersion in (3, 2):
                if connected:
                    break
                try:
                    logger.debug('Using version UDDIv%d' % uddiVersion)
                    properties.setProperty('uddi_version', str(uddiVersion))
                    logger.debug('Try to connect to UDDI Registry using url: ', url)
                    Framework.getAgent(AgentConstants.UDDI_AGENT, '', credentialId, properties)
                    logger.debug('Connected to UDDI Registry  url: ', url)
                    connected = True
                    version = uddiVersion
                except MissingSdkJarException, ex:
                    Framework.reportError('UDDI SDK jars are missed. Refer documentation for details')
                    logger.debugException(ex.getMessage())
                    break
                except JException, java_exc:
                    Framework.reportWarning("Cannot connect to UDDI server")
                    logger.debugException('Failed to connect to UDDI Registry: ' + java_exc.getMessage())
                except:
Example #2
0
def doHttp(ip, port, Framework):
    url = 'http://%s:%s' % (ip, port)
    try:
        logger.debug('Requesting %s' % url)
        return netutils.doHttpGet(url, 20000, 'header', 'Server')
    except:
        logger.debug('Failed to make http connection to %s' % url)
        return None
Example #3
0
 def process(self, context):
     logger.debug('HttpBasedPlugin.process')
     for url, regexp in self.urlAndRegExp:
         content = netutils.doHttpGet(url, 20000, 'header', 'title')
         if self.setVersionDescription:
             context.application.getOsh().setAttribute("application_version", content)
         if content:
             version = re.search(content, regexp, re.I)
             context.application.getOsh().setAttribute("application_version_number", version)
             return
Example #4
0
        msg = removeIp(msg, ' to ')
        errormessages.resolveAndReport(msg, ClientsConsts.HTTP_PROTOCOL_NAME,
                                       Framework)
        return OSHVResult
    except Exception, ex:
        msg = logger.prepareJythonStackTrace('')
        logger.debugException("Failed reading url: '%s'\n" % wsdl_url)
        errormessages.resolveAndReport(msg, ClientsConsts.HTTP_PROTOCOL_NAME,
                                       Framework)
        return OSHVResult

    if importWsdlDocuments == 1:
        getAllImportWsdlsNames(defintion, importWsdldNames)

        for importWsdldName in importWsdldNames:
            importData = netutils.doHttpGet(wsdl_url).strip()
            importWsdldNameToData[importWsdldName] = importData

    services = defintion.getServices().values()

    for service in services:
        serviceName = service.getQName().getLocalPart()
        namespaceURI = service.getQName().getNamespaceURI()
        targetNamespace = defintion.getTargetNamespace()

        if wsdl_url == None and namespaceURI != None:
            wsdl_url = namespaceURI + '?WSDL'

        wsOSH = ObjectStateHolder('webservice')
        wsOSH.setAttribute('data_name', targetNamespace)
        wsOSH.setAttribute('service_name', serviceName)
Example #5
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()
    ip_address = Framework.getTriggerCIDataAsList('ip_address')
    ip_domain = Framework.getTriggerCIDataAsList('ip_domain')
    credentialIds = Framework.getAvailableProtocols(
        ip_address[0], ProtocolManager.UDDI_REGISTRY)
    logger.debug('Len of credentials: %s' % str(len(credentialIds)))
    logger.debug('Start on Address:', ip_address[0], ',  Domain:',
                 ip_domain[0])

    if credentialIds.__len__() == 0:
        msg = errormessages.makeErrorMessage(
            ProtocolManager.UDDI_REGISTRY,
            pattern=errormessages.ERROR_NO_CREDENTIALS)
        errobj = errorobject.createError(
            errorcodes.NO_CREDENTIALS_FOR_TRIGGERED_IP,
            [ProtocolManager.UDDI_REGISTRY], msg)
        logger.reportErrorObject(errobj)

    ip_domain = Framework.getDestinationAttribute("ip_domain")
    for credentialId in credentialIds:
        url = Framework.getProtocolProperty(
            credentialId, CollectorsConstants.UDDI_PROTOCOL_ATTRIBUTE_URL, '')
        if url == '':
            Framework.reportError(
                'URL attribute is not specified in the UDDI protocol')
            continue

        # Check the URL
        try:
            logger.debug("Checking availability of %s" % url)
            netutils.doHttpGet(url, 20000, 'header').strip()
        except:
            Framework.reportWarning(
                'Failed to connect to UDDI Registry using URL: ' + url)
            logger.debugException("Cannot connect to UDDI server")
        else:
            properties = Properties()
            properties.setProperty(
                CollectorsConstants.UDDI_PROTOCOL_ATTRIBUTE_URL, url)
            properties.setProperty("ip_domain", ip_domain)

            connected = False
            version = 0
            for uddiVersion in (3, 2):
                if connected:
                    break
                try:
                    logger.debug('Using version UDDIv%d' % uddiVersion)
                    properties.setProperty('uddi_version', str(uddiVersion))
                    logger.debug('Try to connect to UDDI Registry using url: ',
                                 url)
                    Framework.getAgent(AgentConstants.UDDI_AGENT, '',
                                       credentialId, properties)
                    logger.debug('Connected to UDDI Registry  url: ', url)
                    connected = True
                    version = uddiVersion
                except MissingSdkJarException, ex:
                    Framework.reportError(
                        'UDDI SDK jars are missed. Refer documentation for details'
                    )
                    logger.debugException(ex.getMessage())
                    break
                except JException, java_exc:
                    Framework.reportWarning("Cannot connect to UDDI server")
                    logger.debugException(
                        'Failed to connect to UDDI Registry: ' +
                        java_exc.getMessage())
                except:
Example #6
0
        msg = ex.getMessage()
        logger.debugException("Failed reading url: '%s', reason: '%s'\n" % (wsdl_url, msg))
        msg = removeIp(msg, ' to ')
        errormessages.resolveAndReport(msg, ClientsConsts.HTTP_PROTOCOL_NAME, Framework)
        return OSHVResult
    except Exception, ex:
        msg=logger.prepareJythonStackTrace('')
        logger.debugException("Failed reading url: '%s'\n" % wsdl_url)
        errormessages.resolveAndReport(msg, ClientsConsts.HTTP_PROTOCOL_NAME, Framework)
        return OSHVResult

    if importWsdlDocuments == 1:
        getAllImportWsdlsNames(defintion, importWsdldNames)
        
        for importWsdldName in importWsdldNames:
            importData = netutils.doHttpGet(wsdl_url).strip()
            importWsdldNameToData[importWsdldName] = importData
        
    
    services = defintion.getServices().values()

    for service in services:
        serviceName = service.getQName().getLocalPart()
        namespaceURI = service.getQName().getNamespaceURI()
        targetNamespace = defintion.getTargetNamespace()

        if wsdl_url == None and namespaceURI!=None:
            wsdl_url = namespaceURI+'?WSDL'

        wsOSH = ObjectStateHolder('webservice')
        wsOSH.setAttribute('data_name', targetNamespace)