From 1b48b263a94e43d5c0f2705e79028640b631066d Mon Sep 17 00:00:00 2001 From: xflord <493294@mail.muni.cz> Date: Tue, 29 Nov 2022 12:41:01 +0100 Subject: [PATCH] feat(scs_it4i): extend the service to include more attributes --- gen/scs_it4i | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/gen/scs_it4i b/gen/scs_it4i index ccc1b130..587435e2 100755 --- a/gen/scs_it4i +++ b/gen/scs_it4i @@ -7,16 +7,30 @@ use File::Basename; our $SERVICE_NAME = basename($0); our $PROTOCOL_VERSION = "3.0.0"; -my $SCRIPT_VERSION = "3.0.0"; +my $SCRIPT_VERSION = "3.0.1"; perunServicesInit::init; my $DIRECTORY = perunServicesInit::getDirectory; my $data = perunServicesInit::getHashedHierarchicalData; #Constants -our $A_USER_LOGIN_EINFRA; *A_USER_LOGIN_EINFRA = \'urn:perun:user:attribute-def:def:login-namespace:einfra'; -our $A_ORGANIZATION; *A_ORGANIZATION = \'urn:perun:user:attribute-def:def:organization'; -our $A_BLOCK_COLLISION; *A_BLOCK_COLLISION = \'urn:perun:user:attribute-def:def:it4iBlockCollision'; + +our $A_USER_LOGIN_EINFRA_PERSIST; *A_USER_LOGIN_EINFRA_PERSIST = \'urn:perun:user:attribute-def:virt:login-namespace:einfraid-persistent'; +our $A_ORGANIZATION; *A_ORGANIZATION = \'urn:perun:user:attribute-def:def:organization'; +our $A_BLOCK_COLLISION; *A_BLOCK_COLLISION = \'urn:perun:user:attribute-def:def:it4iBlockCollision'; +our $A_COMMON_NAME; *A_COMMON_NAME = \'urn:perun:user:attribute-def:core:commonName'; +our $A_DISPLAY_NAME; *A_DISPLAY_NAME = \'urn:perun:user:attribute-def:core:displayName'; +our $A_FIRST_NAME; *A_FIRST_NAME = \'urn:perun:user:attribute-def:core:firstName'; +our $A_LAST_NAME; *A_LAST_NAME = \'urn:perun:user:attribute-def:core:lastName'; +our $A_MIDDLE_NAME; *A_MIDDLE_NAME = \'urn:perun:user:attribute-def:core:middleName'; +our $A_TITLE_AFTER; *A_TITLE_AFTER = \'urn:perun:user:attribute-def:core:titleAfter'; +our $A_TITLE_BEFORE; *A_TITLE_BEFORE = \'urn:perun:user:attribute-def:core:titleBefore'; +our $A_UUID; *A_UUID = \'urn:perun:user:attribute-def:core:uuid'; +our $A_COUNTRY; *A_COUNTRY = \'urn:perun:user:attribute-def:def:country'; +our $A_PREF_LANGUAGE; *A_PREF_LANGUAGE = \'urn:perun:user:attribute-def:def:preferredLanguage'; +our $A_PREF_MAIL; *A_PREF_MAIL = \'urn:perun:user:attribute-def:def:preferredMail'; +our $A_INSTIT_COUNTRIES; *A_INSTIT_COUNTRIES = \'urn:perun:user:attribute-def:virt:institutionsCountries'; + my $service_file_name = "$DIRECTORY/$::SERVICE_NAME"; @@ -25,17 +39,27 @@ my $users; foreach my $memberId ($data->getMemberIdsForFacility()) { my $collision = $data->getUserAttributeValue( member => $memberId, attrName => $A_BLOCK_COLLISION ); - my $login = $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_LOGIN_EINFRA ); - my $org = $data->getUserAttributeValue( member => $memberId, attrName => $A_ORGANIZATION ) || ""; + my $login = $data->getUserAttributeValue( member => $memberId, attrName => $A_USER_LOGIN_EINFRA_PERSIST ) || ""; # Check if user is not prohibited in IT4I !! if (defined $collision) { die "Login '$login' has collision with old IT4I data. Propagations was stopped for safety." } - + $users->{$login}->{"uuid"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_UUID) || ""; $users->{$login}->{"login"} = $login; - $users->{$login}->{"organization"} = $org; - $users->{$login}->{"citizenship"} = ""; # TODO + $users->{$login}->{"commonName"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_COMMON_NAME ) || ""; + $users->{$login}->{"displayName"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_DISPLAY_NAME ) || ""; + $users->{$login}->{"firstName"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_FIRST_NAME ) || ""; + $users->{$login}->{"lastName"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_LAST_NAME ) || ""; + $users->{$login}->{"middleName"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_MIDDLE_NAME) || ""; + $users->{$login}->{"titleAfter"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_TITLE_AFTER ) || ""; + $users->{$login}->{"titleBefore"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_TITLE_BEFORE ) || ""; + $users->{$login}->{"citizenship"} = ""; + $users->{$login}->{"country"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_COUNTRY ) || ""; + $users->{$login}->{"organization"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_ORGANIZATION ) || ""; + $users->{$login}->{"preferredLanguage"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_PREF_LANGUAGE ) || ""; + $users->{$login}->{"preferredMail"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_PREF_MAIL ) || ""; + $users->{$login}->{"institutionsCountries"} = $data->getUserAttributeValue( member => $memberId, attrName => $A_INSTIT_COUNTRIES ) || []; } @@ -46,7 +70,7 @@ foreach my $login (sort keys %{$users}) { } ####### output file ###################### -open SERVICE_FILE, ">:encoding(UTF-8)", "$service_file_name" or die "Cannot open $service_file_name: $! \n"; +open SERVICE_FILE, ">$service_file_name" or die "Cannot open $service_file_name: $! \n"; print SERVICE_FILE JSON::XS->new->utf8->pretty->canonical->encode(\@result); close(SERVICE_FILE); #####################################################