Skip to content
Snippets Groups Projects
Commit eae7b852 authored by Lasse Birnbaum Jensen's avatar Lasse Birnbaum Jensen
Browse files

Implemented issue 99. http://code.google.com/p/simplesamlphp/issues/detail?id=99

!! IMPORTANT !!
This patch may break existing configurations if custom attributealter functions are used.

To use the new implementation attributealter function must be placed in a specific file for that function. 

Example: attributealter function insertorgname which insert a static organization name in the attribute set.

Function must be placed in file attributealter/insertorgname.php and have the following content.

attributealter/insertorgname.php
<?php

function attributealter_insertorgname($attributes,$spid = null, $idpid=null) {
$attributes['orgname']=array('static name');
}
  




git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@636 44740490-163a-0410-bde0-09ae8108e29a
parent 308a2068
No related branches found
No related tags found
No related merge requests found
<?php
function attributealter_edupersontargetedid(&$attributes, $spEntityId = null, $idpEntityId = null) {
assert('$spEntityId !== NULL');
assert('$idpEntityId !== NULL');
$userid = SimpleSAML_Utilities::generateUserIdentifier($idpEntityId, $spEntityId, $attributes);
$attributes['eduPersonTargetedID'] = array($userid);
}
?>
\ No newline at end of file
<?php <?php
function encodeIllegalChars($input) { function encodeIllegalChars($input) {
return preg_replace("/[^a-zA-Z0-9_@=.]/", "_", $input); return preg_replace("/[^a-zA-Z0-9_@=.]/", "_", $input);
} }
...@@ -72,36 +68,4 @@ function attributealter_groups(&$attributes, $spentityid = null, $idpentityid = ...@@ -72,36 +68,4 @@ function attributealter_groups(&$attributes, $spentityid = null, $idpentityid =
$attributes['groups'] = $groups; $attributes['groups'] = $groups;
} }
?>
\ No newline at end of file
function attributealter_test(&$attributes, $spentityid = null, $idpentityid = null) {
$attributes['injected'] = array('newvalue');
}
function attributealter_realm(&$attributes, $spentityid = null, $idpentityid = null) {
$attributename = 'eduPersonPrincipalName';
# $attributename = 'edupersonprincipalname';
if (array_key_exists($attributename, $attributes)) {
$eduppn = $attributes[$attributename][0];
$splitted = explode('@', $eduppn);
if (count($splitted) > 1) {
$attributes['realm'] = array($splitted[1]);
} else {
SimpleSAML_Logger::debug('attributealter_realm: Wrong format on ' . $attributename . ' (not including @)');
}
} else {
SimpleSAML_Logger::debug('attributealter_realm: Could not find ' . $attributename);
}
}
function attributealter_edupersontargetedid(&$attributes, $spEntityId = null, $idpEntityId = null) {
assert('$spEntityId !== NULL');
assert('$idpEntityId !== NULL');
$userid = SimpleSAML_Utilities::generateUserIdentifier($idpEntityId, $spEntityId, $attributes);
$attributes['eduPersonTargetedID'] = array($userid);
}
<?php
function attributealter_realm(&$attributes, $spentityid = null, $idpentityid = null) {
$attributename = 'eduPersonPrincipalName';
# $attributename = 'edupersonprincipalname';
if (array_key_exists($attributename, $attributes)) {
$eduppn = $attributes[$attributename][0];
$splitted = explode('@', $eduppn);
if (count($splitted) > 1) {
$attributes['realm'] = array($splitted[1]);
} else {
SimpleSAML_Logger::debug('attributealter_realm: Wrong format on ' . $attributename . ' (not including @)');
}
} else {
SimpleSAML_Logger::debug('attributealter_realm: Could not find ' . $attributename);
}
}
?>
\ No newline at end of file
<?php
function attributealter_test(&$attributes, $spentityid = null, $idpentityid = null) {
$attributes['injected'] = array('newvalue');
}
?>
\ No newline at end of file
...@@ -93,8 +93,8 @@ class SimpleSAML_XML_AttributeFilter { ...@@ -93,8 +93,8 @@ class SimpleSAML_XML_AttributeFilter {
*/ */
public function alter($rule, $spentityid = null, $idpentityid = null) { public function alter($rule, $spentityid = null, $idpentityid = null) {
$alterfile = $this->configuration->getBaseDir() . 'attributealter/alterfunctions.php'; $alterfile = $this->configuration->getBaseDir() . 'attributealter/' . $rule . '.php';
if (!file_exists($alterfile)) throw new Exception('Could not find attributemap file: ' . $alterfile); if (!file_exists($alterfile)) throw new Exception('Could not find attributealter file: ' . $alterfile);
include_once($alterfile); include_once($alterfile);
...@@ -103,7 +103,7 @@ class SimpleSAML_XML_AttributeFilter { ...@@ -103,7 +103,7 @@ class SimpleSAML_XML_AttributeFilter {
if (function_exists($function)) { if (function_exists($function)) {
$function($this->attributes, $spentityid, $idpentityid); $function($this->attributes, $spentityid, $idpentityid);
} else { } else {
throw new Exception('Could not find attribute alter fucntion: ' . $function); throw new Exception('Could not find attribute alter fucntion: ' . $function . ' in file ' .$alterfile);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment