improve Metadata module to build hashref for Manager structure
This commit is contained in:
parent
cb71f77f4d
commit
5b576643ee
|
@ -111,13 +111,72 @@ sub toXML
|
||||||
sub toConf
|
sub toConf
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
my $fields;
|
||||||
local $Data::Dumper::Indent = 0;
|
local $Data::Dumper::Indent = 0;
|
||||||
|
local $Data::Dumper::Varname = "data";
|
||||||
my $data = Dumper($self);
|
my $data = Dumper($self);
|
||||||
$data =~ s/\A\$VAR\d+\s*=\s*//;
|
$data =~ s/^\s*(.*?)\s*$/$1/;
|
||||||
$data =~ s/'/'/g;
|
$data =~ s/'/'/g;
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## @method public hashref toStruct ()
|
||||||
|
# Return this object to be display into the Manager.
|
||||||
|
# @return hashref
|
||||||
|
sub toStruct
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $struct = ();
|
||||||
|
foreach (keys %$self)
|
||||||
|
{
|
||||||
|
$struct->{$_} = $self->{$_};
|
||||||
|
}
|
||||||
|
return $self->_toStruct('', $struct);
|
||||||
|
}
|
||||||
|
|
||||||
|
## @method private hashref _toStruct (Hashref node)
|
||||||
|
# Return a preformated structure to be stored into Manager structure.
|
||||||
|
# @param $path The path of the node.
|
||||||
|
# @param $node The current node into the hashref tree.
|
||||||
|
# @return Hashref A structure to be inserted into Manager structure.
|
||||||
|
sub _toStruct
|
||||||
|
{
|
||||||
|
my $self = shift;
|
||||||
|
my $path = shift;
|
||||||
|
my ($node) = @_;
|
||||||
|
if (ref $node)
|
||||||
|
{
|
||||||
|
my $struct = {
|
||||||
|
_nodes => [],
|
||||||
|
_help => 'default'
|
||||||
|
};
|
||||||
|
my @nodes = ();
|
||||||
|
foreach (keys %$node)
|
||||||
|
{
|
||||||
|
if ($_ =~ /^xmlns/)
|
||||||
|
{
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
my $key = $path . ' ' . $_;
|
||||||
|
$key =~ s/^ +//g;
|
||||||
|
my $data = $self->_toStruct($key, $node->{$_});
|
||||||
|
if ($data)
|
||||||
|
{
|
||||||
|
$struct->{$key} = $data;
|
||||||
|
push @nodes, 'n:' . $key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$struct->{$key} = 'text:/' . $_;
|
||||||
|
push @nodes, $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$struct->{_nodes} = \@nodes;
|
||||||
|
return $struct;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
## @method public static boolean load(Array files)
|
## @method public static boolean load(Array files)
|
||||||
# Return an array of Metadata object.
|
# Return an array of Metadata object.
|
||||||
# @param $files Array of filenames
|
# @param $files Array of filenames
|
||||||
|
|
|
@ -43,7 +43,7 @@ sub unserialize {
|
||||||
while ( my ( $k, $v ) = each(%$fields) ) {
|
while ( my ( $k, $v ) = each(%$fields) ) {
|
||||||
$v =~ s/^'(.*)'$/$1/s;
|
$v =~ s/^'(.*)'$/$1/s;
|
||||||
if ( $k =~
|
if ( $k =~
|
||||||
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions|notificationStorageOptions)$/
|
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions|notificationStorageOptions|samlServiceMetaData)$/
|
||||||
and $v ||= {}
|
and $v ||= {}
|
||||||
and not ref($v) )
|
and not ref($v) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
package Lemonldap::NG::Manager::_Struct;
|
package Lemonldap::NG::Manager::_Struct;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use Lemonldap::NG::Common::Conf::SAML::Metadata;
|
||||||
|
|
||||||
our $VERSION = '0.1';
|
our $VERSION = '0.1';
|
||||||
|
|
||||||
## @method protected hashref cstruct(hashref h,string k)
|
## @method protected hashref cstruct(hashref h,string k)
|
||||||
|
@ -42,7 +44,7 @@ sub cstruct {
|
||||||
sub struct {
|
sub struct {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return {
|
return {
|
||||||
_nodes => [qw(n:generalParameters n:variables n:virtualHosts)],
|
_nodes => [qw(n:generalParameters n:variables n:virtualHosts n:samlServiceMetadata)],
|
||||||
_help => 'default',
|
_help => 'default',
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
@ -237,6 +239,12 @@ sub struct {
|
||||||
_help => 'default',
|
_help => 'default',
|
||||||
_call => '$(\'#bnewvh\').show();',
|
_call => '$(\'#bnewvh\').show();',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
#################
|
||||||
|
# SAML METADATA #
|
||||||
|
#################
|
||||||
|
|
||||||
|
samlServiceMetadata => $self->conf->{samlServiceMetaData}->toStruct(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user