Solstice

 view release on metacpan or  search on metacpan

examples/webservice_example.php  view on Meta::CPAN

<?php

$private_key = '12345';
$public_id = 'mcrawfor';

$content = '';

$host = "http://inkey.eplt.washington.edu";
$url = "/tools/rest/webq/v1/";
$method = "PUT";


//Build auth key
$date = time();
if($content)
    $content_sha1 = sha1($content);
$to_sign = "$private_key\n$method\n$url\n$date\n$content_sha1";
$auth_key = "SolAuth $public_id:".sha1($to_sign);

//Build Headers
$headers = array();
array_push($headers, "Date: $date");
if($content)
    array_push($headers, "Content-SHA1: $content_sha1");
array_push($headers, "Authorization: $auth_key");

//HTTP work

examples/webservice_example.pl  view on Meta::CPAN



use strict;
use warnings;
use Digest::SHA1 qw(sha1_hex);
use LWP::UserAgent;


my $private_key = '12345';
my $public_id = 'mcrawfor';

my $content = '';

my $host = "http://solstice.washington.edu";
my $url = "/tools/rest/webq/v1/?foo=blah";
my $method = "GET";

#build auth key
my $date = localtime;
my $content_sha1 = $content ? sha1_hex($content) : '';
my $to_sign = "$private_key\n$method\n$url\n$date\n$content_sha1";
my $auth_key = "SolAuth $public_id:". sha1_hex($to_sign);


my $ua = LWP::UserAgent->new;
$ua->agent("Solstice Webservices Client/0.1 ");

my $req = HTTP::Request->new($method => $host.$url);
$req->content($content) if $content;
$req->header('Content-SHA1', $content_sha1) if $content;
$req->header('Date', $date);

lib/Solstice/Controller/Application/REST.pm  view on Meta::CPAN

package Solstice::Controller::Application::REST;

=head1 NAME

Solstice::Controller::Application::REST - The Application controller for the REST 'cgi'. 

=head1 SYNOPSIS

  my $rest = Solstice::Controller::Application::REST->new();
  my $is_valid = $rest->isValidServiceRequest($service_name);
  my $has_access = $rest->hasServiceAccess($service_name, $consumer_private_key);

  my $requires_user_auth = $rest->requiresUserAuth($service_name);
  my $has_user_auth = $rest->hasUserAuth($service_name, $consumer_private_key, $person_id);
  my $response = $rest->getResponseData();

=head1 DESCRIPTION

This process all requests to Solstice REST web services.

=cut

use strict;
use warnings;

lib/Solstice/Controller/Application/REST.pm  view on Meta::CPAN

    $$screen = "<error>\n".
    "    <error_status>".$server->getStatus()."</error_status>\n".
    "    <error_string>$error_string</error_string>\n".
    "</error>\n";

}

sub checkSignature {
    my $self = shift;
    my $signature = shift;
    my $private_key = shift;

    my $server = Solstice::Server->new();

    my $method      = $ENV{'REQUEST_METHOD'}             || '';
    my $url         = $ENV{'REQUEST_URI'}                || '';
    my $date        = $server->getHeaderIn('Date')             || '';
    my $content_sha1= $server->getHeaderIn('Content-SHA1')     || '';

    my $body = $server->getRequestBody();

    if($body){
        return FALSE unless sha1_hex($body) eq $content_sha1;
    }

    my $message = "$private_key\n$method\n$url\n$date\n$content_sha1";

    return sha1_hex($message) eq $signature;
}

sub setErrorString {
    my $self = shift;
    $self->{'_error_string'} = shift;
}

sub getErrorString {

lib/Solstice/Encryption.pm  view on Meta::CPAN

use 5.006_000;
use strict;
use warnings;

use Crypt::Rijndael;
use MIME::Base64;
use URI::Escape;
use Solstice::Configure;
use Unicode::String;

our $private_key;
use constant DIVISOR => 16;
our ($VERSION) = ('$Revision: 3364 $' =~ /^\$Revision:\s*([\d.]*)/);

=head2 Export

No symbols exported.

=head2 Methods

=over 4

lib/Solstice/Encryption.pm  view on Meta::CPAN

=item new()

Constructor.  Returns an encrypter object.

=cut

sub new {
    my $pkg = shift;
    my $self = bless {}, $pkg;

    if (!defined $private_key) {
        my $config = Solstice::Configure->new();
        $private_key = $config->getEncryptionKey();
    }

    $self->_setCipher(Crypt::Rijndael->new($private_key));

    return $self;
}

=item encrypt(plain_text_string)

Returns the encrypted version of the plain_text_string in URL safe text.

=cut

lib/Solstice/Model/WebserviceConsumer.pm  view on Meta::CPAN

}

sub _initByHash {
    my $self = shift;
    my $input = shift;

    return FALSE unless $self->_isValidHashRef($input);

    $self->_setID($input->{'webservice_consumer_id'});
    $self->_setPerson(Solstice::Factory::Person->new()->createByID($input->{'person_id'}));
    $self->_setPrivateKey($input->{'private_key'});
    $self->_setCertCName($input->{'cert_cname'});
    $self->_setNotes($input->{'notes'});

    my $db = Solstice::Database->new();
    my $db_name = $self->getConfigService()->getDBName();

    $db->readQuery("SELECT * FROM $db_name.WebserviceConsumerApplicationAccess WHERE webservice_consumer_id = ?", 
        $self->getID()
    );

lib/Solstice/Model/WebserviceConsumer.pm  view on Meta::CPAN

        key  => '_person',
        type => 'Solstice::Person',
    },
    {
        name => 'PublicID',
        key  => '_public_id',
        type => 'String',
    },
    {
        name => 'PrivateKey',
        key  => '_private_key',
        type => 'String',
    },
    {
        name => 'CertCName',
        key  => '_cname',
        type => 'String',
    },
    {
        name => 'Notes',
        key  => '_notes',



( run in 0.615 second using v1.01-cache-2.11-cpan-a5abf4f5562 )