store IDP values into samlIDPMetaDataXML and samlIDPMetaDataExportedAttributes, as what has been done with virtualhosts

This commit is contained in:
Thomas CHEMINEAU 2010-02-19 17:31:25 +00:00
parent 9766b8457a
commit c2dc15ab6e
6 changed files with 33 additions and 37 deletions

View File

@ -48,31 +48,18 @@ sub setDebug {
# @param string key The key into the manager struct
sub buildIDPStruct {
my ( $h, $k ) = @_;
return $h
unless (ref($h));
my @keys = split(/\//, $k);
return $h
unless (scalar @keys ge 2);
%{$h->{samlIDPMetaData}} = (
%{$h->{samlIDPMetaData}},
$keys[1] => {
_nodes => [
qw(samlIDPMetaDataXML
samlIDPMetaDataExportedAttributes)
],
samlIDPMetaDataXML =>
'samlmetadata:/samlIDPMetaData/' . $keys[1]
. '/samlIDPMetaDataXML:samlIDPMetaDataXML:textarea',
samlIDPMetaDataExportedAttributes =>
'text:/samlIDPMetaData/' . $keys[1]
. '/samlIDPMetaDataExportedAttributes'
. ':samlIDPMetaDataExportedAttributes:text',
%$h = (
%$h,
samlIDPMetaData => {
$k => {
_nodes => [qw(samlIDPMetaDataXML samlIDPMetaDataExportedAttributes)],
samlIDPMetaDataXML => "samlmetadata:/samlIDPMetaDataXML/$k:samlIDPMetaDataXML:textarea",
samlIDPMetaDataExportedAttributes => {
_nodes => ["hash:/samlIDPMetaDataExportedAttributes/$k:samlIDPMetaDataExportedAttributes:btext"],
_js => 'hashRoot'
},
}
);
@{$h->{samlIDPMetaData}->{_nodes}} = (
@{$h->{samlIDPMetaData}->{_nodes}},
'n:' . $keys[1]
);
});
return $h;
}

View File

@ -54,7 +54,7 @@ sub unserialize {
# Manage hashes
if ( $k =~
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions|notificationStorageOptions|samlIDPMetaData|samlSPMetaData)$/
/^(?:exportedVars|locationRules|groups|exportedHeaders|macros|globalStorageOptions|notificationStorageOptions|samlIDPMetaDataXML|samlIDPMetaDataExportedAttributes|samlSPMetaData)$/
and $v ||= {}
and not ref($v) )
{

View File

@ -268,11 +268,11 @@ function samlAssertion(id) {
}
function samlIDP(id){
currentId=id;
if($('#li_'+myB64('/samlIDPMetaData')).find('span').size()==1){
/*if($('#li_'+myB64('/samlIDPMetaData')).find('span').size()==1){
$('#delsamlidpb').hide();
}else{
$('#delsamlidpb').show();
}
}*/
$('#samlIDPMetaData').attr('value',lmtext(id));
display('samlIDPMetaData',lmtext(id));
}
@ -323,6 +323,11 @@ function rulesRoot(id){
display('default','');
$('#newrbr').show();
}
function samlIDPRoot(id){
currentId=id;
display('default', '');
$('#newsamlidpb').show();
}
function reloadAuthParams() {
setlmdata(currentId,$('#authText').attr('value'));
$.ajax({
@ -403,8 +408,8 @@ function delSamlIDP(id){
function newSamlIDP(){
var value = prompt(text4newSamlIDP,'authentic');
if(!value){return false;}
var idpId='li_'+myB64('/samlIDPMetaData/'+value);
simpleTreeCollection[0].newAjaxNodeIn($('#li_c2FtbC9zYW1sSURQTWV0YURhdGE1'),idpId,value,scriptname+'?type=new&node=samlIDPMetaData/'+value,function(d,s){
var idpId='li_'+myB64('/samlIDPMetaDataExportedAttributes/'+value);
simpleTreeCollection[0].newAjaxNodeIn($('#li_c2FtbElEUE1ldGFEYXRh'),idpId,value,scriptname+'?type=new&node=samlIDPMetaData/'+value,function(d,s){
$('>span',s).attr('name',value).attr('help','default').attr('id','text_'+idpId).attr('onclick','samlIDP(\''+idpId+'\')');
samlIDP(idpId);
});

View File

@ -191,7 +191,7 @@ sub confNode {
my $metadata = Lemonldap::NG::Common::Conf::SAML::Metadata->new();
$metadata->initializeFromConfHash($h);
my $text = $target;
$text =~ s/^.*\///;
$text =~ s/^\/([^\/]+)\/.*$/$1/;
my $id = "$target";
my $data = $metadata->toXML();
$res .= $self->li($id)
@ -200,7 +200,8 @@ sub confNode {
text => $text,
data => $data,
js => $js,
help => $help
help => $help,
target => "samlmetadata",
) . "</li>";
}
@ -302,10 +303,10 @@ sub corresp {
return $h unless ($key);
if ( my $k2 = $self->param('key') ) {
# SAML identity providers
if ($key =~ /^samlIDPMetaData/i) {
$h = Lemonldap::NG::Common::Conf::SAML::Metadata::buildIDPStruct($h, $key);
if ($key =~ /^samlIDPMetaData(?!XML|ExportedAttributes)(\/[^\/]+\/)?/i) {
$h = Lemonldap::NG::Common::Conf::SAML::Metadata::buildIDPStruct( $h, $k2 );
# Virtual hosts
} else {
} elsif ($key =~ /^virtualHosts/i) {
$h = $self->cstruct( $h, $k2 );
}
}
@ -441,7 +442,8 @@ sub span {
# Data
$args{data} = '' unless ( defined $args{data} );
$args{data} =~ s/"/&#39;/g;
$args{data} =~ s/"/&#39;/g
unless ( defined $args{target} and $args{target} =~ /samlmetadata/ );
$args{data} = uri_escape( $args{data} );
# ID

View File

@ -67,7 +67,8 @@ sub confUpload {
$id =~ s/\r//g;
$id =~ s/^\///;
$id =~ s/(?:\/[^\/]*)?$/\/$name/ if ($NK);
next if ( $id =~ /^(generalParameters|virtualHosts)/ );
next if ( $id =~ /^(generalParameters|virtualHosts)/);
next if ( $id =~ /^samlIDPMetaData(?!XML|ExportedAttributes)(\/[^\/]+\/)?/i );
my ( $confKey, $test ) = $self->getConfTests($id);
my ( $res, $m );

View File

@ -244,7 +244,8 @@ sub struct {
# SAML #
########
samlIDPMetaData => {
_nodes => ['nhash:/samlIDPMetaData:samlIDPMetaData:samlIDP'],
_nodes => ['nhash:/samlIDPMetaDataExportedAttributes:samlIDPMetaData:samlIDP'],
_upload => ['/samlIDPMetaDataXML'],
_help => 'default',
_call => '$(\'#newsamlidpb\').show();',
},