Annotation of loncom/CrGrant.pl, revision 1.1
1.1 ! foxr 1: #!/usr/bin/perl
! 2: # The LearningOnline Network
! 3: # CrGrant.pl - Grant a loncapa SSL certificate.
! 4: #
! 5: # $Id$
! 6: #
! 7: # Copyright Michigan State University Board of Trustees
! 8: #
! 9: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
! 10: #
! 11: # LON-CAPA is free software; you can redistribute it and/or modify
! 12: # it under the terms of the GNU General Public License as published by
! 13: # the Free Software Foundation; either version 2 of the License, or
! 14: # (at your option) any later version.
! 15: #
! 16: # LON-CAPA is distributed in the hope that it will be useful,
! 17: # but WITHOUT ANY WARRANTY; without even the implied warranty of
! 18: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 19: # GNU General Public License for more details.
! 20: #
! 21: # You should have received a copy of the GNU General Public License
! 22: # along with LON-CAPA; if not, write to the Free Software
! 23: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
! 24: #
! 25: # /home/httpd/html/adm/gpl.txt
! 26: #
! 27:
! 28:
! 29: # http://www.lon-capa.org/
! 30: #
! 31: # This script operates on a certificate request that has been
! 32: # extracted from the attachment sent to the loncapa certificate
! 33: # administrator and:
! 34: #
! 35: # 1. Creates an ssl certificate corresponding to the request.
! 36: # 2. Constructs an installation script that will install
! 37: # the certificate along with the certificate authority's
! 38: # certificate in a loncapa system.
! 39: # 3. Constructs an email which contains a cover letter
! 40: # describing what to do with the attachment, and an
! 41: # attachment that consists of the installation script
! 42: # created in step 2.
! 43: # 4. Emails the message to the email address in the certificate
! 44: # request.
! 45: #
! 46: # There are some assumptions we need to make in order to
! 47: # get this all to work:
! 48: # - The certificate authority is installed on a
! 49: # loncapa system with configuration files that specify
! 50: # the same certificate directory and certificate filenames
! 51: # as the target system (otherwise we can't generate the
! 52: # installation script).
! 53: # - The loncapa certificate authority configuration file is
! 54: # $SSLDir/loncapaca.cnf and that it specifies that:
! 55: # o The certificate authority files are in $SSLDir/loncapaca
! 56: # o The certificate authority certificate is in:
! 57: # $SSLDir/loncapaca/cacert.pem
! 58: # o The certificate authority maintains a certificate index file
! 59: # $SSLDIR/loncapaca/index.txt
! 60: # o Only one instance of this script will be run at a time!!!!!
! 61: # (otherwise the last line of the index file may not be the
! 62: # index to our certificate. We'll do some rudimentary
! 63: # error checking, but have no idea how to recover in case
! 64: # of problems).
! 65: # o The generated certificates are stored in $SSLDIR/loncapaca/certs
! 66: # o The person that runs this script knows the passphrase
! 67: # for the loncapa certificate authority's private key
! 68: # which remains encrypted for security reasons.
! 69: #
! 70: #
! 71:
! 72: # Import section:
! 73:
! 74: use strict;
! 75: use lib '/home/httpd/lib/perl';
! 76: use MIME::Entity;
! 77: use LONCAPA::Configuration;
! 78:
! 79:
! 80:
! 81: # Global variable declarations
! 82:
! 83:
! 84:
! 85: # Debug/log support
! 86:
! 87: my $DEBUG=1;
! 88:
! 89: sub Debug {
! 90: my $msg = shift;
! 91: if($DEBUG) {
! 92: print STDERR "$msg\n";
! 93: }
! 94: }
! 95: # Support subs:
! 96:
! 97: sub Usage {}
! 98:
! 99: sub CreateCertificate {
! 100: my $RequestFile = shift;
! 101:
! 102: return 'fox@nscl.msu.edu'; # Stub..
! 103: }
! 104: sub CreateInstallScript {}
! 105:
! 106: sub CreateEmail {
! 107: return "Dummy message"; # Stub.
! 108: }
! 109:
! 110: sub SendEmail {
! 111: my ($EmailAddress, $Message) = @_;
! 112: }
! 113: sub Cleanup {}
! 114:
! 115:
! 116: # Program entry point
! 117: # The usage is:
! 118: # CrGrant.pl {request_file}
! 119: #
! 120:
! 121: my $argc = @ARGV; # Count number of command parameters.
! 122: if($argc != 1) {
! 123: Usage;
! 124: exit -1;
! 125: }
! 126: my $CertificateRequest = $ARGV[0];
! 127:
! 128: my $EmailAddress = CreateCertificate($CertificateRequest);
! 129: CreateInstallScript;
! 130: my $Message = CreateEmail;
! 131: SendEmail($EmailAddress, $Message);
! 132: Cleanup;
! 133:
! 134: # POD documentation.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>