--- /dev/null
+
+package NCIPServer::NCIP;
+use strict;
+use warnings;
+
+use NCIPServer::NCIP::Configuration;
+
+use FileHandle;
+
+sub new {
+ my $self = shift;
+ my $config_file = shift;
+
+ my $config = NCIPServer::NCIP::Configuration->new($config_file);
+
+ return bless $config, $self;
+
+}
+
+sub process_request {
+ my $self = shift;
+ my $xml = shift;
+
+ my $response = "<HTML> <HEAD> <TITLE>Hello There</TITLE> </HEAD> <BODY> <H1>Hello You Big JERK!</H1> Who would take this book seriously if the first eaxample didn't say \"hello world\"? </BODY> </HTML>";
+
+ return $response;
+}
+
+1;
--- /dev/null
+#
+# Copyright (C) 2013 MnSCU/PALS
+#
+# Author: Alan Rykhus
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+# parse-config: Parse an XML-format
+# ACS configuration file and build the configuration
+# structure.
+#
+
+package NCIPServer::NCIP::Configuration;
+
+our $VERSION = 0.02;
+
+use strict;
+use warnings;
+use XML::Simple qw(:strict);
+
+use NCIPServer::NCIP::Configuration::Account;
+use NCIPServer::NCIP::Configuration::Institution;
+
+my $parser = new XML::Simple(
+ KeyAttr => {
+ login => '+id',
+ institution => '+id',
+ },
+ GroupTags => {
+ accounts => 'login',
+ institutions => 'institution',
+ },
+ ForceArray => [ 'login', 'institution' ],
+);
+
+sub new {
+ my ($class, $config_file) = @_;
+ my $cfg = $parser->XMLin($config_file);
+
+ foreach my $acct (values %{$cfg->{accounts}}) {
+ new NCIPServer::NCIP::Configuration::Account $acct;
+ }
+
+ foreach my $inst (values %{$cfg->{institutions}}) {
+ new NCIPServer::NCIP::Configuration::Institution $inst;
+ }
+
+ return bless $cfg, $class;
+}
+
+sub accounts {
+ my $self = shift;
+ return values %{$self->{accounts}};
+}
+
+sub institutions {
+ my $self = shift;
+ return values %{$self->{institutions}};
+}
+
+1;
+__END__
+
+=head1 NAME
+
+NCIPServer::NCIP::Configuration - abstraction/accessor for NCIP configs
+
+=head1 SYNOPSIS
+
+use NCIPServer::NCIP::Configuration;
+my $config = NCIPServer::NCIP::Configuration->new($ARGV[0]);
+
+foreach my $acct ($config->accounts) {
+ print "Found account: '", $acct->id, "', part of '";
+ print $acct->institution, "'\n";
+}
+
+=cut
+
--- /dev/null
+#
+# Copyright (C) 2013 MnSCU/PALS
+#
+# Author: Alan Rykhus
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+package NCIPServer::NCIP::Configuration::Account;
+
+use strict;
+use warnings;
+
+sub new {
+ my ($class, $obj) = @_;
+ my $type = ref($class) || $class;
+
+ if (ref($obj) eq "HASH") {
+ return bless $obj, $type; # Just bless the object
+ }
+
+ return bless {}, $type;
+}
+
+sub id {
+ my $self = shift;
+ return $self->{id};
+}
+
+sub institution {
+ my $self = shift;
+ return $self->{institution};
+}
+
+sub password {
+ my $self = shift;
+ return $self->{password};
+}
+
+1;
--- /dev/null
+#
+# Copyright (C) 2013 MnSCU/PALS
+#
+# Author: Alan Rykhus
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+package NCIPServer::NCIP::Configuration::Institution;
+
+use strict;
+use warnings;
+
+sub new {
+ my ($class, $obj) = @_;
+ my $type = ref($class) || $class;
+
+ if (ref($obj) eq "HASH") {
+ return bless $obj, $type; # Just bless the object
+ }
+
+ return bless {}, $type;
+}
+
+sub id {
+ my $self = shift;
+ return $self->{id};
+}
+
+sub implementation {
+ my $self = shift;
+ return $self->{implementation};
+}
+
+1;
--- /dev/null
+
+package NCIPServer::NCIPResponder;
+use strict;
+use warnings;
+
+use FileHandle;
+
+use Apache2::Const -compile => qw(OK :log :http :methods :cmd_how :override);
+use Apache2::RequestRec ();
+use Apache2::RequestIO ();
+use NCIPServer::NCIP;
+
+sub handler {
+ my $r = shift;
+
+ return Apache2::Const::HTTP_METHOD_NOT_ALLOWED unless $r->method_number eq Apache2::Const::M_POST;
+
+ my $NCIPConfigFile = $r->dir_config('NCIPConfigFile');
+
+ if (!defined($NCIPConfigFile)) {
+ die sprintf "error: There is no NCIPConfigFile defined\n";
+ } else {
+ if (! (-r $NCIPConfigFile)) {
+ die sprintf "error: NCIPConfigFile %s does not exist or is not readable\n", $NCIPConfigFile;
+ }
+ }
+
+ my $ncip = NCIPServer::NCIP->new($NCIPConfigFile);
+
+ $r->content_type('text/html');
+ my $tmp_buf;
+ my $input_xml;
+
+ while ($r->read($tmp_buf, 1024))
+ {
+ $input_xml .= $tmp_buf;
+ }
+
+ my $response_xml = $ncip->process_request($input_xml);
+
+ $r->print($response_xml);
+ return Apache2::Const::OK;
+}
+
+1;