allow obfuscated settings
This commit is contained in:
parent
e1ad25ef02
commit
825c546991
|
@ -778,4 +778,47 @@ function formatLDAPTimestamp($time) {
|
||||||
' ' . substr($time, 8, 2) . ':' . substr($time, 10, 2) . ':' . substr($time, 12, 2) . ' GMT';
|
' ' . substr($time, 8, 2) . ':' . substr($time, 10, 2) . ':' . substr($time, 12, 2) . ' GMT';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple function to obfuscate strings.
|
||||||
|
*
|
||||||
|
* @param String $text text to obfuscate
|
||||||
|
*/
|
||||||
|
function obfuscateText($text) {
|
||||||
|
if (($text == null) || ($text == '')) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
return str_rot13(base64_encode('LAM_OBFUSCATE:'.$text));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple function to deobfuscate strings.
|
||||||
|
*
|
||||||
|
* @param String $text text to deobfuscate
|
||||||
|
*/
|
||||||
|
function deobfuscateText($text) {
|
||||||
|
if (($text == null) || ($text == '')) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
return str_replace('LAM_OBFUSCATE:', '', base64_decode(str_rot13($text)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given text is obfuscated.
|
||||||
|
*
|
||||||
|
* @param String $text text to check
|
||||||
|
* @return boolean obfuscated or not
|
||||||
|
*/
|
||||||
|
function isObfuscatedText($text) {
|
||||||
|
if (($text == null) || ($text == '')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$deob = base64_decode(str_rot13($text));
|
||||||
|
if (strpos($deob, 'LAM_OBFUSCATE:') === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -349,6 +349,8 @@ class htmlInputField extends htmlElement {
|
||||||
private $isPassword = false;
|
private $isPassword = false;
|
||||||
/** enabled or disabled */
|
/** enabled or disabled */
|
||||||
private $isEnabled = true;
|
private $isEnabled = true;
|
||||||
|
/** indicates that the value should be saved in obfuscated form */
|
||||||
|
private $obfuscate = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -357,6 +359,9 @@ class htmlInputField extends htmlElement {
|
||||||
* @param String $fieldValue value of input field (optional)
|
* @param String $fieldValue value of input field (optional)
|
||||||
*/
|
*/
|
||||||
function __construct($fieldName, $fieldValue = null, $fieldSize = null) {
|
function __construct($fieldName, $fieldValue = null, $fieldSize = null) {
|
||||||
|
if (isObfuscatedText($fieldValue)) {
|
||||||
|
$fieldValue = deobfuscateText($fieldValue);
|
||||||
|
}
|
||||||
$this->fieldName = htmlspecialchars($fieldName);
|
$this->fieldName = htmlspecialchars($fieldName);
|
||||||
$this->fieldValue = htmlspecialchars($fieldValue);
|
$this->fieldValue = htmlspecialchars($fieldValue);
|
||||||
if ($fieldSize != null) {
|
if ($fieldSize != null) {
|
||||||
|
@ -377,8 +382,13 @@ class htmlInputField extends htmlElement {
|
||||||
*/
|
*/
|
||||||
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
|
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
|
||||||
if (isset($values[$this->fieldName])) {
|
if (isset($values[$this->fieldName])) {
|
||||||
|
if (isObfuscatedText($values[$this->fieldName][0])) {
|
||||||
|
$this->fieldValue = deobfuscateText($values[$this->fieldName][0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->fieldValue = $values[$this->fieldName][0];
|
$this->fieldValue = $values[$this->fieldName][0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// print input field
|
// print input field
|
||||||
$name = ' name="' . $this->fieldName . '"';
|
$name = ' name="' . $this->fieldName . '"';
|
||||||
$value = '';
|
$value = '';
|
||||||
|
@ -401,8 +411,13 @@ class htmlInputField extends htmlElement {
|
||||||
$disabled = ' disabled';
|
$disabled = ' disabled';
|
||||||
}
|
}
|
||||||
echo '<input type="' . $inputType . '"' . $name . $value . $maxLength . $size . $fieldTabIndex . $disabled . '>';
|
echo '<input type="' . $inputType . '"' . $name . $value . $maxLength . $size . $fieldTabIndex . $disabled . '>';
|
||||||
|
if ($this->obfuscate) {
|
||||||
|
return array($this->fieldName => 'text_obfuscated');
|
||||||
|
}
|
||||||
|
else {
|
||||||
return array($this->fieldName => 'text');
|
return array($this->fieldName => 'text');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the maximum field length.
|
* Sets the maximum field length.
|
||||||
|
@ -440,6 +455,15 @@ class htmlInputField extends htmlElement {
|
||||||
$this->isEnabled = $isEnabled;
|
$this->isEnabled = $isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if the value should be saved in obfuscated form (e.g. self service profile).
|
||||||
|
*
|
||||||
|
* @param boolean $obfuscate obfuscate value
|
||||||
|
*/
|
||||||
|
public function setObfuscate($obfuscate) {
|
||||||
|
$this->obfuscate = $obfuscate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue