spep::SPEP* spep::SPEP::initializeServer( spep::ConfigurationReader &configurationReader, std::vector<saml2::Handler*> handlers ) { spep::SPEP *spep = new spep::SPEP; spep->_mode = SPEP_MODE_SERVER; spep->_isStarted = false; spep->_logger = new saml2::Logger(); for( std::vector<saml2::Handler*>::iterator handlerIterator = handlers.begin(); handlerIterator != handlers.end(); ++handlerIterator ) { spep->_logger->registerHandler( *handlerIterator ); } saml2::LocalLogger localLogger(spep->_logger, "spep::SPEP"); localLogger.debug() << "Beginning to initialize server-side SPEP components."; spep->_configuration = new ConfigurationImpl( configurationReader ); spep->_spepConfigData = new SPEPConfigData( spep->_configuration->getSPEPConfigData() ); int allowedTimeSkew = configurationReader.getIntegerValue( CONFIGURATION_ALLOWEDTIMESKEW ); int metadataInterval = configurationReader.getIntegerValue( CONFIGURATION_METADATAINTERVAL ); int attributeConsumingServiceIndex = configurationReader.getIntegerValue( CONFIGURATION_ATTRIBUTECONSUMINGSERVICEINDEX ); int assertionConsumerServiceIndex = configurationReader.getIntegerValue( CONFIGURATION_ASSERTIONCONSUMERSERVICEINDEX ); int authzCacheIndex = configurationReader.getIntegerValue( CONFIGURATION_AUTHZCACHEINDEX ); int startupRetryInterval = configurationReader.getIntegerValue( CONFIGURATION_STARTUPRETRYINTERVAL ); int sessionCacheInterval = configurationReader.getIntegerValue( CONFIGURATION_SESSIONCACHEINTERVAL ); int sessionCacheTimeout = configurationReader.getIntegerValue( CONFIGURATION_SESSIONCACHETIMEOUT ); std::string nodeID( configurationReader.getStringValue( CONFIGURATION_NODEIDENTIFIER ) ); std::string caBundle( configurationReader.getStringValue( CONFIGURATION_CABUNDLE, std::string() ) ); Decision defaultPolicyDecision( configurationReader.getStringValue( CONFIGURATION_DEFAULTPOLICYDECISION ) ); std::string schemaPath( configurationReader.getStringValue( CONFIGURATION_SCHEMAPATH ) ); std::wstring spepIdentifier( UnicodeStringConversion::toWString( configurationReader.getStringValue( CONFIGURATION_SPEPIDENTIFIER ) ) ); std::wstring esoeIdentifier( UnicodeStringConversion::toWString( configurationReader.getStringValue( CONFIGURATION_ESOEIDENTIFIER ) ) ); std::string metadataURL( configurationReader.getStringValue( CONFIGURATION_METADATAURL ) ); spep->_identifierCache = new saml2::IdentifierCache(); spep->_identifierGenerator = new saml2::IdentifierGenerator( spep->_identifierCache ); spep->_samlValidator = new saml2::SAMLValidator( spep->_identifierCache, allowedTimeSkew ); spep->_metadata = new MetadataImpl( spep->_logger, schemaPath, spepIdentifier, esoeIdentifier, metadataURL, caBundle, spep->_spepConfigData->getKeyResolver(), assertionConsumerServiceIndex, metadataInterval ); spep->_soapUtil = new SOAPUtil( spep->_logger, schemaPath ); spep->_wsClient = new WSClient( spep->_logger, caBundle, spep->_soapUtil ); spep->_attributeProcessor = new AttributeProcessor( spep->_logger, spep->_metadata, spep->_spepConfigData->getKeyResolver(), spep->_identifierGenerator, spep->_wsClient, spep->_samlValidator, schemaPath, spep->_spepConfigData->getAttributeRenameMap() ); spep->_sessionCache = new SessionCacheImpl( spep->_logger ); spep->_sessionCacheThread = new SessionCacheThread( spep->_logger, spep->_sessionCache, sessionCacheTimeout, sessionCacheInterval ); spep->_authnProcessor = new AuthnProcessor( spep->_logger, spep->_attributeProcessor, spep->_metadata, spep->_sessionCache, spep->_samlValidator, spep->_identifierGenerator, spep->_spepConfigData->getKeyResolver(), spepIdentifier, spep->_spepConfigData->getSSORedirect(), spep->_spepConfigData->getServiceHost(), schemaPath, attributeConsumingServiceIndex, assertionConsumerServiceIndex ); spep->_sessionGroupCache = new SessionGroupCacheImpl( spep->_logger, defaultPolicyDecision ); spep->_policyEnforcementProcessor = new PolicyEnforcementProcessor( spep->_logger, spep->_wsClient, spep->_sessionGroupCache, spep->_sessionCache, spep->_metadata, spep->_identifierGenerator, spep->_samlValidator, spep->_spepConfigData->getKeyResolver(), schemaPath ); spep->_startupProcessor = new StartupProcessorImpl( spep->_logger, spep->_wsClient, spep->_metadata, spep->_spepConfigData->getKeyResolver(), spep->_identifierGenerator, spep->_samlValidator, schemaPath, spepIdentifier, spep->_spepConfigData->getIPAddresses(), nodeID, authzCacheIndex, startupRetryInterval ); spep->_wsProcessor = new WSProcessor( spep->_logger, spep->_authnProcessor, spep->_policyEnforcementProcessor, spep->_soapUtil ); return spep; }
static bool SAMLLoadSchema(XercesDOMParser &parser, const SAMLGlibString &schemaDir, const char *filename) { SAMLGlibString schemaPath(g_build_filename(schemaDir.c_str(), filename, NULL)); Grammar *g = parser.loadGrammar(schemaPath.c_str(), Grammar::SchemaGrammarType, true); if (g == NULL) { /* * The parser complains even with official schemas, so we don't * normally set an error handler. However, this should not fail since * we control these files, so try again with logging, so we can see * what went wrong. */ SAMLErrorHandler errorHandler; parser.setErrorHandler(&errorHandler); g = parser.loadGrammar(schemaPath.c_str(), Grammar::SchemaGrammarType, true); Warning("Failed to load XML Schema from %s.\n", schemaPath.c_str()); return false; } return true; }
const QJsonObject LedDeviceWrapper::getLedDeviceSchemas() { // make sure the resources are loaded (they may be left out after static linking) Q_INIT_RESOURCE(LedDeviceSchemas); // read the json schema from the resource QDir d(":/leddevices/"); QStringList l = d.entryList(); QJsonObject result, schemaJson; for(QString &item : l) { QString schemaPath(QString(":/leddevices/")+item); QString devName = item.remove("schema-"); QString data; if(!FileUtils::readFile(schemaPath, data, Logger::getInstance("LedDevice"))) { throw std::runtime_error("ERROR: Schema not found: " + item.toStdString()); } QJsonObject schema; if(!JsonUtils::parse(schemaPath, data, schema, Logger::getInstance("LedDevice"))) { throw std::runtime_error("ERROR: Json schema wrong of file: " + item.toStdString()); } schemaJson = schema; schemaJson["title"] = QString("edt_dev_spec_header_title"); result[devName] = schemaJson; } return result; }
int XmlGspInterface::readFile(const QString &fileName) { QFile* file = new QFile(fileName); QFileInfo fi(fileName); QString path = (fi.path().length() > 3) ? QString(fi.path() + "/") : fi.path(); QFileInfo si(QString::fromStdString(_schemaName)); QString schemaPath(si.absolutePath() + "/"); if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { std::cout << "XmlGspInterface::readFile() - Can't open xml-file " << fileName.toStdString() << "." << std::endl; delete file; return 0; } if (!checkHash(fileName)) { delete file; return 0; } QDomDocument doc("OGS-PROJECT-DOM"); doc.setContent(file); QDomElement docElement = doc.documentElement(); //OpenGeoSysProject if (docElement.nodeName().compare("OpenGeoSysProject")) { std::cout << "XmlGspInterface::readFile() - Unexpected XML root." << std::endl; delete file; return 0; } QDomNodeList fileList = docElement.childNodes(); for(int i = 0; i < fileList.count(); i++) { const QString file_node(fileList.at(i).nodeName()); if (file_node.compare("geo") == 0) { XmlGmlInterface gml(_project, schemaPath.toStdString() + "OpenGeoSysGLI.xsd"); const QDomNodeList childList = fileList.at(i).childNodes(); for(int j = 0; j < childList.count(); j++) { const QDomNode child_node (childList.at(j)); if (child_node.nodeName().compare("file") == 0) { std::cout << "path: " << path.toStdString() << "#" << std::endl; std::cout << "file name: " << (child_node.toElement().text()).toStdString() << "#" << std::endl; gml.readFile(QString(path + child_node.toElement().text())); } } } else if (file_node.compare("stn") == 0) { XmlStnInterface stn(_project, schemaPath.toStdString() + "OpenGeoSysSTN.xsd"); const QDomNodeList childList = fileList.at(i).childNodes(); for(int j = 0; j < childList.count(); j++) if (childList.at(j).nodeName().compare("file") == 0) stn.readFile(QString(path + childList.at(j).toElement().text())); } else if (file_node.compare("msh") == 0) { const std::string msh_name = path.toStdString() + fileList.at(i).toElement().text().toStdString(); FileIO::MeshIO meshIO; MeshLib::Mesh* msh = meshIO.loadMeshFromFile(msh_name); _project->addMesh(msh); } } return 1; }