Commit abe78a54 authored by Thomas Chemineau's avatar Thomas Chemineau
Browse files

move metadatas structures of manager into to _Struct and try to generalize...

move metadatas structures of manager into to _Struct and try to generalize display layouts of metadatas in template
parent fc542fa6
......@@ -42,27 +42,6 @@ sub setDebug {
return;
}
## @method public hashref buildIDPStruct (hashref h, string key)
# Build a simple hashref to be included into the struct of manager.
# @param hashref h The current manager struct
# @param string key The key into the manager struct
sub buildIDPStruct {
my ( $h, $k ) = @_;
%$h = (
%$h,
samlIDPMetaData => {
$k => {
_nodes => [qw(samlIDPMetaDataXML samlIDPMetaDataExportedAttributes)],
samlIDPMetaDataXML => "samlmetadata:/samlIDPMetaDataXML/$k:samlIDPMetaDataXML:textarea",
samlIDPMetaDataExportedAttributes => {
_nodes => ["hash:/samlIDPMetaDataExportedAttributes/$k:samlIDPMetaDataExportedAttributes:btext"],
_js => 'hashRoot'
},
}
});
return $h;
}
## @method public boolean initiliazeFromConf(string s)
# Initialize this object from configuration string.
# @param $s Configuration string.
......
......@@ -266,15 +266,15 @@ function samlAssertion(id) {
$('#samlAssertionLocation').attr('value',t[3]);
display('samlAssertion',lmtext(id));
}
function samlIDP(id){
function samlMetaData(id){
currentId=id;
/*if($('#li_'+myB64('/samlIDPMetaData')).find('span').size()==1){
$('#delsamlidpb').hide();
if($('#li_'+myB64('/samlIDPMetaData')).find('span').size()==1){
$('#delsamlmetadatab').hide();
}else{
$('#delsamlidpb').show();
}*/
$('#samlIDPMetaData').attr('value',lmtext(id));
display('samlIDPMetaData',lmtext(id));
$('#delsamlmetadatab').show();
}
$('#samlMetaData').attr('value',lmtext(id));
display('samlMetaData',lmtext(id));
}
function samlService(id) {
currentId=id;
......@@ -323,10 +323,10 @@ function rulesRoot(id){
display('default','');
$('#newrbr').show();
}
function samlIDPRoot(id){
function samlMetaDataRoot(id){
currentId=id;
display('default', '');
$('#newsamlidpb').show();
$('#newsamlmetadatab').show();
}
function reloadAuthParams() {
setlmdata(currentId,$('#authText').attr('value'));
......@@ -398,20 +398,20 @@ function newVh(name){
vhost(vhId);
});
}
function delSamlIDP(id){
function delSamlMetaData(id){
var idpname = $('#text_'+id).attr('name');
if(confirm('Delete '+idpname+' ?')){
$('#'+id).remove();
samlIDP(id);
samlMetaData(id);
}
}
function newSamlIDP(){
var value = prompt(text4newSamlIDP,'authentic');
if(!value){return false;}
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);
function newSamlMetaData(){
var name = prompt(text4newSamlIDP,'authentic');
if(!name){return false;}
var idpId='li_'+myB64('/samlIDPMetaDataExportedAttributes/'+name);
simpleTreeCollection[0].newAjaxNodeIn($('#li_L3NhbWxJRFBNZXRhRGF0YQ2'),idpId,name,scriptname+'?type=new&node=samlIDPMetaData/'+name,function(d,s){
$('>span',s).attr('name',name).attr('help','default').attr('id','text_'+idpId).attr('onclick','samlMetaData(\''+idpId+'\')');
samlMetaData(idpId);
});
}
var cfgAttrDone=0;
......
......@@ -99,12 +99,12 @@
<lang en="Delete key" fr="Effacer la clef" />
</button>
<button id="newsamlidpb" style="display:none;" onclick="newSamlIDP();return false;" class="ui-state-default ui-corner-all">
<lang en="New identity provider" fr="Nouveau fournisseur d'identités" />
<button id="newsamlmetadatab" style="display:none;" onclick="newSamlMetaData();return false;" class="ui-state-default ui-corner-all">
<lang en="New metadatas" fr="Nouvelles métadatas" />
</button>
<button id="delsamlidpb" style="display:none;" onclick="delSamlIDP(currentId);" class="ui-state-default ui-corner-all">
<lang en="Delete identity provider" fr="Supprimer le fournisseur d'identités" />
<button id="delsamlmetadatab" style="display:none;" onclick="delSamlMetaData(currentId);" class="ui-state-default ui-corner-all">
<lang en="Delete metadatas" fr="Supprimer les métadatas" />
</button>
</div>
......@@ -188,22 +188,9 @@
<input type="text" id="vhost" onchange="setlmtext(currentId,this.value)"/>
</div>
<!-- samlService -->
<div id="content_samlService" class="hidden">
<table>
<tr>
<td><lang en="Binding" fr="Binding"/></td>
<td><input type="text" size="50" id="samlServiceBinding" onchange="setlmsamlservice(currentId)" disabled="disabled"/></td>
</tr>
<tr>
<td><lang en="Location" fr="URL"/></td>
<td><input type="text" size="50" id="samlServiceLocation" onchange="setlmsamlservice(currentId)"/></td>
</tr>
<tr>
<td><lang en="Response Location" fr="URL de retour"/></td>
<td><input type="text" size="50" id="samlServiceResponseLocation" onchange="setlmsamlservice(currentId)"/></td>
</tr>
</table>
<!-- samlMetaData -->
<div id="content_samlMetaData" class="hidden">
<input type="text" id="samlMetaData" onchange="setlmtext(currentId,this.value)"/>
</div>
<!-- samlAssertion -->
......@@ -230,6 +217,23 @@
</table>
</div>
<!-- samlService -->
<div id="content_samlService" class="hidden">
<table>
<tr>
<td><lang en="Binding" fr="Binding"/></td>
<td><input type="text" size="50" id="samlServiceBinding" onchange="setlmsamlservice(currentId)" disabled="disabled"/></td>
</tr>
<tr>
<td><lang en="Location" fr="URL"/></td>
<td><input type="text" size="50" id="samlServiceLocation" onchange="setlmsamlservice(currentId)"/></td>
</tr>
<tr>
<td><lang en="Response Location" fr="URL de retour"/></td>
<td><input type="text" size="50" id="samlServiceResponseLocation" onchange="setlmsamlservice(currentId)"/></td>
</tr>
</table>
</div>
</div>
</form>
......
......@@ -192,13 +192,11 @@ sub confNode {
$metadata->initializeFromConfHash($h);
my $text = $target;
$text =~ s/^\/([^\/]+)\/.*$/$1/;
my $id = "$target";
my $data = $metadata->toXML();
$res .= $self->li($id)
$res .= $self->li("$target")
. $self->span(
id => $id,
id => "$target",
text => $text,
data => $data,
data => $metadata->toXML(),
js => $js,
help => $help,
target => "samlmetadata",
......@@ -302,13 +300,7 @@ sub corresp {
my $h = $self->struct();
return $h unless ($key);
if ( my $k2 = $self->param('key') ) {
# SAML identity providers
if ($key =~ /^samlIDPMetaData(?!XML|ExportedAttributes)(\/[^\/]+\/)?/i) {
$h = Lemonldap::NG::Common::Conf::SAML::Metadata::buildIDPStruct( $h, $k2 );
# Virtual hosts
} elsif ($key =~ /^virtualHosts/i) {
$h = $self->cstruct( $h, $k2 );
}
$h = $self->cstruct( $h, $key );
}
my @tmp1 = split /\//, $key;
my $help;
......
......@@ -67,8 +67,7 @@ sub confUpload {
$id =~ s/\r//g;
$id =~ s/^\///;
$id =~ s/(?:\/[^\/]*)?$/\/$name/ if ($NK);
next if ( $id =~ /^(generalParameters|virtualHosts)/);
next if ( $id =~ /^samlIDPMetaData(?!XML|ExportedAttributes)(\/[^\/]+\/)?/i );
next if ( $id =~ /^(generalParameters|virtualHosts|samlIDPMetaData)/);
my ( $confKey, $test ) = $self->getConfTests($id);
my ( $res, $m );
......
......@@ -12,29 +12,58 @@ our $VERSION = '0.1';
## @method protected hashref cstruct(hashref h,string k)
# Merge $h with the structure produced with $k and return it.
# Used to manage virtual hosts.
# Used to manage virtual hosts, and metadatas (IDP, SP).
#@param $h Result of struct()
#@param $k Name of the virtual host
#@param $k Full path of the key
#@return Tree structure
sub cstruct {
shift;
my ( $h, $k ) = @_;
my @tmp = split(/\//, $k);
return $h unless (scalar(@tmp) > 1);
my $k1 = $tmp[0];
my $k2 = $tmp[1];
if ($k1 =~ /virtualHosts/i)
{
%$h = (
%$h,
virtualHosts => {
$k => {
$k2 => {
_nodes => [qw(rules:rules:rules headers)],
rules => {
_nodes => ["hash:/locationRules/$k:rules:rules"],
_nodes => ["hash:/locationRules/$k2:rules:rules"],
_js => 'rulesRoot'
},
headers => {
_nodes => ["hash:/exportedHeaders/$k"],
_nodes => ["hash:/exportedHeaders/$k2"],
_js => 'hashRoot'
},
}
}
);
}
elsif ($k1 =~ /samlIDPMetaData/i)
{
%$h = (
%$h,
samlIDPMetaData => {
$k2 => {
_nodes => [
qw(samlIDPMetaDataExportedAttributes samlIDPMetaDataXML)
],
samlIDPMetaDataExportedAttributes => {
_nodes => [
"hash:/samlIDPMetaDataExportedAttributes/$k2"
. ":samlIDPMetaDataExportedAttributes:btext"
],
_js => 'hashRoot'
},
samlIDPMetaDataXML => "samlmetadata:/samlIDPMetaDataXML/$k2"
. ":samlIDPMetaDataXML:textarea",
}
}
);
}
return $h;
}
......@@ -244,10 +273,10 @@ sub struct {
# SAML #
########
samlIDPMetaData => {
_nodes => ['nhash:/samlIDPMetaDataExportedAttributes:samlIDPMetaData:samlIDP'],
_nodes => ['nhash:/samlIDPMetaDataExportedAttributes:samlIDPMetaData:samlMetaData'],
_upload => ['/samlIDPMetaDataXML'],
_help => 'default',
_call => '$(\'#newsamlidpb\').show();',
_call => '$(\'#newsamlmetadatab\').show();',
},
samlServiceMetaData => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment