std::string AuthScope::toString() const { std::stringstream ss; ss << "Scheme: " << (_hasScheme ? getScheme() : "Any"); ss << " Host: " << (_hasHost ? getHost() : "Any"); ss << " Port: "; if (_hasPort) { ss << getPort(); } else { ss << "Any"; } ss << " Realm: " << (_hasRealm ? getRealm() : "Any"); ss << " AuthType: "; if (_hasAuthType) { switch (getAuthType()) { case BASIC: ss << "BASIC"; break; case DIGEST: ss << "DIGEST"; break; case NONE: ss << "NONE"; break; default: ss << "UNKNOWN"; } } else { ss << "Any"; } return ss.str(); }
void CGI::logCGIData(const QString& filename) { // create a QFile object to do the file I/O QFile file(filename); // open the file if (file.open(QIODevice::WriteOnly)) { // create a QTextStream object on the file Q3TextStream textFile(&file); // get the environment textFile << "REQUEST_METHOD=" << getenv("REQUEST_METHOD") << endl; textFile << "CONTENT_LENGTH=" << getenv("CONTENT_LENGTH") << endl; // write the query string to the file textFile << "QUERY_STRING=" << query_string << endl; // write misc. CGI environment pieces textFile << "AUTH_TYPE=" << getAuthType() << endl; textFile << "GATEWAY_INTERFACE=" << getGatewayInterface() << endl; textFile << "HTTP_ACCEPT=" << getHTTPAccept() << endl; textFile << "HTTP_ACCEPT_ENCODING=" << getHTTPAcceptEncoding() << endl; textFile << "HTTP_ACCEPT_LANGUAGE=" << getHTTPAcceptLanguage() << endl; textFile << "HTTP_CONNECTION=" << getHTTPConnection() << endl; textFile << "HTTP_REFERER=" << getHTTPReferer() << endl; textFile << "HTTP_USER_AGENT=" << getHTTPUserAgent() << endl; textFile << "REMOTE_HOST=" << getRemoteHost() << endl; textFile << "REMOTE_ADDRESS=" << getRemoteAddress() << endl; textFile << "REMOTE_PORT=" << getRemotePort() << endl; textFile << "REQUEST_URI=" << getRequestURI() << endl; textFile << "SCRIPT_NAME=" << getScriptName() << endl; textFile << "SERVER_ADMIN=" << getServerAdmin() << endl; textFile << "SERVER_NAME=" << getServerName() << endl; textFile << "SERVER_PORT=" << getServerPort() << endl; textFile << "SERVER_PROTOCOL=" << getServerProtocol() << endl; textFile << "SERVER_SOFTWARE=" << getServerSoftware() << endl; } // close the file file.close(); }
/* Change name from requestSetupDefaultPDP to requestSetupDataCall */ void requestSetupDataCall(void * data, size_t datalen, RIL_Token t) { /* In GSM with CDMA version: DOUNT - data[0] is radioType(GSM/UMTS or CDMA), data[1] is profile, * data[2] is apn, data[3] is username, data[4] is passwd, data[5] is authType (added by Android2.1) * data[6] is cid field added by mtk for Multiple PDP contexts setup support 2010-04 */ const char* profile = ((const char **)data)[1]; const char* apn = ((const char **)data)[2]; const char* username = ((const char **)data)[3]; const char* passwd = ((const char **)data)[4]; const int authType = getAuthType(((const char **)data)[5]); const int protocol = get_protocol_type(((const char **)data)[6]); const int interfaceId = atoi(((const char **)data)[7]) - 1; LOGD("requestSetupData profile=%s, apn=%s, username=%s, password=xxxx, authType=%d, protocol=%d, interfaceId=%d", profile, apn, username, authType, protocol, interfaceId); int requestParamNumber = (datalen/sizeof(char*)); LOGD("requestSetupData with datalen=%d and parameter number=%d", datalen, requestParamNumber); if (requestParamNumber != 8) { /* Last parm is the authType instaed of cid */ LOGD("requestSetupData with incorrect parameters"); goto error; } #if defined(PURE_AP_USE_EXTERNAL_MODEM) && !defined(MT6280_SUPER_DONGLE) if (strcmp(profile, "1002") == 0) { // Always request for CID 1 for default connection requestSetupDataCallOverIPv6(apn, username, passwd, authType, protocol, 0, 1, profile, t); } else { requestSetupDataCallOverIPv6(apn, username, passwd, authType, protocol, 1, 2, profile, t); } #else //genenal project requestSetupDataCallOverIPv6(apn, username, passwd, authType, protocol, interfaceId, profile, t); #endif return; error: RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0); }
// Insert a row into the AUTHS table void CmpSeabaseDDLauth::insertRow() { char buf[1000]; ExeCliInterface cliInterface(STMTHEAP); NAString authType; switch (getAuthType()) { case COM_ROLE_CLASS: authType = COM_ROLE_CLASS_LIT; break; case COM_USER_CLASS: authType = COM_USER_CLASS_LIT; break; default: authType = COM_UNKNOWN_ID_CLASS_LIT; } NAString authValid = isAuthValid() ? "Y" : "N"; NAString immutable = isAuthImmutable() ? "Y" : "N"; NAString sysCat = CmpSeabaseDDL::getSystemCatalogStatic(); str_sprintf(buf, "insert into %s.\"%s\".%s values (%d, '%s', '%s', '%s', %d, '%s', %Ld, %Ld)", sysCat.data(), SEABASE_MD_SCHEMA, SEABASE_AUTHS, getAuthID(), getAuthDbName().data(), getAuthExtName().data(), authType.data(), getAuthCreator(), authValid.data(), getAuthCreateTime(), getAuthRedefTime()); Int32 cliRC = cliInterface.executeImmediate(buf); if (cliRC < 0) { cliInterface.retrieveSQLDiagnostics(CmpCommon::diags()); UserException excp (NULL, 0); excp.throwException(); } }
int initModule(sLogin* psLogin, _MODULE_DATA *_psSessionData) { int hSocket = -1; enum MODULE_STATE nState = MSTATE_NEW; unsigned char bufSend[BUF_SIZE]; unsigned char* bufReceive; int nReceiveBufferSize = 0; sCredentialSet *psCredSet = NULL; sConnectParams params; psCredSet = malloc( sizeof(sCredentialSet) ); memset(psCredSet, 0, sizeof(sCredentialSet)); if (getNextCredSet(psLogin, psCredSet) == FAILURE) { writeError(ERR_ERROR, "[%s] Error retrieving next credential set to test.", MODULE_NAME); nState = MSTATE_COMPLETE; } else if (psCredSet->psUser) { writeError(ERR_DEBUG_MODULE, "[%s] module started for host: %s user: %s", MODULE_NAME, psLogin->psServer->pHostIP, psCredSet->psUser->pUser); } else { writeError(ERR_DEBUG_MODULE, "[%s] module started for host: %s - no more available users to test.", MODULE_NAME); nState = MSTATE_COMPLETE; } memset(¶ms, 0, sizeof(sConnectParams)); if (psLogin->psServer->psAudit->iPortOverride > 0) params.nPort = psLogin->psServer->psAudit->iPortOverride; else if (psLogin->psServer->psHost->iUseSSL > 0) params.nPort = PORT_POP3S; else params.nPort = PORT_POP3; initConnectionParams(psLogin, ¶ms); while (nState != MSTATE_COMPLETE) { switch (nState) { case MSTATE_NEW: // Already have an open socket - close it if (hSocket > 0) medusaDisconnect(hSocket); if (psLogin->psServer->psHost->iUseSSL > 0) hSocket = medusaConnectSSL(¶ms); else hSocket = medusaConnect(¶ms); if (hSocket < 0) { writeError(ERR_NOTICE, "%s: failed to connect, port %d was not open on %s", MODULE_NAME, params.nPort, psLogin->psServer->pHostIP); psLogin->iResult = LOGIN_RESULT_UNKNOWN; return FAILURE; } /* establish initial connection */ nReceiveBufferSize = 0; if ((medusaReceiveRegex(hSocket, &bufReceive, &nReceiveBufferSize, "\\+OK.*\r\n") == FAILURE) || (bufReceive == NULL)) { writeError(ERR_DEBUG_MODULE, "%s failed: Server did not respond with '+OK'. Exiting...", MODULE_NAME); psLogin->iResult = LOGIN_RESULT_UNKNOWN; nState = MSTATE_EXITING; } else { writeError(ERR_DEBUG_MODULE, "Connected"); nState = MSTATE_RUNNING; } /* POP3 STARTTLS Extension http://www.faqs.org/rfcs/rfc2595.html */ /* The capability name "STLS" indicates this command is present and permitted in the current state. "CAPA" can be used to test for its presence. Are there cases where "STLS" may not be implemented? */ /* Initiate STLS only if we don't already have a SSL connection */ if (psLogin->psServer->psHost->iUseSSL == 0) { memset(bufSend, 0, BUF_SIZE); sprintf(bufSend, "STLS\r\n"); if (medusaSend(hSocket, bufSend, strlen(bufSend), 0) < 0) { writeError(ERR_ERROR, "[%s] failed: medusaSend was not successful", MODULE_NAME); return FAILURE; } nReceiveBufferSize = 0; if (medusaReceiveRegex(hSocket, &bufReceive, &nReceiveBufferSize, "\\+OK.*\r\n|-ERR.*\r\n") == FAILURE) { writeError(ERR_ERROR, "[%s] Failed: Unexpected or no data received: %s", MODULE_NAME, bufReceive); return FAILURE; } /* [SUPPORTED] +OK Begin TLS negotiation / +OK Ready to start TLS [NOT SUPPORTED] +OK STLS completed [ERROR] -ERR Command not permitted when TLS active */ else if (strstr(bufReceive, "+OK") != NULL) { FREE(bufReceive); writeError(ERR_DEBUG_MODULE, "[%s] Starting TLS negotiation.", MODULE_NAME); params.nSSLVersion = 3.1; /* Force the use of TLSv1 */ if (medusaConnectSocketSSL(¶ms, hSocket) < 0) { writeError(ERR_ERROR, "[%s] Failed to establish SSLv3 connection.", MODULE_NAME); return FAILURE; } } else { writeError(ERR_DEBUG_MODULE, "[%s] TLS negotiation not available.", MODULE_NAME); FREE(bufReceive); } } /* Query service for accepted authentication methods */ if (_psSessionData->nAuthType == AUTH_UNKNOWN) { getAuthType(hSocket, _psSessionData); if (_psSessionData->nAuthType == AUTH_UNKNOWN) { psLogin->iResult = LOGIN_RESULT_UNKNOWN; return FAILURE; } } break; case MSTATE_RUNNING: /* The POP3 service may be configured to drop connections after an arbitrary number of failed logon attempts. We will reuse the established connection to send authentication attempts until that disconnect happens. At that point the connection should be reestablished. */ if ( medusaCheckSocket(hSocket) ) { nState = tryLogin(hSocket, &psLogin, _psSessionData, psCredSet->psUser->pUser, psCredSet->pPass); if (psLogin->iResult != LOGIN_RESULT_UNKNOWN) { if (getNextCredSet(psLogin, psCredSet) == FAILURE) { writeError(ERR_ERROR, "[%s] Error retrieving next credential set to test.", MODULE_NAME); nState = MSTATE_EXITING; } else { if (psCredSet->iStatus == CREDENTIAL_DONE) { writeError(ERR_DEBUG_MODULE, "[%s] No more available credential sets to test.", MODULE_NAME); nState = MSTATE_EXITING; } else if (psCredSet->iStatus == CREDENTIAL_NEW_USER) { writeError(ERR_DEBUG_MODULE, "[%s] Starting testing for new user: %s.", MODULE_NAME, psCredSet->psUser->pUser); nState = MSTATE_NEW; } else writeError(ERR_DEBUG_MODULE, "[%s] Next credential set - user: %s password: %s", MODULE_NAME, psCredSet->psUser->pUser, psCredSet->pPass); } } } else { writeError(ERR_NOTICE, "[%s] Socket is no longer valid. Server likely dropped connection. Establishing new session.", MODULE_NAME); nState = MSTATE_NEW; if (hSocket > 0) medusaDisconnect(hSocket); hSocket = -1; } break; case MSTATE_EXITING: if (hSocket > 0) medusaDisconnect(hSocket); hSocket = -1; nState = MSTATE_COMPLETE; break; default: writeError(ERR_CRITICAL, "Unknown %s module state %d", MODULE_NAME, nState); if (hSocket > 0) medusaDisconnect(hSocket); hSocket = -1; psLogin->iResult = LOGIN_RESULT_UNKNOWN; return FAILURE; } } FREE(psCredSet); return SUCCESS; }