Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Access Check - Account manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN Access Check - Account manager
Commits
5a9192e4
Commit
5a9192e4
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
use exceptions, and let caller handle logging
parent
10a9399b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/account-manager-client.pl
+9
-4
9 additions, 4 deletions
bin/account-manager-client.pl
lib/IdPAccountManager/SAMLMetadata.pm
+24
-79
24 additions, 79 deletions
lib/IdPAccountManager/SAMLMetadata.pm
lib/IdPAccountManager/WebRequest.pm
+11
-10
11 additions, 10 deletions
lib/IdPAccountManager/WebRequest.pm
with
44 additions
and
93 deletions
bin/account-manager-client.pl
+
9
−
4
View file @
5a9192e4
...
...
@@ -7,6 +7,7 @@ use lib qw(lib);
use
feature
"
switch
";
no
warnings
'
experimental::smartmatch
';
use
English
qw(-no_match_vars)
;
use
Getopt::
Long
qw(:config auto_help)
;
use
Pod::
Usage
;
...
...
@@ -150,19 +151,23 @@ sub list_test_accounts {
sub
parse_federation_metadata
{
my
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
();
die
"
unable to load federation metadata
\n
"
unless
$federation_metadata
->
load
(
eval
{
$federation_metadata
->
load
(
federation_metadata_file_path
=>
$configuration
->
{
federation_metadata_file_path
}
);
};
die
"
unable to load federation metadata:
$EVAL_ERROR
"
if
$EVAL_ERROR
;
my
%args
;
if
(
$options
{
sp_entityid
})
{
$args
{
filter_entity_id
}
=
$options
{
sp_entityid
};
}
die
"
unable to parse federation metadata
\n
"
unless
$federation_metadata
->
parse
(
%args
);
eval
{
$federation_metadata
->
parse
(
%args
);
};
die
"
unable to parse federation metadata:
$EVAL_ERROR
\n
"
if
$EVAL_ERROR
;
printf
"
Document %s parsed
\n
",
$configuration
->
{
federation_metadata_file_path
};
...
...
This diff is collapsed.
Click to expand it.
lib/IdPAccountManager/SAMLMetadata.pm
+
24
−
79
View file @
5a9192e4
...
...
@@ -7,12 +7,11 @@ use English qw(-no_match_vars);
use
XML::
LibXML
;
use
IdPAccountManager::
Tools
;
use
IdPAccountManager::
Logger
;
sub
new
{
my
(
$pkg
,
%args
)
=
@_
;
my
$self
=
{
logger
=>
$args
{
logger
}
};
my
$self
=
{};
bless
$self
,
$pkg
;
...
...
@@ -23,47 +22,23 @@ sub new {
sub
load
{
my
(
$self
,
%args
)
=
@_
;
unless
(
$args
{
federation_metadata_file_path
})
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Missing parameter 'federation_metadata_file_path'
"
);
return
undef
;
}
die
"
Missing parameter 'federation_metadata_file_path'
"
unless
$args
{
federation_metadata_file_path
};
$self
->
{
federation_metadata_file_path
}
=
$args
{
federation_metadata_file_path
};
unless
(
-
r
$self
->
{
federation_metadata_file_path
})
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to read
$args
{federation_metadata_file_path} :
$ERRNO
"
);
return
undef
;
}
die
"
Failed to read
$args
{federation_metadata_file_path}:
$ERRNO
"
unless
-
r
$self
->
{
federation_metadata_file_path
};
unless
(
$self
->
{
federation_metadata_as_xml
}
=
$self
->
_get_xml_object
(
$args
{
federation_metadata_file_path
}))
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to parse file
$args
{metadata_file} :
$ERRNO
"
);
return
undef
;
}
die
"
Failed to parse file
$args
{metadata_file}:
$ERRNO
"
unless
$self
->
{
federation_metadata_as_xml
}
=
$self
->
_get_xml_object
(
$args
{
federation_metadata_file_path
});
my
$root
=
$self
->
{
federation_metadata_as_xml
}
->
documentElement
();
unless
(
$root
->
nodeName
()
=~
/EntitiesDescriptor$/
)
{
$self
->
{
logger
}
->
(
level
=>
LOG_ERROR
,
message
=>
sprintf
(
"
Root element of file
$args
{federation_metadata_file_path} is of type '%s'; should be 'EntitiesDescriptor'
",
$root
->
nodeName
()
)
);
return
undef
;
}
die
"
Root element of file
$args
{federation_metadata_file_path} is of type '%s'; should be 'EntitiesDescriptor'
",
$root
->
nodeName
()
unless
$root
->
nodeName
()
=~
/EntitiesDescriptor$/
;
return
1
;
}
...
...
@@ -83,13 +58,9 @@ sub parse {
$self
->
{
federation_metadata_as_hashref
}
=
$self
->
_parse_saml_metadata
(
%parser_args
);
unless
(
defined
$self
->
{
federation_metadata_as_hashref
})
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to parse federation metadata
"
);
return
undef
;
}
die
"
Failed to parse federation metadata
"
unless
defined
$self
->
{
federation_metadata_as_hashref
};
return
1
;
}
...
...
@@ -107,51 +78,25 @@ sub print {
sub
_get_xml_object
{
my
(
$self
,
$metadata_file
)
=
@_
;
unless
(
-
f
$metadata_file
)
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
File
$metadata_file
not found:
$ERRNO
"
);
return
undef
;
}
die
"
File
$metadata_file
not found:
$ERRNO
"
unless
-
f
$metadata_file
;
unless
(
open
FH
,
$metadata_file
)
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to open file
$metadata_file
:
$ERRNO
"
);
return
undef
;
}
die
"
Failed to open file
$metadata_file
:
$ERRNO
"
unless
open
FH
,
$metadata_file
;
my
$parser
;
unless
(
$parser
=
XML::
LibXML
->
new
())
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to initialize XML parser
"
);
return
undef
;
}
my
$parser
=
XML::
LibXML
->
new
();
die
"
Failed to initialize XML parser
"
unless
$parser
;
$parser
->
line_numbers
(
1
);
my
$doc
;
## Eval() prevents the parsing from killing the main process
eval
{
$doc
=
$parser
->
parse_fh
(
\
*FH
)
};
if
(
$EVAL_ERROR
)
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to parse file
$metadata_file
:
$EVAL_ERROR
"
);
return
undef
;
}
die
"
Failed to parse file
$metadata_file
:
$EVAL_ERROR
"
if
$EVAL_ERROR
;
unless
(
$doc
)
{
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to parse file
$metadata_file
:
$ERRNO
"
);
return
undef
;
}
die
"
Failed to parse file
$metadata_file
:
$EVAL_ERROR
"
unless
$doc
;
return
$doc
;
}
...
...
This diff is collapsed.
Click to expand it.
lib/IdPAccountManager/WebRequest.pm
+
11
−
10
View file @
5a9192e4
...
...
@@ -231,30 +231,31 @@ sub req_account_wizard {
my
(
$self
)
=
@_
;
$self
->
{
logger
}
->
log
(
level
=>
LOG_INFO
,
message
=>
"");
my
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
(
logger
=>
$self
->
{
logger
}
);
my
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
();
unless
(
eval
{
$federation_metadata
->
load
(
federation_metadata_file_path
=>
$self
->
{
configuration
}
->
{
federation_metadata_file_path
}
)
)
{
)
;
};
if
(
$EVAL_ERROR
)
{
push
@
{
$self
->
{
param_out
}
->
{
errors
}
},
"
internal
";
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to load federation metadata
:
$E
RRNO
"
message
=>
"
Failed to load federation metadata:
$E
VAL_ERROR
"
);
return
undef
;
}
unless
(
$federation_metadata
->
parse
())
{
eval
{
$federation_metadata
->
parse
());
};
if
(
$EVAL_ERROR
)
{
push
@
{
$self
->
{
param_out
}
->
{
errors
}
},
"
internal
";
$self
->
{
logger
}
->
log
(
level
=>
LOG_ERROR
,
message
=>
"
Failed to parse federation metadata
:
$E
RRNO
"
message
=>
"
Failed to parse federation metadata:
$E
VAL_ERROR
"
);
return
undef
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment