Ejemplo n.º 1
0
GBool SecurityHandler::checkEncryption(GooString *ownerPassword,
                                       GooString *userPassword) {
    void *authData;
    GBool ok;
    int i;

    if (ownerPassword || userPassword) {
        authData = makeAuthData(ownerPassword, userPassword);
    } else {
        authData = NULL;
    }
    ok = authorize(authData);
    if (authData) {
        freeAuthData(authData);
    }
    for (i = 0; !ok && i < 3; ++i) {
        if (!(authData = getAuthData())) {
            break;
        }
        ok = authorize(authData);
        if (authData) {
            freeAuthData(authData);
        }
    }
    if (!ok) {
        error(-1, "Incorrect password");
    }
    return ok;
}
Ejemplo n.º 2
0
// Return 1 if request is authorised, 0 otherwise.
static int check_authorization(struct mg_connection *conn, const char *path) {
  char fname[PATH_MAX];
  struct vec uri_vec, filename_vec;
  const char *list;
  FILE *fp = NULL;
  int authorized = 1;

  list = conn->ctx->config[PROTECT_URI];
  while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) {
    if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) {
      mg_snprintf(fname, sizeof(fname), "%.*s",
                  (int) filename_vec.len, filename_vec.ptr);
      fp = mg_fopen(fname, "r");
      break;
    }
  }

  if (fp == NULL) {
    fp = open_auth_file(conn, path);
  }

  if (fp != NULL) {
    authorized = authorize(conn, fp);
    fclose(fp);
  }

  return authorized;
}
Ejemplo n.º 3
0
void main (int argc, char *argu[]) {
	char *name, *pass;
	size_t n;
	int ii, flags = GoKeepEnviron;
	for (ii = 1; ii < argc; ii++) {
		if (argu[ii][0] != '-' || argu[ii][1] == 0) break;
		if (argu[ii][1] == '-' && argu[ii][2] == 0) {
			ii++;
			break;
		}
		for (int jj = 1; argu[ii][jj]; jj++) switch (argu[ii][jj]) {
		case 'l':
			flags |=  GoChdirHome;
			flags &= ~GoKeepEnviron;
			break;
		default:
			errx ("bad option %c", argu[ii][jj]);
		}
	}
	
	name = ii >= argc ? "root" : argu[ii];
	pass = getpass ("Password: "******"Denied\n", stdout);
	errx (1, "authorization failed");
}
Ejemplo n.º 4
0
void OAuthWizard::authorize()
{
  ui_p->pinEdit->setEnabled( false );
  QOAuth::ParamMap otherArgs;
  otherArgs.insert( ParamVerifier, ui_p->pinEdit->text().toAscii() );
  QOAuth::ParamMap accessToken = qoauth->accessToken( TwitterAccessTokenURL, QOAuth::POST, token,
                                                      tokenSecret, QOAuth::HMAC_SHA1, otherArgs );

  if ( qoauth->error() != QOAuth::NoError ) {
    ui_p->pinEdit->hide();
    ui_p->pinLabel->setText( tr( "Either the PIN you entered is incorrect, or a network-related problem occured. Please try again later." ) );
    ui_p->okButton->setText( tr( "Retry" ) );
    adjustSize();
    resize( width(), height() * 1.5 );
    disconnect( ui_p->okButton, SIGNAL(clicked()), this, SLOT(authorize()) );
    connect( ui_p->okButton, SIGNAL(clicked()), this, SLOT(openUrl()) );
    state = false;
    return;
  }

  screenName = accessToken.value( ParamScreenName );
  token = accessToken.value( QOAuth::ParamToken );
  tokenSecret = accessToken.value( QOAuth::ParamTokenSecret );
  state = true;
  accept();
}
int restful_rhizome_insert(httpd_request *r, const char *remainder)
{
  r->http.response.header.content_type = CONTENT_TYPE_JSON;
  if (*remainder)
    return 404;
  if (!is_rhizome_http_enabled())
    return 403;
  if (r->http.verb != HTTP_VERB_POST)
    return 405;
  int ret = authorize(&r->http);
  if (ret)
    return ret;
  // Parse the request body as multipart/form-data.
  assert(r->u.insert.current_part == NULL);
  assert(!r->u.insert.received_author);
  assert(!r->u.insert.received_secret);
  assert(!r->u.insert.received_manifest);
  assert(!r->u.insert.received_payload);
  bzero(&r->u.insert.write, sizeof r->u.insert.write);
  r->u.insert.write.blob_fd = -1;
  r->finalise_union = finalise_union_rhizome_insert;
  r->http.form_data.handle_mime_part_start = insert_mime_part_start;
  r->http.form_data.handle_mime_part_end = insert_mime_part_end;
  r->http.form_data.handle_mime_part_header = insert_mime_part_header;
  r->http.form_data.handle_mime_body = insert_mime_part_body;
  // Perform the insert once the body has arrived.
  r->http.handle_content_end = restful_rhizome_insert_end;
  return 1;
}
Ejemplo n.º 6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connectionManager = new QTcpSocket(this);

    form = new ChatBoxDialog(0);

    createdTabs = new QMap<QString, ChatBoxDialogContent*>;

    createStatusBar();

    createTrayIcon();

    openLocalDatabase();

    loadMyProfile();

    initContactsList();

    this->settings = new QSettings("settings.ini", QSettings::IniFormat);

    QString hostname = this->settings->value("Server/Hostname").toString();
    int port = this->settings->value("Server/Port").toInt();

    connect(this->connectionManager, SIGNAL(connected()), this, SLOT(authorize()));
    connectToServer(hostname, port);
}
Ejemplo n.º 7
0
void main (int argc, char *argu[]) {
	char *name, *pass;
	size_t n;
	int ii;
	name = "root";
	for (ii = 1; ii < argc; ii++) {
		if (argu[ii][0] != '-' || argu[ii][1] == 0) break;
		if (argu[ii][1] == '-' && argu[ii][2] == 0) {
			ii++;
			break;
		}
		switch (argu[ii][1]) {
		case 'u':
			name = argu[++ii];
			break;
		default:
			errx (1, "bad option %c", argu[ii][1]);
		}
	}
	
	if (ii > argc) errx (1, "bad arguments");
	pass = getpass ("Password: "******"Denied\n", stdout);
	errx (1, "authorization failed");
}
Ejemplo n.º 8
0
//ダイアログの実行開始
int TweetDialog::exec()
{
    //認証済みか確認
    authorize();

    //ハッシュタグ


    return QDialog::exec();
}
Ejemplo n.º 9
0
/** \brief This function actually does an Authorization then a Charge Preauth.
           Changes don't occurr real-time so we do the preauth real-time and
           if that succeeds just put the record in the correct state to be
           charged later. If the processor can't do the charge then the transaction
           must be undone.
 */
int  PaymentechProcessor::doCharge(const int pccardid, const int pcvv, const double pamount, const double ptax, const bool ptaxexempt, const double pfreight, const double pduty, const int pcurrid, QString& pneworder, QString& preforder, int &pccpayid, ParameterList &pparams)
{
  if (DEBUG)
    qDebug("Paymentech:doCharge(%d, %d, %f, %f, %d, %f, %f, %d, %s, %s, %d)",
	   pccardid, pcvv, pamount,  ptax, ptaxexempt,  pfreight,  pduty, pcurrid,
	   pneworder.toAscii().data(), preforder.toAscii().data(), pccpayid);

  int    returnValue = 0;

  int refid = 0;
  returnValue = authorize(pccardid, pcvv, pamount, ptax, ptaxexempt, pfreight, pduty, pcurrid, pneworder, preforder, pccpayid, "", refid);
  /* don't return here because the caller is going to need all of the parameter data
  if(returnValue < 0)
  {
    return returnValue;
  }
  */

  double amount  = pamount;
  int    currid  = pcurrid;

  XSqlQuery ccq;
  ccq.prepare("SELECT ccpay_r_avs, ccpay_r_ordernum, ccpay_r_error,"
              "       ccpay_r_code, ccpay_r_shipping, ccpay_r_tax,"
              "       ccpay_r_ref, ccpay_r_message, ccpay_yp_r_tdate"
              "  FROM ccpay"
              " WHERE(ccpay_id=:ccpayid);");
  ccq.bindValue(":ccpayid", pccpayid);
  ccq.exec();
  if(!ccq.first())
  {
    return -1;
  }

  pparams.append("ccard_id",    pccardid);
  pparams.append("currid",      currid);
  pparams.append("auth_charge", "C");
  pparams.append("type",        "C");
  pparams.append("status",      "C");
  pparams.append("reforder",    (preforder.isEmpty()) ? pneworder : preforder);
  pparams.append("ordernum",    pneworder);
  pparams.append("approved",    "SUBMITTED");
  pparams.append("avs",         ccq.value("ccpay_r_avs").toString());
  pparams.append("xactionid",   ccq.value("ccpay_r_ordernum").toString());
  pparams.append("error",       ccq.value("ccpay_r_error").toString());
  pparams.append("code",        ccq.value("ccpay_r_code").toString());
  pparams.append("shipping",    ccq.value("ccpay_r_shipping").toString());
  pparams.append("tax",         ccq.value("ccpay_r_tax").toString());
  pparams.append("ref",         ccq.value("ccpay_r_ref").toString());
  pparams.append("message",     ccq.value("ccpay_r_message").toString());
  pparams.append("tdate",       ccq.value("ccpay_yp_r_tdate").toString());
  pparams.append("auth",        false);
  pparams.append("amount",   amount);
  return returnValue;
}
Ejemplo n.º 10
0
static int is_authorized_for_put(struct mg_connection *conn) {
  const char *passfile = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE];
  FILE *fp;
  int ret = 0;

  if (passfile != NULL && (fp = mg_fopen(passfile, "r")) != NULL) {
    ret = authorize(conn, fp);
    fclose(fp);
  }

  return ret;
}
Ejemplo n.º 11
0
void Server::event_handler(struct mg_connection *conn, int ev, void *p) {
	struct http_message *hm = (struct http_message *) p;

	if (ev == MG_EV_SSI_CALL) {
		mbuf_resize(&conn->send_mbuf, conn->send_mbuf.size * 2);
		std::string resp(conn->send_mbuf.buf, conn->send_mbuf.len);
		boost::replace_all(resp, "href=\"/", std::string("href=\"") + CONFIG_STRING(m_config, "service.base_location"));
		boost::replace_all(resp, "src=\"/", std::string("src=\"") + CONFIG_STRING(m_config, "service.base_location"));
		boost::replace_all(resp, "action=\"/", std::string("action=\"") + CONFIG_STRING(m_config, "service.base_location"));
		strcpy(conn->send_mbuf.buf, resp.c_str());
		mbuf_trim(&conn->send_mbuf);
		return;
	}

	if (ev != MG_EV_HTTP_REQUEST) {
		return;
	}

	hm->uri.p += CONFIG_STRING(m_config, "service.base_location").size() - 1;
	hm->uri.len -= CONFIG_STRING(m_config, "service.base_location").size() - 1;

	if (!is_authorized(conn, hm)) {
		redirect_to(conn, hm, "/login");
	} else if (mg_vcmp(&hm->uri, "/authorize") == 0) {
		authorize(conn, hm);
	} else if (mg_vcmp(&hm->uri, "/logout") == 0) {
		serve_logout(conn, hm);
// 	} else if (mg_vcmp(&hm->uri, "/users") == 0) {
// 		serve_users(conn, hm);
// 	} else if (mg_vcmp(&hm->uri, "/users/add") == 0) {
// 		serve_users_add(conn, hm);
// 	} else if (mg_vcmp(&hm->uri, "/users/remove") == 0) {
// 		serve_users_remove(conn, hm);
	} else if (has_prefix(&hm->uri, "/oauth2")) {
		serve_oauth2(conn, hm);
	} else if (has_prefix(&hm->uri, "/api/v1/")) {
		m_apiServer->handleRequest(this, get_session(hm), conn, hm);
	} else {
		if (hm->uri.p[hm->uri.len - 1] != '/') {
			std::string url(hm->uri.p, hm->uri.len);
			if (url.find(".") == std::string::npos) {
				url += "/";
				redirect_to(conn, hm, url.c_str());
				conn->flags |= MG_F_SEND_AND_CLOSE;
				return;
			}
		}
		mg_serve_http(conn, hm, s_http_server_opts);
	}

	conn->flags |= MG_F_SEND_AND_CLOSE;
}
Ejemplo n.º 12
0
int onion_handler_auth_pam_handler(onion_handler_auth_pam_data *d, onion_request *request, onion_response *res){
	/// Use session to know if already logged in, so do not mess with PAM so often.
	if (onion_request_get_session(request, "pam_logged_in"))
		return onion_handler_handle(d->inside, request, res);
	
	const char *o=onion_request_get_header(request, "Authorization");
	char *auth=NULL;
	char *username=NULL;
	char *passwd=NULL;
	if (o && strncmp(o,"Basic",5)==0){
		//fprintf(stderr,"auth: '%s'\n",&o[6]);
		auth=onion_base64_decode(&o[6], NULL);
		username=auth;
		int i=0;
		while (auth[i]!='\0' && auth[i]!=':') i++;
		if (auth[i]==':'){
			auth[i]='\0'; // so i have user ready
			passwd=&auth[i+1];
		}
		else
			passwd=NULL;
	}
	
	// I have my data, try to authorize
	if (username && passwd){
		int ok=authorize(d->pamname, username, passwd);
		
		if (ok){ // I save the username at the session, so it can be accessed later.
			onion_dict *session=onion_request_get_session_dict(request);
			onion_dict_lock_write(session);
			onion_dict_add(session, "username", username, OD_REPLACE|OD_DUP_VALUE);
			onion_dict_add(session, "pam_logged_in", username, OD_REPLACE|OD_DUP_VALUE);
			onion_dict_unlock(session);
			
			free(auth);
			return onion_handler_handle(d->inside, request, res);
		}
	}
	if (auth)
		free(auth);

	
	// Not authorized. Ask for it.
	char temp[256];
	sprintf(temp, "Basic realm=\"%s\"",d->realm);
	onion_response_set_header(res, "WWW-Authenticate",temp);
	onion_response_set_code(res, HTTP_UNAUTHORIZED);
	onion_response_set_length(res,sizeof(RESPONSE_UNAUTHORIZED));
	
	onion_response_write(res,RESPONSE_UNAUTHORIZED,sizeof(RESPONSE_UNAUTHORIZED));
	return OCS_PROCESSED;
}
Ejemplo n.º 13
0
void OAuthWizard::openUrl()
{
  QOAuth::ParamMap requestToken = qoauth->requestToken( TwitterRequestTokenURL, QOAuth::GET, QOAuth::HMAC_SHA1 );

  if ( qoauth->error() != QOAuth::NoError ) {
    if ( sender() == ui_p->okButton ) {
      delete ui_o->widget->layout();

      ui_p->okButton->deleteLater();
      ui_p->pinEdit->deleteLater();
      ui_p->pinLabel->deleteLater();
      ui_a->setupUi(ui_o->widget);
    }

    ui_a->allowLabel->setText( tr( "There was a network-related problem with completing the request. Please try again later." ) );
    ui_a->allowButton->setText( tr( "Retry" ) );
    adjustSize();
    resize( width(), height() * 1.5 );
    state = false;
    return;
  }

  token = requestToken.value( QOAuth::ParamToken );
  tokenSecret = requestToken.value( QOAuth::ParamTokenSecret );

  QString url = TwitterAuthorizeURL;

  url.append( "?" );
  url.append( "&" + QOAuth::ParamToken + "=" + token );
  url.append( "&" + ParamCallback + "=" + ParamCallbackValue );

  QDesktopServices::openUrl( QUrl( url ) );

  delete ui_o->widget->layout();

  if ( sender() == ui_p->okButton ) {
    delete ui_o->widget->layout();

    ui_p->okButton->deleteLater();
    ui_p->pinEdit->deleteLater();
    ui_p->pinLabel->deleteLater();
  } else {
    ui_a->allowLabel->deleteLater();
    ui_a->allowButton->deleteLater();
  }

  ui_p->setupUi(ui_o->widget);
  ui_p->pinEdit->setValidator( new QRegExpValidator( QRegExp( "\\d{6}" ), this ) );
  connect( ui_p->okButton, SIGNAL(clicked()), this, SLOT(authorize()) );
  connect( ui_p->pinEdit, SIGNAL(textChanged(QString)), this, SLOT(setOkButtonEnabled()) );
}
Ejemplo n.º 14
0
Archivo: etvnet.c Proyecto: serge-v/ctv
static json_object *
get_cached(const char *url, const char *name)
{
	char fname[PATH_MAX];
	char full_url[500];
	int rc = 0;
	const char *error;
	json_object *root;

	snprintf(fname, PATH_MAX-1, "%s%s.json", cache_path, name);

	if (expired(fname, 3600*24)) {
		get_full_url(url, full_url);
		rc = fetch(full_url, fname);
	}

	if (rc != 0) {
		provider->error_number = 1;
		return NULL;
	}

	root = json_object_from_file(fname);
	error = get_str(root, "error");

	if (rc == 0 && root != NULL && error == NULL)
		return root;

	sleep(2);
	authorize(NULL);
	get_full_url(url, full_url);
	rc = fetch(url, fname);

	root = json_object_from_file(fname);
	error = get_str(root, "error");

	if (rc != 0 || root == NULL) {
		sprintf(last_error, "cannot load %s. rc: %d", fname, rc);
		provider->error_number = 1;
		return NULL;
	}

	if (error != NULL) {
		remove(fname);
		sprintf(last_error, "api error: %s", error);
		provider->error_number = 1;
		return NULL;
	}

	return root;
}
Ejemplo n.º 15
0
int XttVideoMgmAimetis::check_session()
{
  pwr_tTime current;
  pwr_tDeltaTime timeout = {300,0};
  pwr_tDeltaTime dt;
  int sts = 1;

  // Check that current session hasn't timed out
  time_GetTime( &current);
  time_Adiff_NE( &dt, &current, &m_last_auth); 
  if ( time_Dcomp( &dt, &timeout) == 1)
    sts = authorize( m_op->User, m_op->Password);

  return sts;
}
Ejemplo n.º 16
0
void
authorize(const Response &challenge, Request &nextRequest,
          const std::string &username, const std::string &password)
{
    MORDOR_ASSERT(challenge.status.status == UNAUTHORIZED ||
                  challenge.status.status == PROXY_AUTHENTICATION_REQUIRED);
    bool proxy = challenge.status.status == PROXY_AUTHENTICATION_REQUIRED;
    const ChallengeList &authenticate = proxy ?
                                        challenge.response.proxyAuthenticate :
                                        challenge.response.wwwAuthenticate;
    AuthParams &authorization = proxy ?
                                nextRequest.request.proxyAuthorization :
                                nextRequest.request.authorization;
    authorize(challengeForSchemeAndRealm(authenticate, "Digest"),
              authorization, nextRequest.requestLine.uri,
              nextRequest.requestLine.method, username, password);
}
Ejemplo n.º 17
0
grpc::Status implement_status(Authorize &&authorize, F &&f) {
  try {
    const grpc::Status auth = authorize();
    if (!auth.ok()) return auth;
  } catch (std::exception &e) {
    return grpc::Status(grpc::UNKNOWN, "Unable to authorize");
  } catch (...) {
    return grpc::Status(grpc::UNKNOWN, "Unable to authorize");
  }
  try {
    return f();
  } catch (std::exception &e) {
    return grpc::Status(grpc::UNKNOWN, e.what());
  } catch (...) {
    return grpc::Status(grpc::UNKNOWN, "Unknown");
  }
}
Ejemplo n.º 18
0
int restful_rhizome_bundlelist_json(httpd_request *r, const char *remainder)
{
  r->http.response.header.content_type = CONTENT_TYPE_JSON;
  if (!is_rhizome_http_enabled())
    return 403;
  if (*remainder)
    return 404;
  if (r->http.verb != HTTP_VERB_GET)
    return 405;
  int ret = authorize(&r->http);
  if (ret)
    return ret;
  r->u.rhlist.phase = LIST_HEADER;
  r->u.rhlist.rowcount = 0;
  bzero(&r->u.rhlist.cursor, sizeof r->u.rhlist.cursor);
  http_request_response_generated(&r->http, 200, CONTENT_TYPE_JSON, restful_rhizome_bundlelist_json_content);
  return 1;
}
Ejemplo n.º 19
0
void MainServer::parseData( const QString& cmd, int clientId )
{
    Clients::iterator i = clients.find( clientId );

    if( i == clients.end() )
        return;

    if( authorize( cmd, i ) )
        return;

    if( setField( cmd, i ) )
        return;

    if( makeStep( cmd, i ) )
        return;

    i->send( "wrongcmd:" );
}
Ejemplo n.º 20
0
int XttVideoMgmAimetis::init()
{
  int sts;

  sts = authorize( m_op->User, m_op->Password);
  if ( EVEN(sts)) return sts;
  sts = get_panels();
  if ( EVEN(sts)) return sts;
  sts = get_cameras();
  if ( EVEN(sts)) return sts;
  
  // Set default panel
  sts = display_panel( m_op->DefaultPanel);
  m_op->PanelArraySelect[m_op->DefaultPanel] = 1;
  m_panel_select_old[m_op->DefaultPanel] = 1;

  return 1;
}
Ejemplo n.º 21
0
int restful_rhizome_(httpd_request *r, const char *remainder)
{
  r->http.response.header.content_type = CONTENT_TYPE_JSON;
  if (!is_rhizome_http_enabled())
    return 403;
  HTTP_HANDLER *handler = NULL;
  rhizome_bid_t bid;
  const char *end;
  if (strn_to_rhizome_bid_t(&bid, remainder, &end) != -1) {
    if (strcmp(end, ".rhm") == 0) {
      handler = restful_rhizome_bid_rhm;
      remainder = "";
    } else if (strcmp(end, "/raw.bin") == 0) {
      handler = restful_rhizome_bid_raw_bin;
      remainder = "";
    } else if (strcmp(end, "/decrypted.bin") == 0) {
      handler = restful_rhizome_bid_decrypted_bin;
      remainder = "";
    }
  }
  if (handler == NULL)
    return 404;
  if (r->http.verb != HTTP_VERB_GET)
    return 405;
  int ret = authorize(&r->http);
  if (ret)
    return ret;
  if ((r->manifest = rhizome_new_manifest()) == NULL)
    return 500;
  ret = rhizome_retrieve_manifest(&bid, r->manifest);
  if (ret == -1)
    return 500;
  if (ret == 0) {
    rhizome_authenticate_author(r->manifest);
    r->http.render_extra_headers = render_manifest_headers;
  } else {
    assert(r->manifest == NULL);
    assert(r->http.render_extra_headers == NULL);
  }
  ret = handler(r, remainder);
  return ret;
}
Ejemplo n.º 22
0
static int begin_request_handler(struct mg_connection *conn) {
  const struct mg_request_info *request_info = mg_get_request_info(conn);
  int processed = 1;

  if (!request_info->is_ssl) {
    redirect_to_ssl(conn, request_info);
  } else if (!is_authorized(conn, request_info)) {
    redirect_to_login(conn, request_info);
  } else if (strcmp(request_info->uri, authorize_url) == 0) {
    authorize(conn, request_info);
  } else if (strcmp(request_info->uri, "/ajax/get_messages") == 0) {
    ajax_get_messages(conn, request_info);
  } else if (strcmp(request_info->uri, "/ajax/send_message") == 0) {
    ajax_send_message(conn, request_info);
  } else {
    // No suitable handler found, mark as not processed. Civetweb will
    // try to serve the request.
    processed = 0;
  }
  return processed;
}
Ejemplo n.º 23
0
void main (int argc, char *argu[]) {
	char *pass;
	int ii;
	for (ii = 1; ii < argc; ii++) {
		if (argu[ii][0] != '-' || argu[ii][1] == 0) break;
		if (argu[ii][1] == '-' && argu[ii][2] == 0) {
			ii++;
			break;
		}
	}
	
	if (ii >= argc) errx (1, "no name given");
	
	pass = getpass ("Password: "******"Denied\n", stdout);
	errx (1, "authorization failed");
}
Ejemplo n.º 24
0
        Command::Status open(std::string hostname,
                                        int port,
                                Context &context) {
            *context.output << "Open connection to \"" << hostname << ":"
                << port << "\"" << std::endl;
            context.ftp.open(hostname, port);
            context.ftp.readInto(*context.output);

            Command::Status authResult = authorize(context);
            if (authResult != OK) {
                return authResult;
            }

            std::stringstream currDirStream;
            if (!context.ftp.pwd(currDirStream)) {
                return ERROR;
            }
            int pwd_code;
            currDirStream >> pwd_code;
            currDirStream >> context.workingDirectory;
            return OK;
        }
Ejemplo n.º 25
0
int main( int argc, char** argv )
{
	BApplication* pcApp = new BApplication( "application/x-vnd.KHS-desktop_manager" );

	#if 0
	if( getuid() == 0 )
	{
		const char* pzLoginName = NULL;

		if ( argc == 2 )
		{
			pzLoginName = argv[1];
		}
		authorize( pzLoginName );
	}
	#endif
	const char* pzBaseDir = getenv( "COSMOE_SYS" );
	if( pzBaseDir == NULL )
	{
		pzBaseDir = "/cosmoe";
	}
	char* pzPath = new char[ strlen(pzBaseDir) + 80 ];
	strcpy( pzPath, pzBaseDir );
	strcat( pzPath, "/backdrop.jpg" );
	g_pcBackDrop = load_jpeg( pzPath );
	delete[] pzPath;

	BWindow* pcBitmapWindow = new BWindow(  BRect( 0, 0, 1599, 1199 ), "",
											B_NO_BORDER_WINDOW_LOOK,
											B_NORMAL_WINDOW_FEEL,
											WND_BACKMOST,
											B_ALL_WORKSPACES );
	pcBitmapWindow->AddChild( new BitmapView( BRect( 0, 0, 1599, 1199 ), g_pcBackDrop ) );
	pcBitmapWindow->Show();

	pcApp->Run();

	return( 0 );
}
Ejemplo n.º 26
0
int restful_rhizome_newsince(httpd_request *r, const char *remainder)
{
  r->http.response.header.content_type = CONTENT_TYPE_JSON;
  if (!is_rhizome_http_enabled())
    return 403;
  uint64_t rowid;
  const char *end = NULL;
  if (!strn_to_list_token(remainder, &rowid, &end) || strcmp(end, "/bundlelist.json") != 0)
    return 404;
  if (r->http.verb != HTTP_VERB_GET)
    return 405;
  int ret = authorize(&r->http);
  if (ret)
    return ret;
  r->u.rhlist.phase = LIST_HEADER;
  r->u.rhlist.rowcount = 0;
  bzero(&r->u.rhlist.cursor, sizeof r->u.rhlist.cursor);
  r->u.rhlist.cursor.rowid_since = rowid;
  r->u.rhlist.end_time = gettime_ms() + config.rhizome.api.restful.newsince_timeout * 1000;
  http_request_response_generated(&r->http, 200, CONTENT_TYPE_JSON, restful_rhizome_bundlelist_json_content);
  return 1;
}
Ejemplo n.º 27
0
    bool S3::upload(std::string pathToImage)
    {
        std::vector<std::string> headers;
    
        // File name
        std::vector<std::string> tokens;
        helper::tokenize(pathToImage, tokens, "/");
        std::string fileName = helper::urlencode(tokens[tokens.size()-1]);

        // Host URL
        headers.push_back("Host: " + m_bucket + ".s3.amazonaws.com");

        // Date
        std::string date = getDate();
        headers.push_back("Date: " + date);

        // folder    
        std::string folder = (m_folder == "") ? "" : m_folder + "/";
        
        // Authorize request
        std::string request = "PUT\n";
        request += "\n";
        request += "\n";
        request += date + "\n";
        request += "/" + m_bucket + "/" + folder + fileName;
        headers.push_back("Authorization: " + authorize(request));

        // Url
        std::string url = "https://" + m_bucket + ".s3.amazonaws.com/" + folder + fileName;

        // Body
        std::vector<std::string> body;
        body.push_back(pathToImage);

        // Execute get operation
        return put(url, headers, body);
    }
Ejemplo n.º 28
0
/*
 * Authorize using WWW-Authorize header field
 */
int aaa_www_authorize(struct sip_msg* _msg, char* _realm, char* _uri_user)
{
	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)_uri_user,
		HDR_AUTHORIZATION_T);
}
Ejemplo n.º 29
0
/*
 * Authorize using Proxy-Authorize header field (URI user parameter given)
 */
int aaa_proxy_authorize_2(struct sip_msg* _msg, char* _realm,
														char* _uri_user)
{
	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)_uri_user,
		HDR_PROXYAUTH_T);
}
Ejemplo n.º 30
0
/*
 * Authorize using Proxy-Authorize header field (no URI user parameter given)
 */
int aaa_proxy_authorize_1(struct sip_msg* _msg, char* _realm, char* _s2)
{
	/* realm parameter is converted in fixup */
	return authorize(_msg, (pv_elem_t*)_realm, (pv_spec_t *)0,
		HDR_PROXYAUTH_T);
}