From 2bf2f1dab1f404bfcc07c34f31d523b2fb0ea6b6 Mon Sep 17 00:00:00 2001 From: Martin Haase <martin.haase@daasi.de> Date: Tue, 3 Aug 2010 08:28:00 +0000 Subject: [PATCH] VOMRS AutoRegistration fpr SLCS, PoC git-svn-id: https://textgridlab.org/svn/textgrid/trunk/middleware/tgauth@6864 7c539038-3410-0410-b1ec-0f2a7bf1c452 --- .../secure/portal.cgi | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi b/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi index fa47024..21bf65a 100644 --- a/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi +++ b/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi @@ -135,6 +135,12 @@ The corresponding private key is now held by TG-auth*. This service will be inte <input type="submit" value="Return to the TextGridLab"/> </form><br/> EOF + +registerUserAtVOMRS ( + "/usr/local/bin/VOMRSclient/bin/runAutoregClient.sh", + $certificate, +); + print $cgi->end_html(); } @@ -152,6 +158,49 @@ sub handleRejected # Utility functions # +sub registerUserAtVOMRS { + my ($registerScript, $pem) = @_; + + use Crypt::OpenSSL::X509; + + my $crt = Crypt::OpenSSL::X509->new_from_string ( $pem ); + + my $dn_commas = $crt->subject(); + my $ca_commas = $crt->issuer(); + my $mail = $crt->email(); + my $serial = $crt->serial(); + + my ($firstname, $lastname ) = getSLCname ($dn_commas); + + my $dn = commas2slashes ($dn_commas); + my $ca = commas2slashes ($ca_commas); + + my $phone = "0123456789"; # well, we really don't have it anywhere + + system "$registerScript '$dn' '$ca' '$serial' '$mail' '$firstname' '$lastname' '$phone' >/dev/null"; +} + + +# assumes "C=DE, ..., CN=Tanja Test - tanja.test@textgrid-test-idp.de" +# returns ("Tanja", "Test") +sub getSLCname { + my $dn = shift; + $dn =~ /CN=(\S+\s+)+(\S+)\s+-\s+/; + $givennames = $1; + $surname = $2; + $givennames =~ s/\s+$//; + return ( $givennames, $surname ); +} + +# translates C=DE, O=DFN-Verein, OU=DFN-PKI, CN=DFN-Verein Test-AAI SLCS CA +# to /C=DE/O=DFN-Verein/OU=DFN-PKI/CN=DFN-Verein Test-AAI SLCS CA +sub commas2slashes { + $_ = shift; + s/,\s+/\//g; + return '/' . $_; +} + + sub getConfig { my ($configfilename, $authZinstance) = @_; -- GitLab