void Identity::copy(const Identity& original)
{
    setName(original.getName());
    setRealName(original.getRealName());
    setIdent(original.getIdent());
    setNicknameList(original.getNicknameList());
    setAuthType(original.getAuthType());
    setAuthPassword(original.getAuthPassword());
    setNickservNickname(original.getNickservNickname());
    setNickservCommand(original.getNickservCommand());
    setSaslAccount(original.getSaslAccount());
    setPemClientCertFile(original.getPemClientCertFile());
    setQuitReason(original.getQuitReason());
    setPartReason(original.getPartReason());
    setKickReason(original.getKickReason());
    setInsertRememberLineOnAway(original.getInsertRememberLineOnAway());
    setRunAwayCommands(original.getRunAwayCommands());
    setAwayCommand(original.getAwayCommand());
    setAwayMessage(original.getAwayMessage());
    setAwayNickname(original.getAwayNickname());
    setReturnCommand(original.getReturnCommand());
    setAutomaticAway(original.getAutomaticAway());
    setAwayInactivity(original.getAwayInactivity());
    setAutomaticUnaway(original.getAutomaticUnaway());
    setShellCommand(original.getShellCommand());
    setCodecName(original.getCodecName());
}
Example #2
0
/*function : send a request pkg to AC auth and wish to get response from that --tangsiqi 2010-1-18*/
int CgiInformAc(char * clientIp, char * serverIp, PKG_TYPE Type, STAuthProcess * pAuthProc,UINT32 pro)
{
	int retErr=0;
	struct in_addr user_ip;
	struct in6_addr user_ipv6;
	pAuthProc->pSendPkg= createPortalPkg(Type);
	/*malloc STPortalPkg ready to rev data*/
	fprintf(stderr,"CgiInformAc createPortalPkg suc Type is %d\n",Type );
	pAuthProc->pRevPkg = (STPortalPkg * )malloc(sizeof(STPortalPkg));
	memset(pAuthProc->pRevPkg, 0, sizeof(STPortalPkg));
    fprintf(stderr,"CgiInformAc serverIp=%s\n",serverIp );

	setAuthType(pAuthProc->pSendPkg, pro);

	memset(&user_ip, 0, sizeof(user_ip));
	memset(&user_ipv6, 0, sizeof(user_ipv6));
	if (1 == inet_pton(AF_INET, clientIp, &user_ip)) {
		fprintf(stderr,"CgiInformAc clientIp4=%s\n",clientIp );
		setPkgUserIP( pAuthProc->pSendPkg, user_ip.s_addr );
	} else if (1 == inet_pton(AF_INET6, clientIp, &user_ipv6)){
		fprintf(stderr,"CgiInformAc clientIp6=%s\n",clientIp );
		pAuthProc->pSendPkg->version = 0x02;
		setPkgUserIP( pAuthProc->pSendPkg, 0 );
		addAttr( &(pAuthProc->pSendPkg), ATTR_USER_IPV6, &user_ipv6, sizeof(user_ipv6) );
	}
	fprintf(stderr,"CgiInformAc version=%u\n",pAuthProc->pSendPkg->version );

	if(sendPortalPkg(pAuthProc->fd, 3, 2000, serverIp, pAuthProc->pSendPkg) < 0 )
	{
		fprintf(stderr,"CgiInformAc sendPortalPkg failed\n" );
		retErr = -1;
	}
	else
	{
		fprintf(stderr,"CgiInformAc sendPortalPkg suc\n" );
	}

	if(getPortalPkg(pAuthProc->fd, 3, &(pAuthProc->pRevPkg))<0)
	{
		fprintf(stderr,"CgiInformAc getPortalPkg failed\n" );
		retErr = -1;
	}
	else
	{
		fprintf(stderr,"CgiInformAc getPortalPkg suc\n" );
		retErr = getErrCode(pAuthProc->pRevPkg);
	}

	fprintf(stderr,"CgiInformAc getErrCode(stAuth.pRevPkg)=%d\n", retErr );

	return retErr;
}
Example #3
0
PEPRequestImpl::PEPRequestImpl(const t_authz_request* req) :
		AbstractPEPRequest("PEPRequestImpl"), m_AuthzRequest(req) {

	DOMPropertySet * propSet = new DOMPropertySet();

	propSet->setProperty("applicationId", m_AuthzRequest->app_id);
	//propSet->setProperty("REMOTE_ADDR", req->http_req.remote_addr);
	//propSet->setProperty("REMOTE_USER", req->http_req.remote_user);

	m_RequestSettings.first = propSet;
	m_RequestSettings.second = nullptr;
	setRequestURI(m_AuthzRequest->http_req.uri);
	setAuthType(m_AuthzRequest->http_auth_info.auth_type);
}
Example #4
0
/*function : send a request pkg to AC auth and wish to get response from that --tangsiqi 2010-1-18*/
int CgiInformAc(char * clientIp, char * serverIp, PKG_TYPE Type, STAuthProcess * pAuthProc,UINT32 pro)
{
		int retErr=0;
		pAuthProc->pSendPkg= createPortalPkg(Type);
		/*malloc STPortalPkg ready to rev data*/
		fprintf(stderr,"CgiInformAc createPortalPkg suc Type is %d\n",Type );
		pAuthProc->pRevPkg = (STPortalPkg * )malloc(sizeof(STPortalPkg));
		memset(pAuthProc->pRevPkg, 0, sizeof(STPortalPkg));
		

		setAuthType(pAuthProc->pSendPkg, pro);
		
		setPkgUserIP( pAuthProc->pSendPkg, htonl(inet_addr(clientIp)) );

		
		if(sendPortalPkg(pAuthProc->fd, 3, 2000, serverIp, pAuthProc->pSendPkg) < 0 )
		{
			fprintf(stderr,"CgiInformAc sendPortalPkg failed\n" );
			retErr = -1;
		}
		else
		{
			fprintf(stderr,"CgiInformAc sendPortalPkg suc\n" );
		}
		
		if(getPortalPkg(pAuthProc->fd, 3, &(pAuthProc->pRevPkg))<0)
		{
			fprintf(stderr,"CgiInformAc getPortalPkg failed\n" );
			retErr = -1;
		}
		else
		{
			fprintf(stderr,"CgiInformAc getPortalPkg suc\n" );
			retErr = getErrCode(pAuthProc->pRevPkg);
		}
		
		
		fprintf(stderr,"CgiInformAc getErrCode(stAuth.pRevPkg)=%d\n", retErr );
		
		
		
	return retErr;
}
void Identity::init()
{
    setAuthType(QStringLiteral("nickserv"));
    setNickservNickname(QStringLiteral("nickserv"));
    setNickservCommand(QStringLiteral("identify"));

    setCodecName(Konversation::IRCCharsets::self()->encodingForLocale());

    setInsertRememberLineOnAway(false);

    setQuitReason(QStringLiteral("Konversation terminated!"));
    setPartReason(QStringLiteral("Konversation terminated!"));
    setKickReason(QStringLiteral("User terminated!"));

    setAwayMessage(QStringLiteral("Gone away for now"));

    setRunAwayCommands(false);

    setAutomaticAway(false);
    setAwayInactivity(10);
    setAutomaticUnaway(false);
}
Example #6
0
void OwncloudSetupWizard::slotOwnCloudFoundAuth(const QUrl& url, const QVariantMap &info)
{
    _ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully connected to %1: %2 version %3 (%4)</font><br/><br/>")
                                        .arg(url.toString())
                                        .arg(Theme::instance()->appNameGUI())
                                        .arg(CheckServerJob::versionString(info))
                                        .arg(CheckServerJob::version(info)));

    if (url.path().endsWith("/status.php")) {
        // We might be redirected, update the account
        QUrl redirectedUrl = url;
        redirectedUrl.setPath(url.path().left(url.path().length() - 11));
        _ocWizard->account()->setUrl(redirectedUrl);
        qDebug() << Q_FUNC_INFO << " was redirected to" << redirectedUrl.toString();
    }

    DetermineAuthTypeJob *job = new DetermineAuthTypeJob(_ocWizard->account(), this);
    job->setIgnoreCredentialFailure(true);
    connect(job, SIGNAL(authType(WizardCommon::AuthType)),
            _ocWizard, SLOT(setAuthType(WizardCommon::AuthType)));
    job->start();
}
Example #7
0
/***********************************************************************************************
                        MAIN MENU FOR RETAIL

***********************************************************************************************/
int
main (void)
{
    struct tm intim;
    int Ret_val;
    double amount;
    unsigned char str[100] = "";
    pthread_t syncT;
    pthread_attr_t attr;
    int newprio;
    struct sched_param param;
    int ret;


//fp = fopen (logFile, "w+");
    fp = stdout;

    fprintf(fp,"Begun main()");
    fflush(fp);

    lk_open ();
    prn_open ();
    mscr_open ();
    lk_dispinit ();

    lk_dispclr();

    strcpy(DATABASE,"/mnt/jffs2/fps.sqlite");

    initialize_db ();

    open_sqlite (DATABASE);

    strcpy(CONFIG_FILE, get_config("CONFIG_FILE",tmpbuf,"0"));	//Need OFFICE ID From config file before init_globals
    read_config (CONFIG_FILE);
    strcpy(OFFICE_ID,getVal("office_id")); // Get from config file
    strcpy(SESSION_ID,"");

    fprintf(fp,"office_id:",OFFICE_ID);
    fflush(fp);

    init_globals();

    strcpy(IP,getVal("remote_url"));
    strcpy(shop_id,getVal("shop"));
    strcpy(terminal,getVal("terminal"));
    strcpy(tempFile,"/mnt/jffs2/dat");
    strcpy(svr_username,getVal("server_user"));
    strcpy(svr_password,getVal("server_pwd"));

    setAuthType();

    if(strcmp(toUpper(getVal("show_splash")),"TRUE")==0)
    {
        lk_disptext (1, 0, "        PDS ", 1);
        lk_disptext (3, 0, "     Govt of AP", 0);
        lk_disptext (4, 0, "    Version:0.9", 0);
        lk_disptext (5, 0, "  Enter to continue", 0);
        lk_getkey ();
        lk_dispclr ();
    }

    if(strcmp(toUpper(getVal("commMode")),"ETHERNET") == 0)
        ip_setup ();

    strcpy(background,getVal("background"));

    pthread_attr_init(&attr);
    pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
    newprio = 1;
    param.sched_priority = newprio;
    pthread_attr_setschedparam(&attr,&param);

    if(strcmp(background,"true")==0) {
        fprintf(fp,"Starting a background thread");
        fflush(fp);

        if (pthread_create (&syncT, &attr, syncThread, NULL) != 0)
            fprintf (stderr, "Error creating the thread");
    }

    while(1) {
        ret = login();

        printFlag = FALSE;

        if(ret==USER)
            main_menu();
        else if(ret == ADMIN)
            admin_menu();
        else {
            lk_dispclr();
            lk_disptext (2, 0, "Invalid credentials", 0);
            lk_getkey ();
            lk_dispclr ();
        }
    }

    prn_close ();			// closing printer
    lk_close ();			// closing pinpad
    mscr_close ();		// closing magnetic swipe
    close_sqlite ();

    fprintf(fp,"Ended main()");
    fflush(fp);

    return SUCCESS;
}
Example #8
0
/*main--tangsiqi 2010-1-18*/
int cgiMain()
{

	int retLogin=-1,retLogout=-1,ret_challege=0,fd=0;/*0--suc,100--timeout, 減方---fail*/
	unsigned short reqID = 0;
	char opt[10]="";
	FILE * fpOut = cgiOut;
	unsigned char chap_password[MD5LEN + 2] = {0};
	unsigned char chap_challenge[MD5LEN] = {0};
	MD5_CTX context;
	unsigned char chap_ident=0;
	STPkgAttr *tlvPkgAttr;
	UINT8  tmp[MD5LEN+1];
	char acIp[32] = "";
	char userIp[32] = "";
	char ssid[64] = "";
	
	STUserInfo userInfo;
	memset(&userInfo, 0 ,sizeof(STUserInfo));

	cgiHeaderContentType("text/html");

	/*rev user info from login.html*/
	cgiFormStringNoNewlines("op_auth", opt, 10);
	fprintf(stderr,"opt=%s",opt);
	if( strlen(opt)>0 && (!strcmp(opt,"login")) )
	{
		cgiFormStringNoNewlines("a_name", userInfo.usrName, MAX_EAG_LOGIN_NAME_LEN);
		cgiFormStringNoNewlines("a_pass", userInfo.usrPass, MAX_EAG_LOGIN_PASS_LEN);

		userInfo.usrOperation = 1;
	}
	else
	{
		userInfo.usrOperation = 2;/*logout*/
	}
		
	
	//fprintf(stderr,"cgiQueryString=%s",cgiQueryString);
	//fprintf(stderr,"cgiReferrer=%s",cgiReferrer);
	//fprintf(stderr,"cgiServerName=%s",cgiServerName);
	memset(acIp, 0, sizeof(acIp));
	if( cgiFormNotFound == cgiFormStringNoNewlines("wlanacip", acIp, sizeof(acIp)) ) {
		strncpy(acIp, cgiServerName, sizeof(acIp)-1);
	}
	if( cgiFormNotFound == cgiFormStringNoNewlines("wlanuserip", userIp, sizeof(userIp)) ) {
		strncpy(userIp, cgiRemoteAddr, sizeof(userIp)-1);
	}
	cgiFormStringNoNewlines("ssid", ssid, sizeof(ssid));

	fprintf( fpOut, "<html xmlns=\"http://www.w3.org/1999/xhtml\"> \n" );
	fprintf( fpOut, "<head> \n" );
	fprintf( fpOut, "<meta http-equiv=Content-Type content=text/html; charset=gb2312> \n" );


  	fprintf( fpOut, "<META   HTTP-EQUIV=\"pragma\"   CONTENT=\"no-cache\"> \n");
  	fprintf( fpOut, "<META   HTTP-EQUIV=\"Cache-Control\"   CONTENT=\"no-cache,   must-revalidate\"> \n" );
  	fprintf( fpOut, "<META   HTTP-EQUIV=\"expires\"   CONTENT=\"Wed,   26   Feb   1997   08:21:57   GMT\">	\n");


	fprintf( fpOut, "<title>login_proc</title>\n");
	fprintf( fpOut, "</head> \n" );
	fprintf( fpOut, "<boby>\n");

	
	/*process http req and require a auth request with AC*/
	STAuthProcess stAuth;
	memset(&stAuth, 0, sizeof(STAuthProcess));

	cgi_auth_init(&stAuth, 2000);
	STUserManagePkg * pstReq = NULL;
	STUserManagePkg * pstRsp = NULL;
	char urlPost[4096]={0};
	char *urlNew = NULL;
	char *replace = NULL;
	char urlParam[128] = "";
	char urlValue[256] = "";
	struct in_addr user_ip;
	struct in6_addr user_ipv6;
	
	fprintf(stderr, "a_name=%s, a_pass=%s, op_auth=%s, userIp=%s, acIp=%s, cgiRemoteAddr=%s, cgiServerName=%s\n",
			userInfo.usrName, userInfo.usrPass, opt, userIp, acIp, cgiRemoteAddr, cgiServerName);
	#if 1

	fprintf(stderr,"cgiReferrer=%s\n", cgiReferrer  );
	#endif
	strncpy(urlPost, cgiReferrer, strlen(cgiReferrer));
	#if 0
	fprintf(stderr,"before urlPost=%s\n" ,urlPost );
	replace = strrchr(urlPost, '//');
	fprintf(stderr,"before replace=%s\n" ,replace );
	int partLen = strlen(replace);
	memset(replace, "\0", partLen);
	fprintf(stderr,"inner urlPost=%s\n" ,urlPost );
	memcpy(replace, "/auth_suc.html", strlen("/auth_suc.html")+1);
	
	fprintf(stderr,"last urlPost=%s--partLen=%d\n" ,urlPost, partLen );
	#endif
	
	fprintf(stderr,"userInfo.usrOperation=%d\n" ,userInfo.usrOperation );
	switch(userInfo.usrOperation)
	{
		case 1:/*login*/
			//stAuth.protocal = AUTH_CHAP;

			pstReq =  createRequirePkg(REQ_GET_AUTH_TYPE,NULL,NULL);

			/*connect unix sock to get auth type*/
			//fd = suc_connect_unix_sock();
			//if(fd <= -1)
			//{
			//	fprintf(stderr,"suc_connect_unix_sock: error\n");
			//	break;
			//}

			//fprintf(stderr,"fd=%d",fd);
			stAuth.protocal = AUTH_CHAP;//get_authType_from_eag( pstReq, fd, 5, &(pstRsp));
			//fprintf(stderr,"stAuth.protocal=%d",stAuth.protocal);
			//close( fd );

			if( stAuth.protocal == AUTH_CHAP )				/*chap md5 simulation----------*/
			{
				ret_challege = CgiInformAc(userIp, acIp, REQ_CHALLENGE, &stAuth, stAuth.protocal);
				fprintf(stderr,"ret_challege=%d", ret_challege);
				if( CHALLENGE_SUCCESS == ret_challege || CHALLENGE_CONNECTED == ret_challege )/*if ret is success ,then can get attr from rev pkg*/
				{
					if((tlvPkgAttr = getAttrByAttrType(stAuth.pRevPkg, ATTR_CHALLENGE)) == NULL && CHALLENGE_CONNECTED == ret_challege)
					{
						retLogin = 0;/*容僕suc.html*/
						break;
					}
				}
				else
				{
					retLogin = -1;/*容僕fail.html*/
					break;
				}
				memcpy(chap_challenge, tlvPkgAttr->attr_value, tlvPkgAttr->attr_len);
				fprintf(stderr,"chap_challenge() value %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", \
						 chap_challenge[0],chap_challenge[1],chap_challenge[2],
						chap_challenge[3],chap_challenge[4],chap_challenge[5],chap_challenge[6],chap_challenge[7],chap_challenge[8],chap_challenge[9],
						chap_challenge[10],chap_challenge[11],chap_challenge[12],chap_challenge[13],chap_challenge[14],chap_challenge[15] );
				reqID = getRequireID(stAuth.pRevPkg);
				fprintf(stderr,"CHAP: reqID=%d\n",reqID);
				unsigned char chap_id = (unsigned char)reqID ;
				fprintf(stderr, "chap_id=%d\n",chap_id);

				/*simulate MD5 encoded at portal server add by tangsiqi 2010-1-5*/

				MD5Init(&context);
				MD5Update(&context, (UINT8 *)&chap_id, 1);
				MD5Update(&context, (UINT8 *)userInfo.usrPass, strlen(userInfo.usrPass));/*now the password is get through by redir url */
				MD5Update(&context, chap_challenge, MD5LEN);
				MD5Final(tmp, &context);
				tmp[MD5LEN] = 0;/*add 0 at end of char[]*/
				fprintf(stderr,"CHAP: tmp=%s",tmp);

				memcpy(chap_password, tmp, MD5LEN );
				chap_password[MD5LEN+1] = 0;
				fprintf(stderr,"...add attr CHAP_PASSWORD() value %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", \
						 chap_password[0],chap_password[1],chap_password[2],
						chap_password[3],chap_password[4],chap_password[5],chap_password[6],chap_password[7],chap_password[8],chap_password[9],
						chap_password[10],chap_password[11],chap_password[12],chap_password[13],chap_password[14],chap_password[15] );

				destroyPortalPkg(stAuth.pSendPkg);
				destroyPortalPkg(stAuth.pRevPkg);
 			}

			/*after challege exchange*/
			stAuth.pSendPkg = createPortalPkg(REQ_AUTH);
			fprintf(stderr,"login createPortalPkg suc\n" );

			/*malloc STPortalPkg ready to rev data*/
			stAuth.pRevPkg = (STPortalPkg * )malloc(sizeof(STPortalPkg));
			memset(stAuth.pRevPkg, 0, sizeof(STPortalPkg));

			setAuthType(stAuth.pSendPkg, stAuth.protocal);
			setRequireID(stAuth.pSendPkg, reqID );
			memset(&user_ip, 0, sizeof(user_ip));
			memset(&user_ipv6, 0, sizeof(user_ipv6));
			if (1 == inet_pton(AF_INET, userIp, &user_ip)) {
				fprintf(stderr,"userIp4=%s\n",userIp);
				setPkgUserIP( stAuth.pSendPkg, user_ip.s_addr );
			} else if (1 == inet_pton(AF_INET6, userIp, &user_ipv6)){
				fprintf(stderr,"userIp6=%s\n",userIp);
				stAuth.pSendPkg->version = 0x02;
				setPkgUserIP( stAuth.pSendPkg, 0 );
				addAttr( &stAuth.pSendPkg, ATTR_USER_IPV6, &user_ipv6, sizeof(user_ipv6) );
			}
			fprintf(stderr,"version=%u\n", stAuth.pSendPkg->version);

			addAttr( &stAuth.pSendPkg, ATTR_USERNAME, userInfo.usrName, strlen(userInfo.usrName) );

			if( stAuth.protocal == AUTH_CHAP )
			{
				/*challenge exchange*/
				addAttr( &stAuth.pSendPkg, ATTR_CHAPPASSWORD, chap_password, MD5LEN );
			}
			else/*PAP authentication*/
			{
				fprintf(stderr,"userInfo.usrPass=%s",userInfo.usrPass);
				addAttr( &stAuth.pSendPkg, ATTR_PASSWORD, userInfo.usrPass, strlen(userInfo.usrPass) );
			}

			if(sendPortalPkg(stAuth.fd, 6, 2000, acIp, stAuth.pSendPkg) < 0 )
			{
				fprintf(stderr,"login sendPortalPkg failed\n" );
				retLogin = -1;
			}
			else
			{
				fprintf(stderr,"login sendPortalPkg suc\n" );
			}

			if(getPortalPkg(stAuth.fd, 12, &(stAuth.pRevPkg))<0)
			{
				fprintf(stderr,"login getPortalPkg failed\n" );
				retLogin = -1;
			}
			else
			{
				fprintf(stderr,"login getPortalPkg suc\n" );
			}
			retLogin = getErrCode(stAuth.pRevPkg);
			fprintf(stderr,"login getErrCode(stAuth.pRevPkg)=%d\n", retLogin );


			destroyPortalPkg(stAuth.pSendPkg);
			destroyPortalPkg(stAuth.pRevPkg);
			break;
		case 2:/*logout*/
			retLogout = CgiInformAc(userIp, acIp, REQ_LOGOUT, &stAuth, stAuth.protocal);
			destroyPortalPkg(stAuth.pSendPkg);
			destroyPortalPkg(stAuth.pRevPkg);
			break;
		default:
			break;
	}
	
	
	fprintf(stderr,"retLogin=%d---retLogout=%d\n" ,retLogin,retLogout );
	closePkgSock(&stAuth);
	if( retLogin==100 ||  retLogout==100 )/*time out will retry,reserve*/
	{
		fprintf( fpOut, "<table border=0 cellspacing=0 cellpadding=0><tr><td colspan=2>time out!please retry or return</td></tr>\n");
		fprintf( fpOut, "<tr><td><input type='submit' name='retry' value='retry'></td><td><input type='submit' name='return' value='return'></td></tr>\n");
		fprintf( fpOut, "</table>\n");
		goto html_end;
	}

	snprintf(urlParam, sizeof(urlParam)-1, "wlanacip=%s&wlanuserip=%s&ssid=%s", acIp, userIp, ssid);
	if( userInfo.usrOperation == 1 )/*login*/
	{
		switch(retLogin)
		{
			case PORTAL_AUTH_SUCCESS:
			case PORTAL_AUTH_CONNECTED: /* urlNew = replaceStrPart(urlPost, "/auth_suc.html"); locate(fpOut, urlNew);break; */
				snprintf(urlValue, sizeof(urlValue)-1, "/auth_suc.html?%s", urlParam);
				urlNew = replaceStrPart(urlPost, urlValue);
				locate(fpOut, urlNew);
				break;
			case PORTAL_AUTH_REJECT: 	/* urlNew = replaceStrPart(urlPost, "/auth_fail.html"); locate(fpOut, urlNew);break; */
			case PORTAL_AUTH_ONAUTH: 	/* urlNew = replaceStrPart(urlPost, "/auth_fail.html"); locate(fpOut, urlNew);break; */
			case PORTAL_AUTH_FAILED: 	/* urlNew = replaceStrPart(urlPost, "/auth_fail.html"); locate(fpOut, urlNew);break; */
				snprintf(urlValue, sizeof(urlValue)-1, "/auth_fail.html?%s", urlParam);
				urlNew = replaceStrPart(urlPost, urlValue);
				locate(fpOut, urlNew);
				break;
			case -1:					/* urlNew = replaceStrPart(urlPost, "/login.html"); locate(fpOut, urlNew);break; */
				snprintf(urlValue, sizeof(urlValue)-1, "/login.html?%s", urlParam);
				urlNew = replaceStrPart(urlPost, urlValue);
				locate(fpOut, urlNew);
				break;
			default:
				break;
		}
	}
	else if( userInfo.usrOperation == 2 )/*logout*/
	{
		switch(retLogout)
		{
			case EC_ACK_LOGOUT_SUCCESS: /* urlNew = replaceStrPart(urlPost, "/login.html"); locate(fpOut, urlNew);break; */
				snprintf(urlValue, sizeof(urlValue)-1, "/login.html?%s", urlParam);
				urlNew = replaceStrPart(urlPost, urlValue);
				locate(fpOut, urlNew);
				break;
			case -1:
			case EC_ACK_LOGOUT_REJECT: 	/* urlNew = replaceStrPart(urlPost, "/auth_suc.html"); locate(fpOut, urlNew);break; */
			case EC_ACK_LOGOUT_FAILED: 	/* urlNew = replaceStrPart(urlPost, "/auth_suc.html"); locate(fpOut, urlNew);break; */
				snprintf(urlValue, sizeof(urlValue)-1, "/auth_suc.html?%s", urlParam);
				urlNew = replaceStrPart(urlPost, urlValue);
				locate(fpOut, urlNew);
				break;
			default:
				break;
		}
	}
html_end:

	fprintf( fpOut, "</body>\n" );
	fprintf( fpOut, "</html>\n" );

		
}
Example #9
0
// ----------------------------------------------------------------------------
// Method: registerUser
//
// registers a user in the Trafodion metadata
//
// Input:  parse tree containing a definition of the user
// Output: the global diags area is set up with the result
// ----------------------------------------------------------------------------
void CmpSeabaseDDLuser::registerUser(StmtDDLRegisterUser * pNode)
{
  // Set up a global try/catch loop to catch unexpected errors
  try
  {
    // Verify user is authorized

    verifyAuthority();

    // Verify that the specified user name is not reserved
    // TBD - add the isCatman concept
    if (isAuthNameReserved(pNode->getDbUserName()))
    {
      *CmpCommon::diags() << DgSqlCode (-CAT_AUTH_NAME_RESERVED)
                          << DgString0(pNode->getDbUserName().data());
      DDLException excp (CAT_AUTH_NAME_RESERVED, NULL, 0);
      excp.throwException();
    }


    // set up class members from parse node
    setAuthDbName(pNode->getDbUserName());
    setAuthExtName(pNode->getExternalUserName());
    setAuthImmutable(pNode->isImmutable());
    setAuthType(COM_USER_CLASS);  // we are a user
    setAuthValid(true); // assume a valid user

    Int64 createTime = NA_JulianTimestamp();
    setAuthCreateTime(createTime);
    setAuthRedefTime(createTime);  // make redef time the same as create time

    // Make sure db user has not already been registered
    if (authExists())
    {
      *CmpCommon::diags() << DgSqlCode(-CAT_AUTHID_ALREADY_EXISTS)
                          << DgString0(getAuthDbName().data());
      DDLException excp (CAT_AUTHID_ALREADY_EXISTS, NULL, 0);
      excp.throwException();
    }

    // Make sure external user has not already been registered
    if (authExists(true))
    {
      *CmpCommon::diags() << DgSqlCode(-CAT_LDAP_USER_ALREADY_EXISTS)
                          << DgString0(getAuthExtName().data());
      DDLException excp (CAT_LDAP_USER_ALREADY_EXISTS, NULL, 0);
      excp.throwException();
    }

DBUserAuth::AuthenticationConfiguration configurationNumber = DBUserAuth::DefaultConfiguration;
DBUserAuth::AuthenticationConfiguration foundConfigurationNumber = DBUserAuth::DefaultConfiguration;

    if (!validateExternalUsername(pNode->getExternalUserName().data(),
                                  configurationNumber,
                                  foundConfigurationNumber))
       return;

    // Get a unique auth ID number
    // TBD - check a parserflag (or something) to add DB__ROOT
    Int32 userID = 0;
    if (getAuthDbName() == DB__ROOT)
      userID = SUPER_USER;
    else
      userID = getUniqueUserID();

    setAuthID (userID);

    // If the BY clause was specified, then register the user on behalf of the
    // authorization ID specified in this clause.
    // Need to translate the creator name to its authID
    if (pNode->getOwner() == NULL)
    {
      // get effective user from the Context
      // TBD - replace this call with SQL_EXEC_ call
      Int32 *pUserID = GetCliGlobals()->currContext()->getDatabaseUserID();
      setAuthCreator(*pUserID);
    }
    else
    {
      const NAString creatorName =
        pNode->getOwner()->getAuthorizationIdentifier();
      // TBD: get the authID for the creatorName
      // TBD: verify creator can register users
      setAuthCreator(NA_UserIdDefault);
    }

    // Add the user to AUTHS table
    insertRow();
  }
  catch (...)
  {
    // At this time, an error should be in the diags area.
    // If there is no error, set up an internal error
    Int32 numErrors = CmpCommon::diags()->getNumber(DgSqlCode::ERROR_);
    if (numErrors == 0)
      *CmpCommon::diags() << DgSqlCode (-CAT_INTERNAL_EXCEPTION_ERROR)
                          << DgInt0(__LINE__)
                          << DgString0("register user");

  }
}
Example #10
0
// select exact
bool CmpSeabaseDDLauth::selectExactRow(const NAString & cmd)
{
  ExeCliInterface cliInterface(STMTHEAP);

  Int32 cliRC = cliInterface.fetchRowsPrologue(cmd.data(), true/*no exec*/);
  if (cliRC < 0)
    {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      DDLException excp (cliRC, NULL, 0);
      excp.throwException();
    }

  cliRC = cliInterface.clearExecFetchClose(NULL, 0);
  if (cliRC < 0)
    {
      cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
      DDLException excp (cliRC, NULL, 0);
      excp.throwException();
    }

  // if diags not cleared, then no error is returned -- ??
  if (cliRC == 100) // did not find the row
  {
    cliInterface.clearGlobalDiags();
    return false;
  }

  char * ptr = NULL;
  Lng32 len = 0;
  char type [6];

  // value 1:  auth_id (int32)
  cliInterface.getPtrAndLen(1, ptr, len);
  setAuthID(*(Int32*)ptr);

  // value 2: auth_db_name (NAString)
  cliInterface.getPtrAndLen(2,ptr,len);
  NAString dbName(ptr,len);
  setAuthDbName(dbName);

  // value 3: auth_ext_name (NAString)
  cliInterface.getPtrAndLen(3,ptr,len);
  NAString extName(ptr,len);
  setAuthExtName(extName);

  // value 4: auth_type (char)
  // str_cpy_and_null params: *tgt, *src, len, endchar, blank, null term
  cliInterface.getPtrAndLen(4,ptr,len);
  str_cpy_and_null(type, ptr, len, '\0', ' ', true);
  if ( type[0] == 'U')
    setAuthType(COM_USER_CLASS);
  else if (type[0] == 'R')
    setAuthType(COM_USER_CLASS);
  else
    setAuthType(COM_UNKNOWN_ID_CLASS);

  // value 5: auth_creator (int32)
  cliInterface.getPtrAndLen(5,ptr,len);
  setAuthCreator(*(Int32*)ptr);

  // value 6: auth_is_valid (char)
  cliInterface.getPtrAndLen(6,ptr,len);
  str_cpy_and_null(type, ptr, len, '\0', ' ', true);
  if (type[0] == 'Y')
    setAuthValid(true);
  else
    setAuthValid(false);

  // value 7: auth_create_time (int64)
  cliInterface.getPtrAndLen(7,ptr,len);
  Int64 intValue = *(Int64*)ptr;
  setAuthCreateTime((ComTimestamp) intValue);

  // value 8: auth_redef_time (int64)
  cliInterface.getPtrAndLen(8,ptr,len);
  intValue = *(Int64*)ptr;
  setAuthRedefTime((ComTimestamp) intValue);

  cliInterface.fetchRowsEpilogue(NULL, true);
  return true;
}
Example #11
0
int cgiMain()
{
	int retLogin=0,ResponseCode= 0;
	unsigned short reqID = 0;
	FILE * fpOut = cgiOut;
	char  WISPrVersion[MAX_EAG_WISPR_VERSION_LEN+1] = {0};
	STUserInfo userInfo;
	STAuthProcess stAuth;
	UINT32 userip = 0;
	char userip_str[32]="";
	int ret;
	UINT32 timeout = DEFAULT_PORTAL_REQ_TIMEOUT;
	char timeout_str[32];
	char *ReplyMessage = NULL;
	char *RedirectionURL = NULL;
	UINT32 MaxSessionTime = 0;
	
	memset(&stAuth, 0, sizeof(STAuthProcess));

	cgi_auth_init(&stAuth, 2000);
	memset(&userInfo, 0 ,sizeof(STUserInfo));
	
	ret = cgiFormStringNoNewlines("WISPrVersion", WISPrVersion, MAX_EAG_WISPR_VERSION_LEN);
	if (cgiFormNotFound == ret) {
		strcpy(WISPrVersion,"1");
	}
	cgiFormStringNoNewlines("UserName", userInfo.usrName, MAX_EAG_LOGIN_NAME_LEN);
	cgiFormStringNoNewlines("Password", userInfo.usrPass, MAX_EAG_LOGIN_PASS_LEN);

	memset (userip_str, 0, sizeof(userip_str) );
	ret = cgiFormStringNoNewlines("UserIP", userip_str, sizeof(userip_str));
	if( cgiFormNotFound == ret ){
		fprintf(stderr,"UserIP not find! use cgiRemoteAddr=%s\n",cgiRemoteAddr);
		strncpy (userip_str, cgiRemoteAddr, sizeof(userip_str)-1);		
	}
	userip = htonl(inet_addr(userip_str));

	if (0 == userip) {
		fprintf(stderr, "user ip is 0!!\n" );
	}
	
	ret = cgiFormStringNoNewlines("TimeOut", timeout_str, sizeof(timeout_str)-1);
	if (cgiFormSuccess == ret) {
		timeout = atoi(timeout_str);
		if (timeout<MIN_PORTAL_REQ_TIMEOUT || timeout>MAX_PORTAL_REQ_TIMEOUT) {
			timeout = DEFAULT_PORTAL_REQ_TIMEOUT;
		}
	}
	fprintf(stderr,"login WISPrVersion:%s,UserName:%s,Password=%s.\n",WISPrVersion,userInfo.usrName,userInfo.usrPass);
		
	/*after challege exchange*/
	stAuth.pSendPkg = createPortalPkg(REQ_AUTH);
	fprintf(stderr,"login createPortalPkg suc\n" );
	
	/*malloc STPortalPkg ready to rev data*/
	stAuth.pRevPkg = (STPortalPkg * )malloc(sizeof(STPortalPkg));
	memset(stAuth.pRevPkg, 0, sizeof(STPortalPkg));

	stAuth.protocal = AUTH_PAP;
	setAuthType(stAuth.pSendPkg, stAuth.protocal);
	setRequireID(stAuth.pSendPkg, reqID );
	setPkgUserIP( stAuth.pSendPkg, userip );
	
	addAttr( &stAuth.pSendPkg, ATTR_USERNAME, userInfo.usrName, strlen(userInfo.usrName) );
	
	fprintf(stderr,"userInfo.usrPass=%s",userInfo.usrPass);
	addAttr( &stAuth.pSendPkg, ATTR_PASSWORD, userInfo.usrPass, strlen(userInfo.usrPass) );
	
	if(sendPortalPkg(stAuth.fd, (timeout+1)/2, 2000, cgiServerName, stAuth.pSendPkg) < 0 )
	{
		fprintf(stderr,"login sendPortalPkg failed\n" );
		retLogin = -1;
	}
	else
	{
		fprintf(stderr,"login sendPortalPkg suc\n" );
	}
	
	if(getPortalPkg(stAuth.fd, timeout/2, &(stAuth.pRevPkg))<0)
	{
		fprintf(stderr,"login getPortalPkg failed\n" );
		retLogin = -1;
	}
	else
	{
		fprintf(stderr,"login getPortalPkg suc\n" );
		retLogin = getErrCode(stAuth.pRevPkg);
	}
	
	fprintf(stderr,"login getErrCode(stAuth.pRevPkg)=%d\n", retLogin );

//		WISPr response
//		<MessageType>120</MessageType>	//Required
//		<ResponseCode>{Response Code}</ResponseCode>	//Required
//		<ReplyMessage>{Reply Message Text}</ReplyMessage>	//Conditional Required
//		<LogoffURL>http[s]:/*{site specific logoffURL}*/</LogoffURL>	//Conditional Required
//		<RedirectionURL>http[s]:/*{redirection URL}*/</RedirectionURL>	//Optional
//		<StatusURL>http[s]:/*{status URL}*/</StatusURL>	//Conditional Required
//		<MaxSessionTime>{Maximum Session Time}</MaxSessionTime>
	switch(retLogin){
		case 0:
			ResponseCode=50;	//Login succeeded (Access ACCEPT)
			break;
		case 1:
			ResponseCode=100;	//Login failed (Access REJECT)
			break;
#if 0				
		case:
			ResponseCode=102;	//Authentication server error/timeout
			break;
		case:
			ResponseCode=105;	//Network Administrator Error: No authentication server enabled
			break;
		case:
			ResponseCode=252;	//Invalid state for WISPr request
			break;
		case:
			ResponseCode=253;	//MTU of AAA message is too big
			break;
		case:
			ResponseCode=254;	//Protocol error
			break;
		case:
			ResponseCode=255;	//Access gateway internal error
			break;
#endif				
		default:
			ResponseCode=100;
			fprintf(stderr,"login err retcode(%d) not found!",retLogin);
			break;
	}
/*html pre*/
	cgiHeaderContentType("text/html");
	fprintf( fpOut, "<html xmlns=\"http://www.w3.org/1999/xhtml\"> \n" );
	fprintf( fpOut, "<head> \n" );
#if 0	
	fprintf( fpOut, "<meta http-equiv=\"Content-Type\" content=\"text/html;\" charset=\"gb2312\"> \n" );


  	fprintf( fpOut, "<META   HTTP-EQUIV=\"pragma\"   CONTENT=\"no-cache\"> \n");
  	fprintf( fpOut, "<META   HTTP-EQUIV=\"Cache-Control\"   CONTENT=\"no-cache\"> \n" );
  	fprintf( fpOut, "<META   HTTP-EQUIV=\"expires\"   CONTENT=\"0\">\n");
#endif

	fprintf( fpOut, "<title>login_proc</title> \n");
	fprintf( fpOut, "</head> \n" );
	fprintf( fpOut, "<body> \n");
/*xml */	
	fprintf( fpOut, "<!-- \n" );
	fprintf( fpOut, "<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n" );
	fprintf( fpOut, "<WISPAccessGatewayParam  \n"
					"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n"
					"xsi:noNamespaceSchemaLocation=\"http://www.acmewisp.com/WISPAccessGatewayParam.xsd\"> \n" );
	fprintf( fpOut, "  <AuthenticationReply> \n");
	fprintf( fpOut, "    <MessageType>120</MessageType> \n    <ResponseCode>%d</ResponseCode> \n",ResponseCode);
	if (ReplyMessage && strlen(ReplyMessage)>0){
		fprintf( fpOut, "    <ReplyMessage>%s</ReplyMessage> \n",ReplyMessage);
	}else if (0 != retLogin) {
		fprintf( fpOut, "    <ReplyMessage>Login Failed.Please check your username and password!</ReplyMessage> \n" );
	}
	fprintf( fpOut, "    <LogoffURL>%s://%s:%s/wispr/logout?UserIP=%s</LogoffURL> \n",
						urlprefix,cgiServerName, cgiServerPort, userip_str );
	if (RedirectionURL && strlen(RedirectionURL)>0){
		fprintf( fpOut,	"    <RedirectionURL>%s</RedirectionURL> \n",RedirectionURL);
	}
#if 0	
	fprintf( fpOut, "    <StatusURL>%s://%s:%s/wispr/status?UserIP=%s</StatusURL> \n",
						urlprefix,cgiServerName, cgiServerPort, userip_str );
#endif
	if (MaxSessionTime) {
		fprintf( fpOut,	"    <MaxSessionTime>%u</MaxSessionTime> \n",MaxSessionTime);
	}
	fprintf( fpOut, "  </AuthenticationReply>\n</WISPAccessGatewayParam> \n" );
	
	destroyPortalPkg(stAuth.pSendPkg);
	destroyPortalPkg(stAuth.pRevPkg);
	fprintf( fpOut, "--> \n" );	
/*xml  end*/
#if 0
	if ( 0 == retLogin ){
		fprintf( fpOut, "login successful!\n" );
	}
	if (ReplyMessage && strlen(ReplyMessage)>0){
		fprintf( fpOut, "ReplyMessage=%s\n",ReplyMessage );
	}

#endif	           
/**/
	  
	fprintf( fpOut, "</body>\n" );
	fprintf( fpOut, "</html>\n" );

	/* adding aff_ack_auth package	*/
	// err_code=0 means ack-auth normal succeed
	if (0 == retLogin ) { 
		/*after auth exchange*/
		stAuth.pSendPkg = createPortalPkg(AFF_ACK_AUTH);
		
		/*malloc STPortalPkg ready to rev data*/
		stAuth.pRevPkg = (STPortalPkg * )malloc(sizeof(STPortalPkg));
		memset(stAuth.pRevPkg, 0, sizeof(STPortalPkg));
		
		setAuthType(stAuth.pSendPkg, stAuth.protocal);
		setRequireID(stAuth.pSendPkg, reqID );
		setPkgUserIP( stAuth.pSendPkg, htonl(inet_addr(cgiRemoteAddr)) );
	
		if(sendPortalPkg(stAuth.fd, 3, 2000, cgiServerName, stAuth.pSendPkg) < 0 )
		{
			fprintf(stderr,"auth sendPortalPkg failed\n" );
			retLogin = -1;
		}
		else
		{
			fprintf(stderr,"auth sendPortalPkg suc\n" );
		}
	
		destroyPortalPkg(stAuth.pSendPkg);
		destroyPortalPkg(stAuth.pRevPkg);
	}


	return 0;
}