From 2c8fcb129c45faecd1a480c44f8a1708f768b91d Mon Sep 17 00:00:00 2001 From: jrags <> Date: Tue, 19 Sep 2006 03:04:28 +0000 Subject: Inital Checkin of new membership and role providers. Currently still in development --- framework/Configuration/Provider/TProviderBase.php | 54 +++++ .../Configuration/Provider/TProviderException.php | 19 ++ .../Security/TAnonymousIdentificationModule.php | 7 + .../Security/TAuthorizationStoreRoleProvider.php | 68 ++++++ framework/Web/Security/TMembership.php | 220 ++++++++++++++++++++ framework/Web/Security/TMembershipCreateStatus.php | 39 ++++ .../Security/TMembershipCreateUserException.php | 17 ++ .../Web/Security/TMembershipPasswordException.php | 17 ++ .../Web/Security/TMembershipPasswordFormat.php | 24 +++ framework/Web/Security/TMembershipProvider.php | 66 ++++++ framework/Web/Security/TMembershipUser.php | 180 ++++++++++++++++ framework/Web/Security/TProviderException.php | 6 + framework/Web/Security/TRoleManagerModule.php | 6 + framework/Web/Security/TRolePrincipal.php | 6 + framework/Web/Security/TRoleProvider.php | 32 +++ framework/Web/Security/TRoles.php | 228 +++++++++++++++++++++ framework/Web/Security/TSqlRoleProvider.php | 41 ++++ framework/Web/Security/TUrlAuthorizationModule.php | 6 + 18 files changed, 1036 insertions(+) create mode 100644 framework/Configuration/Provider/TProviderBase.php create mode 100644 framework/Configuration/Provider/TProviderException.php create mode 100644 framework/Web/Security/TAnonymousIdentificationModule.php create mode 100644 framework/Web/Security/TAuthorizationStoreRoleProvider.php create mode 100644 framework/Web/Security/TMembership.php create mode 100644 framework/Web/Security/TMembershipCreateStatus.php create mode 100644 framework/Web/Security/TMembershipCreateUserException.php create mode 100644 framework/Web/Security/TMembershipPasswordException.php create mode 100644 framework/Web/Security/TMembershipPasswordFormat.php create mode 100644 framework/Web/Security/TMembershipProvider.php create mode 100644 framework/Web/Security/TMembershipUser.php create mode 100644 framework/Web/Security/TProviderException.php create mode 100644 framework/Web/Security/TRoleManagerModule.php create mode 100644 framework/Web/Security/TRolePrincipal.php create mode 100644 framework/Web/Security/TRoleProvider.php create mode 100644 framework/Web/Security/TRoles.php create mode 100644 framework/Web/Security/TSqlRoleProvider.php create mode 100644 framework/Web/Security/TUrlAuthorizationModule.php (limited to 'framework') diff --git a/framework/Configuration/Provider/TProviderBase.php b/framework/Configuration/Provider/TProviderBase.php new file mode 100644 index 00000000..2d44bf39 --- /dev/null +++ b/framework/Configuration/Provider/TProviderBase.php @@ -0,0 +1,54 @@ + + * @version $Id: TProviderBase.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Configuration.Provider + * @since 3.1 + */ +abstract class TProviderBase +{ + private $_Description; + private $_Initialized = false; + private $_name; + + public function __construct(){} + + public function getDescription() + { + return $this->_Description; + } + public function getName() + { + return $this->_name; + } + public function Initialize($name,$config) + { + if ($this->_Initialized) + { + throw new TProviderException('Provider_Already_Initialized'); + } + $this->_Initialized=true; + + if ($name === null) + { + throw new TProviderException('name'); + } + + if (strlen($name) == 0) + { + throw new TProviderException('Config_provider_name_null_or_empty'); + } + + $this->_name = TPropertyValue::ensureString($name); + + if ($config !== null && is_array($config)) + { + $this->_Description = TPropertyValue::ensureString($config['description']); + unset($config['description']); + } + } +} +?> \ No newline at end of file diff --git a/framework/Configuration/Provider/TProviderException.php b/framework/Configuration/Provider/TProviderException.php new file mode 100644 index 00000000..ac2caf08 --- /dev/null +++ b/framework/Configuration/Provider/TProviderException.php @@ -0,0 +1,19 @@ + + * @version $Id: TProviderException.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Configuration.Provider + * @since 3.1 + */ + +Prado::using('System.Exceptions.TException'); +class TProviderException extends TException +{ + +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TAnonymousIdentificationModule.php b/framework/Web/Security/TAnonymousIdentificationModule.php new file mode 100644 index 00000000..1735edf1 --- /dev/null +++ b/framework/Web/Security/TAnonymousIdentificationModule.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/framework/Web/Security/TAuthorizationStoreRoleProvider.php b/framework/Web/Security/TAuthorizationStoreRoleProvider.php new file mode 100644 index 00000000..d6919ae6 --- /dev/null +++ b/framework/Web/Security/TAuthorizationStoreRoleProvider.php @@ -0,0 +1,68 @@ + + * @version $Id: TAuthorizationStoreRoleProvider.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +Prado::using('System.Web.Security.TRoleProvider'); +class TAuthorizationStoreRoleProvider extends TRoleProvider +{ + private $_ApplicationName; + public function __construct() + { + + } + public function getApplicationName() + { + return $this->_ApplicationName; + } + public function setApplicationName($value) + { + $this->_ApplicationName = TPropertyValue::ensureString($value); + } + public function AddUsersToRoles($usernames,$roleNames) + { + + } + public function CreateRole($roleName) + { + + } + public function DeleteRole($roleName) + { + + } + public function FineUsersInRole($roleName,$usernameToMatch) + { + + } + public function GetAllRoles() + { + + } + public function GetRolesForUser($username) + { + + } + public function GetUsersIsRole($username,$roleName) + { + + } + public function IsUserIsRole($username,$roleName) + { + + } + public function RemoveUsersFromRoles($usernames,$roleNames) + { + + } + public function RoleExists($roleName) + { + + } +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembership.php b/framework/Web/Security/TMembership.php new file mode 100644 index 00000000..150f9528 --- /dev/null +++ b/framework/Web/Security/TMembership.php @@ -0,0 +1,220 @@ + + * @version $Id: TMembership.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +Prado::using('System.Web.Security.'); +final class TMembership +{ + public static $ApplicationName; + public static $EnablePasswordReset=false; + public static $EnablePasswordRetrieval=false; + public static $HashAlgorithmType; + public static $IsHashAlgorithmFromMembershipConfig=false; + public static $MaxInvalidPasswordAttempts; + public static $MinRequiredNonAlphanumericCharacters; + public static $MinRequiredPasswordLength; + public static $PasswordAttemptWindow; + public static $PasswordStrengthReqularExpression; + public static $Provider; + public static $Providers; + public static $RequiresQuestionAndAnswer=false; + public static $UserIsOnlineTimeWindow; + private static $_punctuations; + private static $_s_HashAlgorithmFromConfig=false; + private static $_s_HashAlgorithmType; + private static $_s_Initialized=false; + private static $_s_InitializeException; + private static $_s_lock; + private static $_s_Provider; + private static $_s_Providers; + private static $_s_UserIsOnlineTimeWindow; + + public static function __construct() + { + self::$_punctuations="!@#$%^&*()_-+=[{]};:>./?"; + self::$_s_UserIsOnlineTimeWindow=15; + self::$_s_lock = new stdClass(); + self::$_s_Initialized=false; + self::$_s_InitializeException=null; + } + public static function getApplicationName() + { + return self::$ApplicationName; + } + public static function setApplicationName($value) + { + self::$ApplicationName = TPropertyValue::ensureString($value); + } + public static function getEnablePasswordReset() + { + return self::$EnablePasswordReset; + } + public static function getEnablePasswordRetrieval() + { + return self::$EnablePasswordRetrieval; + } + public static function getHashAlgorithmType() + { + return self::$HashAlgorithmType; + } + public static function getHashAlgorithmFromMembershipConfig() + { + return self::$IsHashAlgorithmFromMembershipConfig; + } + public static function getMaxInvalidPasswordAttempts() + { + return self::$MaxInvalidPasswordAttempts; + } + public static function getMinRequiredNonAlphanumericCharacters() + { + return self::$MinRequiredNonAlphanumericCharacters; + } + public static function getMinRequiredPasswordLength() + { + return self::$MinRequiredPasswordLength; + } + public static function getPasswordAttemptWindow() + { + return self::$PasswordAttemptWindow; + } + public static function getPasswordStrengthReqularExpression() + { + return self::$PasswordStrengthReqularExpression; + } + public static function getProvider() + { + return self::$Provider; + } + public static function getProviders() + { + return self::$Providers; + } + public static function getUserIsOnlineTimeWindow() + { + return self::$UserIsOnlineTimeWindow; + } + public static function CreateUser($username,$password,$email=null,$passwordQuestion=null,$passwordAnswer=null,$isApproved=null,$providerUserKey=null) + { + return self::$Provider->CreateUser($username,$password,$email,$passwordQuestion,$passwordAnswer,$isApproved,$providerUserKey); + } + public static function DeleteUser($username,$deleteAllRelatedData=true) + { + return self::$Provider->DeleteUser($username,$deleteAllRelatedData); + } + public static function FindUsersByEmail($emailToMatch,$pageIndex=null,$pageSize=null) + { + if ($pageIndex < 0 && $pageIndex!==null) + { + throw new TException('PageIndex_bad',$pageIndex); + } + if ($pageSize > 1 && $pageSize!==null) + { + throw new TException('PageSize_bad',$pageSize); + } + return self::$Provider->FindUsersByEmail($emailToMatch,$pageIndex,$pageSize); + } + public static function FindUsersByName($usernameToMatch,$pageIndex=null,$pageSize=null) + { + if ($pageIndex < 0 && $pageIndex!==null) + { + throw new TException('PageIndex_bad',$pageIndex); + } + if ($pageSize > 1 && $pageSize!==null) + { + throw new TException('PageSize_bad',$pageSize); + } + return self::$Provider->FindUsersByName($usernameToMatch,$pageIndex,$pageSize); + } + public static function GeneratePassword($length,$numberOfNonAlphanumericCharacters) + { + if (($length < 1) || ($length > 0x80)) + { + throw new TException('Membership_password_length_incorrect'); + } + if (($numberOfNonAlphanumericCharacters > $length) || ($numberOfNonAlphanumericCharacters < 0)) + { + throw new TException('Membership_min_required_non_alphanumeric_characters_incorrect',$numberOfNonAlphanumericCharacters); + } + //need to do the alpha checking in here + // $num1=0; + // $buffer1=null; + // $chArray1; + // $num2=0; + // for ($num3 = 0;$num3 < $length; $num3++) + // { + // $num4 = $buffer[$num3]; + // } + } + public static function GetAllUsers($pageIndex=null,$pageSize=null) + { + if ($pageIndex < 0 && $pageIndex!==null) + { + throw new TException('PageIndex_bad',$pageIndex); + } + if ($pageSize > 1 && $pageSize!==null) + { + throw new TException('PageSize_bad',$pageSize); + } + return self::$Provider->GetAllUsers($pageIndex,$pageSize); + } + private static function GetCurrentUserName() + { + //how to get the current username? + } + public static function GetNumberOfUsersOnline() + { + return self::$Provider->GetNumberOfUsersOnline(); + } + public static function GetUser($username=null,$providerUserKey=null,$userIsOnline=false) + { + if ($username===null && $providerUserKey===null) + { + return self::$Provider->GetUser(self::GetCurrentUserName(),null,true); + } + if ($username===null && $providerUserKey!==null) + { + return self::$Provider->GetUser(null,$providerUserKey,$userIsOnline); + } + if ($username!==null && $providerUserKey===null) + { + return self::$Provider->GetUser($username,null,$userIsOnline); + } + } + public static function GetUserNameByEmail($emailToMatch) + { + return self::$Provider->GetUserNameByEmail($emailToMatch); + } + private static function Initialize() + { + if (self::$_s_Initialized) + { + if (self::$_s_InitializeException!==null) + { + throw new self::$_s_InitializeException; + } + } + else + { + + } + } + public static function UpdateUser(TMembershipUser $user) + { + if ($user===null) + { + throw new TException('Membership_user_can_not_be_null'); + } + $user->Update(); + } + public static function ValidateUser($username,$password) + { + return self::$Provider->ValidateUser($username,$password); + } +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipCreateStatus.php b/framework/Web/Security/TMembershipCreateStatus.php new file mode 100644 index 00000000..78b64de4 --- /dev/null +++ b/framework/Web/Security/TMembershipCreateStatus.php @@ -0,0 +1,39 @@ + + * @version $Id: TMembershipCreateStatus.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +class TMembershipCreateStatus extends TEnumerable +{ + const DuplicateEmail='DuplicateEmail'; + const DuplicateProviderUserKey='DuplicateProviderUserKey'; + const DuplicateUserName='DuplicateUserName'; + const InvalidAnswer='InvalidAnswer'; + const InvalidEmail='InvalidEmail'; + const InvalidPassword='InvalidPassword'; + const InvalidProviderUserKey='InvalidProviderUserKey'; + const InvalidQuestion='InvalidQuestion'; + const InvalidUserName='InvalidUserName'; + const ProviderError='ProviderError'; + const Success='Success'; + const UserRejected='UserRejected'; +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipCreateUserException.php b/framework/Web/Security/TMembershipCreateUserException.php new file mode 100644 index 00000000..def74c8d --- /dev/null +++ b/framework/Web/Security/TMembershipCreateUserException.php @@ -0,0 +1,17 @@ + + * @version $Id: TMembershipCreateUserException.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Configuration.Provider + * @since 3.1 + */ + +Prado::using('System.Exceptions.TException'); +class TMembershipCreateUserException extends TException +{ + +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipPasswordException.php b/framework/Web/Security/TMembershipPasswordException.php new file mode 100644 index 00000000..faf0c599 --- /dev/null +++ b/framework/Web/Security/TMembershipPasswordException.php @@ -0,0 +1,17 @@ + + * @version $Id: TMembershipPasswordException.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Configuration.Provider + * @since 3.1 + */ + +Prado::using('System.Exceptions.TException'); +class TMembershipPasswordException extends TException +{ + +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipPasswordFormat.php b/framework/Web/Security/TMembershipPasswordFormat.php new file mode 100644 index 00000000..6648c92b --- /dev/null +++ b/framework/Web/Security/TMembershipPasswordFormat.php @@ -0,0 +1,24 @@ + + * @version $Id: TMembershipPasswordFormat.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +class TMembershipPasswordFormat extends TEnumerable +{ + const Clear='Clear'; + const Encrypted='Encrypted'; + const Hashed='Hashed'; +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipProvider.php b/framework/Web/Security/TMembershipProvider.php new file mode 100644 index 00000000..674f338c --- /dev/null +++ b/framework/Web/Security/TMembershipProvider.php @@ -0,0 +1,66 @@ + + * @version $Id: TMembershipProvider.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +Prado::using('System.Configuration.Provider.TProviderBase'); +abstract class TMembershipProvider extends TProviderBase +{ + public abstract $ApplicationName; + public abstract $EnablePasswordReset=false; + public abstract $EnablePasswordRetrieval=false; + public abstract $MaxInvalidPasswordAttempts; + public abstract $MinRequiredNonAlphanumericCharacters; + public abstract $MinRequiredPasswordLength; + public abstract $PasswordAttemptWindow; + public abstract $PasswordStrengthReqularExpression; + public abstract $RequiresQuestionAndAnswer=false; + public abstract $RequiresUniqueEmail=false; + // private const SALT_SIZE_IN_BYTES = 0x10; + + protected function __construct() + { + + } + public abstract function ChangePassword($username,$oldPassword,$newPassword); + public abstract function ChangePasswordQuestionAndAnswer($username,$password,$newPasswordQuestion,$newPasswordAnswer); + public abstract function CreateUser($username,$password,$email,$passwordQuestion,$passwordAnswer,$isApproved,$providerUserKey); + protected function DecryptPassword($encodedPassword) + { + + } + public abstract function DeleteUser($username,$deleteAllRelatedData); + public function EncodePassword($pass,$passwordFormat,$salt) + { + + } + protected function EncryptPassword($password) + { + + } + public abstract function FindUsersByEmail($emailToMatch,$pageIndex=null,$pageSize=null); + public abstract function FindUsersByName($usernameToMatch,$pageIndex=null,$pageSize=null); + public function GenerateSalt() + { + + } + public abstract function GetAllUsers($pageIndex=null,$pageSize=null); + public abstract function GetNumberOfUsersOnline(); + public abstract function GetPassword($username,$answer); + public abstract function GetUser($username=null,$providerUserKey=null,$userIsOnline); + public abstract function GetUserNameByEmail($email); + public abstract function ResetPassword($username,$answer); + public function UnEncodePassword($pass,$passwordFormat) + { + + } + public abstract function UnlockUser($userName); + public abstract function UpdateUser(TMembershipUser $user); + public abstract function ValidateUser($username,$password); +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TMembershipUser.php b/framework/Web/Security/TMembershipUser.php new file mode 100644 index 00000000..722459fc --- /dev/null +++ b/framework/Web/Security/TMembershipUser.php @@ -0,0 +1,180 @@ + + * @version $Id: TMembershipUser.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +class TMembershipUser +{ + public $Comment; + public $CreationDate; + public $Email; + public $IsApproved=false; + public $IsLockedOut=false; + public $IsOnline=false; + public $LastActivityDate; + public $LastLockoutDate; + public $LastLoginDate; + public $LastPasswordChangedDate; + public $PasswordQuestion; + public $ProviderName; + public $ProviderUserKey; + public $UserName; + private $_Comment; + private $_CreationDate; + private $_Email; + private $_IsApproved=false; + private $_IsLockedOut=false; + private $_LastActivityDate; + private $_LastLockoutDate; + private $_LastLoginDate; + private $_LastPasswordChangedDate; + private $_PasswordQuestion; + private $_ProviderName; + private $_ProviderUserKey; + private $_UserName; + + public function __construct($providerName=null,$name=null,$providerUserKey=null,$email=null,$passwordQuestion=null,$comment=null,$isApproved=null,$isLockedOut=null,$creationDate=null,$lastLoginDate=null,$lastActivityDate=null,$lastPasswordChangedDate=null,$lastLockoutDate=null) + { + if (($providerName===null) || (TMembership===null)) + { + throw new TProviderException('Membership_provider_name_invalid',$providerName); + } + if ($name!==null) + { + $name = trim($name); + } + if ($email!==null) + { + $email = trim($email); + } + if ($passwordQuestion!==null) + { + $passwordQuestion = trim($passwordQuestion); + } + $this->_ProviderName = $providerName; + $this->_UserName = $name; + $this->_ProviderUserKey = $providerUserKey; + $this->_Email = $email; + $this->_PasswordQuestion = $passwordQuestion; + $this->_Comment = $comment; + $this->_IsApproved = $isApproved; + $this->_IsLockedOut = $isLockedOut; + $this->_CreationDate = $creationDate; + $this->_LastLoginDate = $lastLoginDate; + $this->_LastActivityDate = $lastActivityDate; + $this->_LastPasswordChangedDate = $lastPasswordChangedDate; + $this->_LastLockoutDate = $lastLockoutDate; + } + public function getComment() + { + return $this->Comment; + } + public function setApplicationName($value) + { + $this->Comment = TPropertyValue::ensureString($value); + } + public function getCreationDate() + { + return $this->CreationDate; + } + public function getEmail() + { + return $this->Email; + } + public function setEmail($value) + { + $this->Email = TPropertyValue::ensureString($value); + } + public function getIsApproved() + { + return $this->IsApproved; + } + public function setIsApproved($value) + { + $this->IsApproved = TPropertyValue::ensureBoolean($value); + } + public function getIsLockedOut() + { + return $this->IsLockedOut; + } + public function getIsOnline() + { + return $this->IsOnline; + } + public function getLastActivityDate() + { + return $this->LastActivityDate; + } + public function setLastActivityDate($value) + { + $this->LastActivityDate = TPropertyValue::ensureString($value); + } + public function getLastLockoutDate() + { + return $this->LastLockoutDate; + } + public function getLastLoginDate() + { + return $this->LastLoginDate; + } + public function setLastLoginDate($value) + { + $this->LastLoginDate = TPropertyValue::ensureString($value); + } + public function getLastPasswordChangedDate() + { + return $this->LastPasswordChangedDate; + } + public function getLastPasswordChangedDate() + { + return $this->LastPasswordChangedDate; + } + public function getPasswordQuestion() + { + return $this->PasswordQuestion; + } + public function getProviderUserKey() + { + return $this->ProviderUserKey; + } + public function getUserName() + { + return $this->UserName; + } + public function ChangePassword($oldPassword,$newPassword,$throwOnError=null) + { + + } + public function GetPassword() + { + // $throwOnError; + // $passwordAnswer; + // $answer; + // $answer,$useAnswer,$throwOnError; + } + public function ResetPassword() + { + // $throwOnError; + // $passwordAnswer; + // $answer; + // $answer,$useAnswer,$throwOnError; + } + public function UnlockUser() + { + + } + public function Update() + { + + } + private function UpdateSelf() + { + + } +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TProviderException.php b/framework/Web/Security/TProviderException.php new file mode 100644 index 00000000..7239585c --- /dev/null +++ b/framework/Web/Security/TProviderException.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/framework/Web/Security/TRoleManagerModule.php b/framework/Web/Security/TRoleManagerModule.php new file mode 100644 index 00000000..7f6181e0 --- /dev/null +++ b/framework/Web/Security/TRoleManagerModule.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/framework/Web/Security/TRolePrincipal.php b/framework/Web/Security/TRolePrincipal.php new file mode 100644 index 00000000..682f2cbe --- /dev/null +++ b/framework/Web/Security/TRolePrincipal.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/framework/Web/Security/TRoleProvider.php b/framework/Web/Security/TRoleProvider.php new file mode 100644 index 00000000..d705be7e --- /dev/null +++ b/framework/Web/Security/TRoleProvider.php @@ -0,0 +1,32 @@ + + * @version $Id: TRoleProvider.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +Prado::using('System.Configuration.Provider.TProviderBase'); +abstract class TRoleProvider extends TProviderBase +{ + private abstract $_ApplicationName; + protected function __construct() + { + + } + public abstract function getApplicationName(); + public abstract function setApplicationName($value); + public abstract function AddUsersToRoles($usernames,$roleNames); + public abstract function CreateRole($roleName); + public abstract function DeleteRole($roleName); + public abstract function FineUsersInRole($roleName,$usernameToMatch); + public abstract function GetAllRoles(); + public abstract function GetRolesForUser($username); + public abstract function GetUsersIsRole($username,$roleName); + public abstract function IsUserIsRole($username,$roleName); + public abstract function RemoveUsersFromRoles($usernames,$roleNames); + public abstract function RoleExists($roleName); +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TRoles.php b/framework/Web/Security/TRoles.php new file mode 100644 index 00000000..45e112c7 --- /dev/null +++ b/framework/Web/Security/TRoles.php @@ -0,0 +1,228 @@ +CreateRole($roleName); + } + public static function DeleteCookie() + { + + } + public static function DeleteRole($roleName,$throwOnPopulatedRole=true) + { + self::EnsureEnabled(); + + // $flag1 = self::$_Provider->DeleteRole($roleName,$throwOnPopulatedRole); + // try + // { + // $principal1 = self::GetCurrentUser(); + // } + // catch () + // { + // + // } + + } + private static function EnsureEnabled() + { + self::Initialize(); + if (!self::$_s_Initialized) + { + throw new TException('Roles_feature_not_enabled'); + } + } + public static function FindUsersInRole($roleName,$usernameToMatch) + { + + } + public static function GetAllRoles() + { + + } + private static function GetCurrentUser() + { + + } + private static function GetCurrentUserName() + { + + } + public static function GetRolesForUser($username=null) + { + + } + public static function GetUsersInRole($roleName) + { + + } + private static function Initialize() + { + if (self::$_s_Initialized) + { + if (self::$_s_InitializeException!==null) + { + throw new $_s_InitializeException; + } + } + else + { + if (self::$_s_Initialized) + { + if (self::$_s_InitializeException!==null) + { + throw new $_s_InitializeException; + } + return; + } + try + { + self::$_Enabled; + self::$_CookieName; + self::$_CookiePath; + self::$_CacheRolesInCookie; + self::$_CookieTimeout; + self::$_CookiePath; + self::$_CookieRequireSSL; + self::$_CookieSlidingExpiration; + self::$_CookieProtectionValue; + self::$_Domain; + self::$_CreatePersistentCookie; + self::$_MaxCachedResults; + if (self::$_Enabled) + { + if (self::$_MaxCachedResults < 0) + { + throw new TException('Value_must_be_non_negative_integer',self::$_MaxCachedResults); + }////stopped here + } + } + catch (TException $e) + { + + } + } + } + public static function IsUserInRole($roleName,$username=null) + { + + } + public static function RemoveUserFromRole($username,$roleName) + { + + } + public static function RemoreUserFromRoles($username,$roleNames) + { + + } + public static function RemoveUsersFromRole($usernames,$roleName) + { + + } + public static function RemoveUsersFromRoles($usernames,$roleNames) + { + + } + public static function RoleExists($roleName) + { + + } +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TSqlRoleProvider.php b/framework/Web/Security/TSqlRoleProvider.php new file mode 100644 index 00000000..24f5e38d --- /dev/null +++ b/framework/Web/Security/TSqlRoleProvider.php @@ -0,0 +1,41 @@ + + * @version $Id: TSqlRoleProvider.php 1398 2006-09-08 19:31:03Z xue $ + * @package System.Web.Security + * @since 3.1 + */ +Prado::using('System.Web.Security.TRoleProvider'); +class TSqlRoleProvider extends TRoleProvider +{ + private $_ApplicationName; + protected function __construct() + { + + } + public function getApplicationName() + { + return $this->_ApplicationName; + } + public function setApplicationName($value) + { + $this->_ApplicationName = TPropertyValue::ensureString($value); + } + public function AddUsersToRoles($usernames,$roleNames) + { + + } + public function CreateRole($roleName); + public function DeleteRole($roleName); + public function FineUsersInRole($roleName,$usernameToMatch); + public function GetAllRoles(); + public function GetRolesForUser($username); + public function GetUsersIsRole($username,$roleName); + public function IsUserIsRole($username,$roleName); + public function RemoveUsersFromRoles($usernames,$roleNames); + public function RoleExists($roleName); +} +?> \ No newline at end of file diff --git a/framework/Web/Security/TUrlAuthorizationModule.php b/framework/Web/Security/TUrlAuthorizationModule.php new file mode 100644 index 00000000..c321d95d --- /dev/null +++ b/framework/Web/Security/TUrlAuthorizationModule.php @@ -0,0 +1,6 @@ + \ No newline at end of file -- cgit v1.2.3