PHP 클래스 Prado\Security\TSecurityManager

TSecurityManager provides private keys, hashing and encryption functionalities that may be used by other PRADO components, such as viewstate persister, cookies. TSecurityManager is mainly used to protect data from being tampered and viewed. It can generate HMAC and encrypt the data. The private key used to generate HMAC is set by {@link setValidationKey ValidationKey}. The key used to encrypt data is specified by {@link setEncryptionKey EncryptionKey}. If the above keys are not explicitly set, random keys will be generated and used. To prefix data with an HMAC, call {@link hashData()}. To validate if data is tampered, call {@link validateData()}, which will return the real data if it is not tampered. The algorithm used to generated HMAC is specified by {@link setValidation Validation}. To encrypt and decrypt data, call {@link encrypt()} and {@link decrypt()} respectively. The encryption algorithm can be set by {@link setEncryption Encryption}. Note, to use encryption, the PHP Mcrypt extension must be loaded.
부터: 3.0
저자: Qiang Xue ([email protected])
상속: extends Prado\TModule
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
decrypt ( $data ) : string Decrypts data with {@link getEncryptionKey EncryptionKey}.
encrypt ( $data ) : string Encrypts data with {@link getEncryptionKey EncryptionKey}.
getCryptAlgorithm ( ) : mixed
getEncryption ( ) : string This method has been deprecated since version 3.2.1.
getEncryptionKey ( ) : string
getHashAlgorithm ( ) : string
getValidation ( ) : string This method has been deprecated since version 3.2.1.
getValidationKey ( ) : string
hashData ( $data ) : string Prefixes data with an HMAC.
init ( $config ) Initializes the module.
setCryptAlgorithm ( $value ) Sets the crypt algorithm (also known as cipher or cypher) that will be used for {@link encrypt} and {@link decrypt}.
setEncryption ( $value ) This method has been deprecated since version 3.2.1.
setEncryptionKey ( $value )
setHashAlgorithm ( $value )
setValidation ( $value ) This method has been deprecated since version 3.2.1.
setValidationKey ( $value )
validateData ( $data ) : string Validates if data is tampered.

보호된 메소드들

메소드 설명
computeHMAC ( $data ) : string Computes the HMAC for the data with {@link getValidationKey ValidationKey}.
generateRandomKey ( ) Generates a random key.
openCryptModule ( ) : resource Opens the mcrypt module with the configuration specified in {@link cryptAlgorithm}.

비공개 메소드들

메소드 설명
strlen ( string $string ) : integer Returns the length of the given string.
substr ( string $string, integer $start, integer $length ) : string Returns the portion of string specified by the start and length parameters.

메소드 상세

computeHMAC() 보호된 메소드

Computes the HMAC for the data with {@link getValidationKey ValidationKey}.
protected computeHMAC ( $data ) : string
리턴 string the HMAC for the data

decrypt() 공개 메소드

Decrypts data with {@link getEncryptionKey EncryptionKey}.
public decrypt ( $data ) : string
리턴 string the decrypted data

encrypt() 공개 메소드

Encrypts data with {@link getEncryptionKey EncryptionKey}.
public encrypt ( $data ) : string
리턴 string the encrypted data

generateRandomKey() 보호된 메소드

Generates a random key.
protected generateRandomKey ( )

getCryptAlgorithm() 공개 메소드

public getCryptAlgorithm ( ) : mixed
리턴 mixed the algorithm used to encrypt/decrypt data. Defaults to the string 'rijndael-256'.

getEncryption() 공개 메소드

Please use {@link getCryptAlgorithm()} instead.
public getEncryption ( ) : string
리턴 string the algorithm used to encrypt/decrypt data.

getEncryptionKey() 공개 메소드

public getEncryptionKey ( ) : string
리턴 string the private key used to encrypt/decrypt data. If the key is not explicitly set, a random one is generated and returned.

getHashAlgorithm() 공개 메소드

public getHashAlgorithm ( ) : string
리턴 string hashing algorithm used to generate HMAC. Defaults to 'sha1'.

getValidation() 공개 메소드

Please use {@link getHashAlgorithm()} instead.
public getValidation ( ) : string
리턴 string hashing algorithm used to generate HMAC. Defaults to 'sha1'.

getValidationKey() 공개 메소드

public getValidationKey ( ) : string
리턴 string the private key used to generate HMAC. If the key is not explicitly set, a random one is generated and returned.

hashData() 공개 메소드

Prefixes data with an HMAC.
public hashData ( $data ) : string
리턴 string data prefixed with HMAC

init() 공개 메소드

The security module is registered with the application.
public init ( $config )

openCryptModule() 보호된 메소드

Opens the mcrypt module with the configuration specified in {@link cryptAlgorithm}.
부터: 3.2.1
protected openCryptModule ( ) : resource
리턴 resource the mycrypt module handle.

setCryptAlgorithm() 공개 메소드

Sets the crypt algorithm (also known as cipher or cypher) that will be used for {@link encrypt} and {@link decrypt}.
public setCryptAlgorithm ( $value )

setEncryption() 공개 메소드

Please use {@link setCryptAlgorithm()} instead.
public setEncryption ( $value )

setEncryptionKey() 공개 메소드

public setEncryptionKey ( $value )

setHashAlgorithm() 공개 메소드

public setHashAlgorithm ( $value )

setValidation() 공개 메소드

Please use {@link setHashAlgorithm()} instead.
public setValidation ( $value )

setValidationKey() 공개 메소드

public setValidationKey ( $value )

validateData() 공개 메소드

Validates if data is tampered.
public validateData ( $data ) : string
리턴 string the real data with HMAC stripped off. False if the data is tampered.