/// <summary> /// For an invalid request, returns a HTML-formatted error page with the details of the request and the error /// </summary> public static string GetInvalidRequestDebugPage(string requestPath, DadConfiguration dadConfig) { StringBuilder page = new StringBuilder(); page.Append("<style> body { font-family: verdana, sans-serif; } p { font-size: 9pt; } div.errormsg { border: 1px double black; background-color: gold; font-family: lucida console, courier; font-size: 14pt; padding: 10px; width: 85%; } div.code { border: 1px dotted black; font-family: lucida console, courier; font-size: 14pt; padding: 10px; } </style>"); page.AppendFormat("<h1>Thoth Gateway Invalid Request</h1>"); page.AppendFormat("<p>The request is invalid. Please check the URL syntax, and examine the inclusion and exclusion lists.</p>"); page.AppendFormat("<h3>Request</h3><div class='code'>{0}</div>", requestPath); page.AppendFormat("<h3>Inclusion List</h3><div class='code'>{0}</div>", dadConfig.InclusionList); page.AppendFormat("<h3>Exclusion List</h3><div class='code'>{0}</div>", DadConfiguration.DEFAULT_EXCLUSION_LIST + " " + dadConfig.ExclusionList); page.Append(GetSignature()); return(page.ToString()); }
private void ParseRequest(string requestMethod, string thePath, string rawUrl, string soapAction) { string requestPath = thePath.Substring(1); DadSpecifiedInRequest = true; IsFlexibleParams = false; IsPathAlias = false; string[] pathElements = requestPath.Split('/'); if (pathElements.Length >= 2) { ModuleName = pathElements[0]; DadName = pathElements[1]; if (DadName.Length == 0 || !DadConfiguration.IsValidDad(DadName)) { DadSpecifiedInRequest = false; DadName = DadConfiguration.DefaultDad; } // get dad-specific configuration settings DadConfig = new DadConfiguration(DadName); if (pathElements.Length >= 3) { ProcName = pathElements[2]; if (ProcName.Length > 0) { if (ProcName.Substring(0, 1) == "!") { IsFlexibleParams = true; } else if (ProcName == DadConfig.PathAlias) { IsPathAlias = true; PathAliasValue = GetAliasValue(ProcName, thePath); } else if (ProcName == DadConfig.XdbAlias) { IsXdbAlias = true; XdbAliasValue = GetAliasValue(ProcName, thePath); } else if (ProcName == DadConfig.DocumentPath) { IsDocumentPath = true; } } } else { // missing trailing slash in request ProcName = ""; } if (ProcName.Length == 0) { ProcName = DadConfig.DefaultPage; } if (DadConfig.InvocationProtocol == DadConfiguration.INVOCATION_PROTOCOL_SOAP) { IsSoapRequest = true; IsWsdlRequest = requestMethod.ToUpper() == "GET" && rawUrl.ToLower().EndsWith("?wsdl"); } if (IsSoapRequest && !IsWsdlRequest) { // get the procedure name from the SOAPAction header string methodName = soapAction.Replace("\"", ""); methodName = methodName.Substring(methodName.LastIndexOf("/") + 1); ProcName = ProcName + "." + StringUtil.ReversePrettyStr(methodName); } ProcName = SanitizeProcName(ProcName, DadConfig.ExclusionList); } else { ModuleName = ""; DadName = ""; ProcName = ""; } if (DadName.Length > 0 && ProcName.Length > 0) { string[] urlProcElements = ProcName.Split('.'); if (urlProcElements.Length == 3) { // schema, package and procedure specified OraSchema = urlProcElements[0]; OraPackage = urlProcElements[1]; OraProc = urlProcElements[2]; } else if (urlProcElements.Length == 2) { // assume package and procedure specified (although it could also be schema and procedure, but there is no way to be certain) OraSchema = ""; OraPackage = urlProcElements[0]; OraProc = urlProcElements[1]; } else { // just the procedure is specified OraSchema = ""; OraPackage = ""; OraProc = ProcName; } logger.Debug("Parsed module = " + ModuleName + ", dad = " + DadName + ", proc = " + ProcName); } }
public OracleInterface(GatewayRequest req, OracleParameterCache opc) { _dadName = req.DadName; _dadConfig = req.DadConfig; _opc = opc; string dbUsername = _dadConfig.DatabaseUserName; string dbPassword = _dadConfig.DatabasePassword; // Integrated Windows Authentication (use in combination with Oracle proxy authentication) if (dbUsername == "LOGON_USER") { dbUsername = req.WindowsUsername; // if username contains backslash (domain\user), add double quotes to username if (dbUsername.IndexOf("\\") > -1) { dbUsername = "******"" + dbUsername + "\""; } } if (dbUsername == "LOGON_USER_NO_DOMAIN") { dbUsername = req.WindowsUsernameNoDomain; } // for connection string attributes, see http://download.oracle.com/docs/html/E15167_01/featConnecting.htm#i1006259 _connStr = "User Id=" + dbUsername + ";Password="******";Data Source=" + _dadConfig.DatabaseConnectString + ";" + _dadConfig.DatabaseConnectStringAttributes; // careful with this one, it will expose the passwords in the log // use it just for additional debugging during development // logger.Debug("Connection string: " + _connStr); // Connect to Oracle if (logger.IsDebugEnabled) { logger.Debug("Connecting with user " + dbUsername + " to " + _dadConfig.DatabaseConnectString + "..."); } _conn = new OracleConnection(_connStr); try { _conn.Open(); _connected = true; if (logger.IsDebugEnabled) { logger.Debug("Connected to Oracle " + _conn.ServerVersion); } } catch (OracleException e) { _lastError = e.Message; logger.Error("Failed to connect to database: " + e.Message); } if (_connected) { _txn = _conn.BeginTransaction(); // setup National Language Support (NLS) string sql = "alter session set nls_language='" + _dadConfig.NLSLanguage + "' nls_territory='" + _dadConfig.NLSTerritory + "'"; ExecuteSQL(sql, new ArrayList()); //OracleGlobalization glb = OracleGlobalization.GetThreadInfo(); //logger.Debug ("ODP.NET Client Character Set: " + glb.ClientCharacterSet); // ensure a stateless environment by resetting package state sql = "begin dbms_session.modify_package_state(dbms_session.reinitialize); end;"; ExecuteSQL(sql, new ArrayList()); if (_dadConfig.InvocationProtocol == DadConfiguration.INVOCATION_PROTOCOL_SOAP) { // use SOAP date encoding sql = "alter session set nls_date_format = '" + _dadConfig.SoapDateFormat + "'"; ExecuteSQL(sql, new ArrayList()); } } }