PVSecurity is a class designed to handle the security of your application ranging from encryption to hashing.
ProdigyView comes with the ability to implement adapters, intercepting filters and observers. Extending this class to a child class will give the child class the ability to use those design patterns along with a collection that can assign and retrieve values using magic functions.
Example:
//Create the class
class Example extends PVObject {
public static function testMe($string) {
echo $string;
//An observer
$this->_notify(get_class() . '::' . __FUNCTION__, $string);
}
}
//Add to its collection
Example::set('foo','bar');
echo Example::get('foo');
//Add a dynamic method
Example::addMethod('fiz', function($text) {
return 'fiz ' . $text;
});
echo Example::fizz('Bop');
//Add Observer
Example::addObserver('Example::testMe', 'test_closure', function($string) {
echo "\nLine 2 \n"
echo $string;
}, array('type' => 'closure'));
//Will call test me and the observer attached
Example::testMe('Testing String ');
| TODO |
rework classs |
|---|---|
| package |
system |
__callStatic(string $method, mixed $args = array()) : mixed
| access |
public |
|---|
stringThe key/name assigned to the method when added
mixedArguements to pass to the annoymous function. The function is called using call_user_func_array.
mixed$value The value returned is the value the stored function returns
_applyFilter(string $class, string $method, mixed $data, array $options = array()) : mixed
| access |
protected |
|---|
stringThe name of the class the filter is in
stringThe method the filter is in
mixedThe data that is being passed to the filter
arrayoptions to be passed to the filter. Passed options we be passed to the function. -'default_return' mixed: If no filter is return, the data passed in by default will be return. Can be overriden -'event' string: An event to associate with the filter. Default is null
mixed$data The data the function returns
_callAdapter(string $class, string $method) : mixed
| access |
protected |
|---|
stringThe name of the class the adapter is in
stringTHe name of the method the class is being called from.
mixed$value A value that the adapter returns
_checkIv( $iv)
_checkKey( $key)
_getEncryptDefaults() : array
| access |
protected |
|---|---|
array$configuration Returns the configuration in an array
_hasAdapter( $class, string $method) : \boolea
| access |
protected |
|---|
stringThe associated method
\boolea$hasAdapter Returns true if it has an adapter or false if it doesn not
_hasFilter(string $class, string $method)
stringThe class the filter is in
stringThe method of the class that the filter is in
_invokeMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_invokeStaticMethod(string $class, string $method, array $args) : mixed
| access |
protected |
|---|
stringThe name of the class to be called
stringThe name of the method in the class to be called
arrayAn array of arguements. Arguements have to be embedded in an array to be called.
mixed$data Data returned by the function called
_logAdapter(array $data) : void
| access |
private |
|---|
arrayThe data in the adapter
_logFilter(array $data) : void
| access |
private |
|---|
arrayThe data in the filter
_logObserver(array $data) : void
| access |
private |
|---|
arrayThe data in the observer
_notify(string $event) : void
| access |
protected |
|---|
stringThe name of the even that occured that will trigger notifies
_prepareLogData(array $data) : string
| access |
private |
|---|
array
string$message JSON encode message of information about the data
addAdapter(string $trigger_class, string $trigger_method, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
add ability to adapt singleton class |
stringThe class that contains the function the adapter will respond too
stringThe method called that will have the adapter to be called.
stringThe new class to be called that has the same method name
arrayAn array of options that be called -'object' string : Assumes that default method in the class to be called is static. If called object needs to be instantiated, change to object to 'instance' and one will be created before the adapter calls the function -'call_method' string: By default the method to be called to override the current one should be the same name. But this can be ovveridden to call a different method. -'type' string: The type of method being called. Default is class_method but if the method is a closure, set the type to be 'closure' and make the $trigger_method the closure
addClassAdapter(mixed $trigger_class, string $call_class, array $options = array()) : void
| access |
public |
|---|---|
| todo |
Add ability to use singleton classes |
mixedThis can either be the name of the class or an object whose methods will be adapted to another class. The class should be included or be autoloaded by this point.
stringThe call class is the classes methods that will be called in place of the methods in the trigger_class. These class does not have to be included as this point.
arrayOptions that be used to further distinguish the behavior of the adapters added -'object' string: Determines if the object being adapted to is static or an instance.Default is static -'call_class' string: The name of the class that the methods will be adapted too. -'class' string: The name of the whose methods will be adapted to another class
addFilter(string $class, string $method, string $filter_class, string $filter_method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the class the filter is going in
stringThe name of the method the filter is in
stringThe class that the filter resides in.
stringThe method in the class that the parameters will be passed too.
arrayOptions that can be set for further modifying the filter. -'object' string: If the method being called is static, static should be inserted. If its in an instance, 'instance' should be set. Default is set to static. -'event' string: Associate this filter with an event. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $filter_method the closure
addMethod(string $method, \function $closure) : void
| access |
public |
|---|
stringThe key/value that will be used to call the function
\functionThe anonymous function/closure to be added
addObserver(string $event, string $class, string $method, array $options = array()) : void
| access |
public |
|---|
stringThe name of the event that will cause a certain class and method to fire
stringThe name of the class that contains the function that will be fired for this event
stringThe name of the method that will be fired when the event occurs
arrayOptions to further the define the firing of an event -'object' string : If the method being called is static, should be set to static. Else set to instance -'class' stinrg : The name of the class to be called. Default is the class that is passed in. -'method' string: The name of the method to be called. Default is the method that is passed in. -'type' string: The type of function being called. Default is class_method but if the function is a closure, set the type to be 'closure' and make the $method the closure
addToCollection(mixed $data) : void
| access |
public |
|---|
mixedAny data type( Object, Array, int, etc) to add to the public data collection
addToCollectionWithName(string $name, mixed $data) : void
| access |
public |
|---|---|
| todo |
check the relevance of get and set |
stringThe key/index to assign the value to
mixedData to be stored in the collection
checkAuth(array $fields, array $options = array()) : mixed
| access |
public |
|---|
arrayAn array of fields that will be checked against the fields in the database table
arrayAn array of options -'auth_table' string: The table name to be checked against -'auth_hashed_fields' array: An array of fields that must be hashed before checking -'auth_encrypted_fields' array: An array of fields that must be encrypted before checking -'format_table' boolean: Will formated the table with any prefixes or schemas. Default is false. -'save_cookie' boolean: If authenticated save data into cookie. Default is true. -'save_session' boolean: If authenticated, save data into session. Default is true -'cookie_fields' array: The fields that will be saved into the cookie -'session_fields' array: The fields that will be saved into the session
mixedIf authenticated, the return will be the row in the database. Otherwise false.
clearFilters(string $class, string $method) : void
| access |
public |
|---|
stringThe class the filter is in
stringThe method of the class that the filter is in
clearObservers(string $event) : void
| access |
public |
|---|
stringThe event to remove all the observers from
decrypt( $string, array $options = array()) : string
| access |
public |
|---|
arrayAn array of options that defines how to perform the encryption
string$decrypted_string The string decrypted
encrypt(string $string, array $options = array()) : string
| access |
public |
|---|
stringThe string to be encrypted
arrayAn array of options to configure the encryption
string$encrypted_string Returns an encryped string of data
get(string $index) : mixed
| access |
public |
|---|
stringThe index to retrieve a value from
mixed$data The data that was stored at that index
getInstance() : object
| access |
public |
|---|---|
object$instance Returns the instance of a class.
getIterator() : \PVIterator
hash(string $string, string $salt = null) : string
| access |
public |
|---|
stringThe string to be hashed
stringA salt to add to the hash
string$hashed_string Returns the hashed string
init(array $args = array()) : void
| access |
public |
|---|
arrayAn array of arguments to be passed into the security class. -'mcrypt_algorithm' string : The algorthim to be used for encruption. MCRYPT_DES is default -'mcrypt_algorithm_directory' string: The directory the algorithm -'mcrypt_mode' string : The mode to set for mcrypt. Defaults of 'ofb' -'mcrypt_key' string: The default key that will be used for encryption -'mcrypt_iv' string: The iv the will be used for encryption -'salt' string: The default value that will be applied as a salt when hashing -'auth_table' string: The table name that will perform authorization of a user. Default name is users -'auth_hashed_fields' array: An array of fields that will be hashed on authentication -'auth_encrypted_fields' array: An array of fields that will be encryped on authentication -'save_cookie' boolean: Enable the saving of variables to a cookie on save -'save_session' boolean: Enable the saving the variables to a session on authentication -'cookie_fields' array: An array of fields pulled from the auth table that will be saved to the cookie on authentication -'session_fields' array: An array of fields pulled from the auth table that will be saved to the session on authentication
removeAdapter( $class, string $method) : void
| access |
public |
|---|
stringThe associated method
removeClassAdapter( $class) : void
| access |
public |
|---|
set(string $index, mixed $value) : void
| access |
public |
|---|
stringThe key or index to store the value at
mixedA mixed value that can be anytype
setAdapterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace adatper.
setFilterTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace filter.
setObserverTrace(boolean $trace = false) : void
| access |
public |
|---|
booleanDefault is false. If set to true, will trace observer.
cipher :
mcrypt_algorithm :
mcrypt_algorithm_directory :
mcrypt_mode :
mcrypt_mode_directory :
mcrypt_key :
mcrypt_iv :
_salt :
_auth_table :
_auth_hashed_fields :
_auth_encrypted_fields :
_save_session :
_session_fields :
_collection :
_methods :
_adapters :
_observers :
_instances :
_filters :
_traceAdapters :
_traceFilters :
_traceObservers :