diff --git a/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi b/info.textgrid.middleware.tgauth.webauth/secure/portal.cgi index fa470249184a81722e38f6691bc5df7a76e1c7fa..21bf65aca6ca709ea1ebc67acf2ab7380ff3edd9 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) = @_;