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
22715220
Commit
22715220
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
merge load() method with constructor
parent
5a9192e4
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
+3
-4
3 additions, 4 deletions
bin/account-manager-client.pl
lib/IdPAccountManager/SAMLMetadata.pm
+25
-50
25 additions, 50 deletions
lib/IdPAccountManager/SAMLMetadata.pm
lib/IdPAccountManager/WebRequest.pm
+14
-17
14 additions, 17 deletions
lib/IdPAccountManager/WebRequest.pm
with
42 additions
and
71 deletions
bin/account-manager-client.pl
+
3
−
4
View file @
22715220
...
...
@@ -149,12 +149,11 @@ sub list_test_accounts {
}
sub
parse_federation_metadata
{
my
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
()
;
my
$federation_metadata
;
eval
{
$federation_metadata
->
load
(
federation_metadata_file_path
=>
$configuration
->
{
federation_metadata_file_path
}
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
(
file
=>
$configuration
->
{
federation_metadata_file_path
}
);
};
die
"
unable to load federation metadata:
$EVAL_ERROR
"
if
$EVAL_ERROR
;
...
...
This diff is collapsed.
Click to expand it.
lib/IdPAccountManager/SAMLMetadata.pm
+
25
−
50
View file @
22715220
...
...
@@ -11,36 +11,38 @@ use IdPAccountManager::Tools;
sub
new
{
my
(
$pkg
,
%args
)
=
@_
;
my
$self
=
{};
die
"
missing argument 'file'
"
unless
defined
$args
{
file
};
die
"
non-existing file
$args
{file}
"
unless
-
f
$args
{
file
};
die
"
non-readable file
$args
{file}
"
unless
-
r
$args
{
file
};
bless
$self
,
$pkg
;
return
$self
;
}
open
(
my
$handle
,
'
<
',
$args
{
file
})
or
die
"
failed to open file
$args
{file}:
$ERRNO
";
## Load metadata
sub
load
{
my
(
$self
,
%args
)
=
@_
;
my
$parser
=
XML::
LibXML
->
new
();
die
"
Failed to initialize XML parser
"
unless
$parser
;
die
"
Missing parameter 'federation_metadata_file_path'
"
unless
$args
{
federation_metadata_file_path
};
my
$doc
;
eval
{
$doc
=
$parser
->
parse_fh
(
$handle
)
};
die
"
Failed to parse file
$args
{file}:
$EVAL_ERROR
"
if
$EVAL_ERROR
;
$self
->
{
federation_metadata_file_path
}
=
$args
{
federation_metadata_file_path
}
;
die
"
Failed to parse file
$args
{file}:
$EVAL_ERROR
"
unless
$doc
;
die
"
Failed to read
$args
{federation_metadata_file_path}:
$ERRNO
"
unless
-
r
$self
->
{
federation_metadata_file_path
}
;
my
$root
=
$doc
->
documentElement
();
my
$type
=
$root
->
nodeName
()
;
die
"
Failed to parse file
$args
{metadata_file}:
$ERRNO
"
unless
$self
->
{
federation_metadata_as_xml
}
=
$self
->
_get_xml_object
(
$args
{
federation_metadata_file_path
});
die
"
incorrect root element type '
$type
' for file
$args
{file}, should be
'EntitiesDescriptor'
"
unless
$type
=~
/EntitiesDescriptor$/
;
my
$root
=
$self
->
{
federation_metadata_as_xml
}
->
documentElement
();
my
$self
=
{
file
=>
$args
{
file
},
doc
=>
$doc
};
die
"
Root element of file
$args
{federation_metadata_file_path} is of type '%s'; should be 'EntitiesDescriptor'
",
$root
->
nodeName
()
unless
$root
->
nodeName
()
=~
/EntitiesDescriptor$/
;
bless
$self
,
$pkg
;
return
1
;
return
$self
;
}
## Parse XML structure of metadata to fill a hashref
...
...
@@ -48,7 +50,7 @@ sub parse {
my
(
$self
,
%args
)
=
@_
;
my
%parser_args
=
(
metadata_as_xml
=>
$self
->
{
federation_metadata_as_xml
},
metadata_as_xml
=>
$self
->
{
doc
},
filter_entity_type
=>
'
sp
'
);
...
...
@@ -70,37 +72,10 @@ sub print {
my
(
$self
,
$fd
)
=
@_
;
$fd
=
\
*STDOUT
unless
$fd
;
my
$root
=
$self
->
{
federation_metadata_as_xml
}
->
documentElement
();
my
$root
=
$self
->
{
doc
}
->
documentElement
();
print
$fd
$root
->
toString
();
}
## returns a Lib::XML représenting an XML file
sub
_get_xml_object
{
my
(
$self
,
$metadata_file
)
=
@_
;
die
"
File
$metadata_file
not found:
$ERRNO
"
unless
-
f
$metadata_file
;
die
"
Failed to open file
$metadata_file
:
$ERRNO
"
unless
open
FH
,
$metadata_file
;
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
)
};
die
"
Failed to parse file
$metadata_file
:
$EVAL_ERROR
"
if
$EVAL_ERROR
;
die
"
Failed to parse file
$metadata_file
:
$EVAL_ERROR
"
unless
$doc
;
return
$doc
;
}
## Parse a SAML federation metadata file
sub
_parse_saml_metadata
{
my
(
$self
,
%args
)
=
@_
;
...
...
This diff is collapsed.
Click to expand it.
lib/IdPAccountManager/WebRequest.pm
+
14
−
17
View file @
22715220
...
...
@@ -249,7 +249,7 @@ sub req_account_wizard {
}
eval
{
$federation_metadata
->
parse
()
)
;
$federation_metadata
->
parse
();
};
if
(
$EVAL_ERROR
)
{
push
@
{
$self
->
{
param_out
}
->
{
errors
}
},
"
internal
";
...
...
@@ -279,35 +279,32 @@ sub req_select_sp {
return
undef
;
}
my
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
(
logger
=>
$self
->
{
logger
}
);
my
$federation_metadata
;
unless
(
$federation_metadata
->
load
(
federation_metadata_file_path
=>
$self
->
{
configuration
}
->
{
federation_metadata_file_path
}
)
)
{
eval
{
$federation_metadata
=
IdPAccountManager::
SAMLMetadata
->
new
(
file
=>
$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
(
eval
{
$federation_metadata
->
parse
(
filter_entity_id
=>
$self
->
{
param_in
}
->
{
sp_entityid
}
)
)
{
)
;
};
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