idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
18,700
protected function _processPolicy ( PolicyInformation $ policy , ValidatorState $ state ) { $ p_oid = $ policy -> oid ( ) ; $ i = $ state -> index ( ) ; $ match_count = 0 ; foreach ( $ this -> _nodesAtDepth ( $ i - 1 ) as $ node ) { if ( $ node -> hasExpectedPolicy ( $ p_oid ) ) { $ node -> addChild ( new PolicyNode ( ...
Process single policy information .
18,701
protected function _processAnyPolicy ( PolicyInformation $ policy , Certificate $ cert , ValidatorState $ state ) { $ i = $ state -> index ( ) ; if ( ! ( $ state -> inhibitAnyPolicy ( ) > 0 || ( $ i < $ state -> pathLength ( ) && $ cert -> isSelfIssued ( ) ) ) ) { return ; } foreach ( $ this -> _nodesAtDepth ( $ i - 1 ...
Process anyPolicy policy information .
18,702
protected function _applyMappings ( Certificate $ cert , ValidatorState $ state ) { $ policy_mappings = $ cert -> tbsCertificate ( ) -> extensions ( ) -> policyMappings ( ) ; foreach ( $ policy_mappings -> flattenedMappings ( ) as $ idp => $ sdps ) { $ match_count = 0 ; foreach ( $ this -> _nodesAtDepth ( $ state -> in...
Apply policy mappings to the policy tree .
18,703
protected function _pruneTree ( int $ depth ) : int { for ( $ i = $ depth ; $ i > 0 ; -- $ i ) { foreach ( $ this -> _nodesAtDepth ( $ i ) as $ node ) { if ( ! count ( $ node ) ) { $ node -> remove ( ) ; } } } if ( ! count ( $ this -> _root ) ) { $ this -> _root = null ; return 0 ; } return $ this -> _root -> nodeCount...
Prune tree starting from given depth .
18,704
protected function _nodesAtDepth ( int $ i ) : array { if ( ! $ this -> _root ) { return array ( ) ; } $ depth = 0 ; $ nodes = array ( $ this -> _root ) ; while ( $ depth < $ i ) { $ nodes = self :: _gatherChildren ( ... $ nodes ) ; if ( ! count ( $ nodes ) ) { break ; } ++ $ depth ; } return $ nodes ; }
Get all nodes at given depth .
18,705
private static function _gatherChildren ( PolicyNode ... $ nodes ) : array { $ children = array ( ) ; foreach ( $ nodes as $ node ) { $ children = array_merge ( $ children , $ node -> children ( ) ) ; } return $ children ; }
Gather all children of given nodes to a flattened array .
18,706
public function has ( string ... $ oids ) : bool { foreach ( $ oids as $ oid ) { if ( ! in_array ( $ oid , $ this -> _purposes ) ) { return false ; } } return true ; }
Whether purposes are present .
18,707
public function create ( $ url ) { $ part = parse_url ( $ url ) ; $ appendQuery = false ; if ( isset ( $ part [ 'query' ] ) ) { $ appendQuery = true ; } $ request = $ this -> getRequest ( $ url ) ; $ token = $ this -> getToken ( $ request ) ; if ( $ appendQuery === true ) { return $ url . '&' . $ this -> getParam . '='...
Create a security token for a URL .
18,708
public function verify ( $ url = null ) { if ( $ url === null ) { $ url = $ _SERVER [ 'REQUEST_URI' ] ; } $ part = parse_url ( $ url ) ; if ( isset ( $ part [ 'query' ] ) ) { parse_str ( $ part [ 'query' ] , $ query ) ; } if ( ! isset ( $ query [ $ this -> getParam ] ) ) { return false ; } $ request = $ this -> getRequ...
Verify if a URL .
18,709
private function getRequest ( $ url ) { $ part = parse_url ( $ url ) ; if ( isset ( $ part [ 'query' ] ) ) { parse_str ( $ part [ 'query' ] , $ query ) ; if ( isset ( $ query [ $ this -> getParam ] ) ) { unset ( $ query [ $ this -> getParam ] ) ; } if ( sizeof ( $ query ) > 0 ) { $ request = $ part [ 'path' ] . http_bu...
Get the request from a string to create a security token from .
18,710
private function getToken ( $ request ) { $ hash = hash ( 'sha256' , $ request . $ this -> psl -> getUid ( ) ) ; return substr ( $ hash , 0 , 4 ) . substr ( $ hash , 16 , 4 ) . substr ( $ hash , 32 , 4 ) . substr ( $ hash , 48 , 4 ) ; }
Get a security token from a request .
18,711
public static function create ( $ length = 6 , $ num = 32 ) { $ card [ 'list' ] = array ( ) ; for ( $ i = 0 ; $ i < $ num ; $ i ++ ) { $ card [ 'list' ] [ $ i ] = phpsecRand :: str ( $ length ) ; $ card [ 'usable' ] [ $ i ] = true ; } $ card = self :: save ( $ card ) ; return $ card [ 'id' ] ; }
Create a list of 64 pre shared one - time - passwords or a so called password card .
18,712
public static function validate ( $ cardId , $ selected , $ otp ) { $ card = self :: load ( $ cardId ) ; if ( isset ( $ card [ 'usable' ] [ $ selected ] ) && $ card [ 'usable' ] [ $ selected ] === true ) { if ( $ card [ 'list' ] [ $ selected ] == $ otp ) { unset ( $ card [ 'usable' ] [ $ selected ] ) ; self :: save ( $...
Validates a pre shared one - time - password .
18,713
public static function select ( $ cardId ) { $ card = self :: load ( $ cardId ) ; $ available = array_keys ( $ card [ 'usable' ] ) ; $ selected = Rand :: int ( 0 , count ( $ available ) - 1 ) ; return $ available [ $ selected ] ; }
Select a pre shared OTP from a list that a user can use .
18,714
public static function load ( $ cardId ) { $ card = Core :: $ store -> read ( 'otp-card' , $ cardId ) ; if ( $ card !== false ) { if ( $ card [ 'hash' ] !== hash ( self :: HASH_TYPE , $ card [ 'list' ] ) ) { return false ; } $ card [ 'list' ] = json_decode ( base64_decode ( $ card [ 'list' ] ) , true ) ; return $ card ...
Load a password card .
18,715
private static function save ( $ card ) { $ card = self :: hash ( $ card ) ; if ( Core :: $ store -> write ( 'otp-card' , $ card [ 'id' ] , $ card ) ) { return $ card ; } return false ; }
Save a password card .
18,716
private static function hash ( $ card ) { $ card [ 'list' ] = base64_encode ( json_encode ( $ card [ 'list' ] ) ) ; $ card [ 'hash' ] = hash ( self :: HASH_TYPE , $ card [ 'list' ] ) ; $ card [ 'id' ] = substr ( $ card [ 'hash' ] , 0 , 12 ) ; return $ card ; }
Prepeare the password card for saving .
18,717
public function toASN1 ( ) : StringType { switch ( $ this -> _tag ) { case Element :: TYPE_IA5_STRING : return new IA5String ( $ this -> _text ) ; case Element :: TYPE_VISIBLE_STRING : return new VisibleString ( $ this -> _text ) ; case Element :: TYPE_BMP_STRING : return new BMPString ( $ this -> _text ) ; case Elemen...
Generate ASN . 1 element .
18,718
public static function fromString ( $ time , $ tz = null ) : self { return new self ( self :: _createDateTime ( $ time , $ tz ) ) ; }
Initialize from date string .
18,719
public function toASN1 ( ) : TimeType { $ dt = $ this -> _dt ; switch ( $ this -> _type ) { case Element :: TYPE_UTC_TIME : return new UTCTime ( $ dt ) ; case Element :: TYPE_GENERALIZED_TIME : if ( $ dt -> format ( "u" ) != 0 ) { $ dt = self :: _roundDownFractionalSeconds ( $ dt ) ; } return new GeneralizedTime ( $ dt...
Generate ASN . 1 .
18,720
protected static function _determineType ( \ DateTimeImmutable $ dt ) : int { if ( $ dt -> format ( "Y" ) >= 2050 ) { return Element :: TYPE_GENERALIZED_TIME ; } return Element :: TYPE_UTC_TIME ; }
Determine whether to use UTCTime or GeneralizedTime ASN . 1 type .
18,721
public function extensionName ( ) : string { if ( array_key_exists ( $ this -> _oid , self :: MAP_OID_TO_NAME ) ) { return self :: MAP_OID_TO_NAME [ $ this -> _oid ] ; } return $ this -> oid ( ) ; }
Get short name of the extension .
18,722
public static function toBitrixLevel ( $ level ) { $ levels = static :: logLevels ( ) ; if ( isset ( $ levels [ $ level ] ) ) { return $ levels [ $ level ] ; } return false ; }
Converts Monolog levels to Bitrix ones if necessary .
18,723
public static function findByExternalId ( $ externalId ) { if ( gettype ( $ externalId ) == 'string' ) { $ externalId = [ 'external_id' => $ externalId ] ; } $ response = static :: all ( $ externalId ) ; if ( is_null ( $ response ) ) { return null ; } else { return $ response -> first ( ) ; } }
Find a Customer by External ID . Returns only first result!
18,724
public static function search ( $ email , ClientInterface $ client = null ) { $ response = ( new static ( [ ] , $ client ) ) -> getClient ( ) -> setResourceKey ( static :: RESOURCE_NAME ) -> send ( '/v1/customers/search' , 'GET' , [ 'email' => $ email ] ) ; return static :: fromArray ( $ response , $ client ) ; }
Search for Customers
18,725
public function removeTags ( $ tags ) { $ result = $ this -> getClient ( ) -> send ( '/v1/customers/' . $ this -> uuid . '/attributes/tags' , 'DELETE' , [ 'tags' => func_get_args ( ) ] ) ; $ this -> attributes [ 'tags' ] = $ result [ 'tags' ] ; return $ result [ 'tags' ] ; }
Remove Tags from a Customer
18,726
public function addCustomAttributes ( $ custom ) { $ result = $ this -> getClient ( ) -> send ( '/v1/customers/' . $ this -> uuid . '/attributes/custom' , 'POST' , [ 'custom' => func_get_args ( ) ] ) ; $ this -> attributes [ 'custom' ] = $ result [ 'custom' ] ; return $ result [ 'custom' ] ; }
Add Custom Attributes to a Customer
18,727
public function updateCustomAttributes ( $ custom ) { $ data = [ ] ; foreach ( func_get_args ( ) as $ value ) { $ data = array_merge ( $ data , $ value ) ; } $ result = $ this -> getClient ( ) -> send ( '/v1/customers/' . $ this -> uuid . '/attributes/custom' , 'PUT' , [ 'custom' => $ data ] ) ; $ this -> attributes [ ...
Update Custom Attributes of a Customer
18,728
public function subscriptions ( array $ options = [ ] ) { if ( ! isset ( $ this -> subscriptions ) ) { $ options [ 'customer_uuid' ] = $ this -> uuid ; $ this -> subscriptions = Subscription :: all ( $ options ) ; } return $ this -> subscriptions ; }
Find a Customer Subscriptions
18,729
public function invoices ( array $ options = [ ] ) { if ( ! isset ( $ this -> invoices ) ) { $ options [ 'customer_uuid' ] = $ this -> uuid ; $ this -> invoices = CustomerInvoices :: all ( $ options ) -> invoices ; } return $ this -> invoices ; }
Find customer s invoices
18,730
public function withBaseCertificateID ( IssuerSerial $ issuer ) : self { $ obj = clone $ this ; $ obj -> _baseCertificateID = $ issuer ; return $ obj ; }
Get self with base certificate ID .
18,731
public function withEntityName ( GeneralNames $ names ) : self { $ obj = clone $ this ; $ obj -> _entityName = $ names ; return $ obj ; }
Get self with entity name .
18,732
public function withObjectDigestInfo ( ObjectDigestInfo $ odi ) : self { $ obj = clone $ this ; $ obj -> _objectDigestInfo = $ odi ; return $ obj ; }
Get self with object digest info .
18,733
public function identifiesPKC ( Certificate $ cert ) : bool { if ( ! $ this -> _baseCertificateID && ! $ this -> _entityName ) { return false ; } if ( $ this -> _baseCertificateID && ! $ this -> _baseCertificateID -> identifiesPKC ( $ cert ) ) { return false ; } if ( $ this -> _entityName && ! $ this -> _checkEntityNam...
Check whether Holder identifies given certificate .
18,734
private function _checkEntityName ( Certificate $ cert ) : bool { $ name = $ this -> _entityName -> firstDN ( ) ; if ( $ cert -> tbsCertificate ( ) -> subject ( ) -> equals ( $ name ) ) { return true ; } $ exts = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ exts -> hasSubjectAlternativeName ( ) ) { $ ext = $...
Check whether entityName matches the given certificate .
18,735
private function _checkEntityAlternativeNames ( GeneralNames $ san ) : bool { $ name = $ this -> _entityName -> firstDN ( ) ; foreach ( $ san -> allOf ( GeneralName :: TAG_DIRECTORY_NAME ) as $ dn ) { if ( $ dn instanceof DirectoryName && $ dn -> dn ( ) -> equals ( $ name ) ) { return true ; } } return false ; }
Check whether any of the subject alternative names match entityName .
18,736
public function withEvaluationTime ( \ DateTimeImmutable $ dt ) : self { $ obj = clone $ this ; $ obj -> _evalTime = $ dt ; return $ obj ; }
Get self with given evaluation reference time .
18,737
public function withTargets ( Target ... $ targets ) : self { $ obj = clone $ this ; $ obj -> _targets = $ targets ; return $ obj ; }
Get self with permitted targets .
18,738
public function userNew ( $ email , $ cellphone , $ countrycode = 1 ) { $ data = array ( 'user[email]' => $ email , 'user[cellphone]' => $ cellphone , 'user[country_code]' => $ countrycode , ) ; $ result = $ this -> apiCall ( 'new' , $ data ) ; if ( $ result === false ) { $ this -> lastError = 'AUTHY_SERVER_ERROR' ; re...
Add a new Authy user and get the Authy ID .
18,739
public function verify ( $ authyId , $ token ) { $ data = array ( 'token' => $ token , 'authy_id' => $ authyId , ) ; $ result = $ this -> apiCall ( 'verify' , $ data ) ; if ( $ result === false ) { $ this -> lastError = 'AUTHY_SERVER_ERROR' ; return false ; } if ( isset ( $ result -> errors ) ) { if ( isset ( $ result ...
Verify a Authy OTP .
18,740
public function requestSms ( $ authyId , $ force = false ) { $ data = array ( 'authy_id' => $ authyId , 'force' => $ force , ) ; $ result = $ this -> apiCall ( 'sms' , $ data ) ; if ( $ result === false ) { $ this -> lastError = 'AUTHY_SERVER_ERROR' ; return false ; } if ( isset ( $ result -> errors ) ) { $ this -> las...
Request SMS token .
18,741
private function apiCall ( $ action , $ data ) { switch ( $ this -> _sandbox ) { case true : $ url = $ this -> _servers [ 'sandbox' ] ; break ; default : $ url = $ this -> _servers [ 'production' ] ; } switch ( $ action ) { case 'new' : $ url = $ url . '/protected/json/users/new?api_key=' . $ this -> _apiKey ; $ postDa...
Performs a call to the Authy API .
18,742
public function allPathsToTarget ( Certificate $ target , CertificateBundle $ intermediate = null ) : array { $ paths = $ this -> _resolvePathsToTarget ( $ target , $ intermediate ) ; return array_map ( function ( $ certs ) { return new CertificationPath ( ... $ certs ) ; } , $ paths ) ; }
Get all certification paths to given target certificate from any trust anchor .
18,743
private function _resolvePathsToTarget ( Certificate $ target , CertificateBundle $ intermediate = null ) : array { $ paths = array ( ) ; foreach ( $ this -> _findIssuers ( $ target , $ this -> _trustList ) as $ issuer ) { if ( $ target -> equals ( $ issuer ) ) { $ paths [ ] = array ( $ target ) ; } else { $ paths [ ] ...
Resolve all possible certification paths from any trust anchor to the target certificate using optional intermediate certificates .
18,744
protected function _findIssuers ( Certificate $ target , CertificateBundle $ bundle ) : array { $ issuers = array ( ) ; $ issuer_name = $ target -> tbsCertificate ( ) -> issuer ( ) ; $ extensions = $ target -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasAuthorityKeyIdentifier ( ) ) { $ ext = $ extens...
Find all issuers of the target certificate from a given bundle .
18,745
protected function _findFirst ( string $ name ) { $ oid = AttributeType :: attrNameToOID ( $ name ) ; foreach ( $ this -> _attributes as $ attr ) { if ( $ attr -> oid ( ) == $ oid ) { return $ attr ; } } return null ; }
Find first attribute of given name or OID .
18,746
public function firstOf ( string $ name ) : Attribute { $ attr = $ this -> _findFirst ( $ name ) ; if ( ! $ attr ) { throw new \ UnexpectedValueException ( "No $name attribute." ) ; } return $ attr ; }
Get first attribute by OID or attribute name .
18,747
public function allOf ( string $ name ) : array { $ oid = AttributeType :: attrNameToOID ( $ name ) ; $ attrs = array_filter ( $ this -> _attributes , function ( Attribute $ attr ) use ( $ oid ) { return $ attr -> oid ( ) == $ oid ; } ) ; return array_values ( $ attrs ) ; }
Get all attributes of given name .
18,748
public function withAdditional ( Attribute ... $ attribs ) : self { $ obj = clone $ this ; foreach ( $ attribs as $ attr ) { $ obj -> _attributes [ ] = $ attr ; } return $ obj ; }
Get self with additional attributes added .
18,749
public function withUnique ( Attribute $ attr ) : self { $ obj = clone $ this ; $ obj -> _attributes = array_filter ( $ obj -> _attributes , function ( Attribute $ a ) use ( $ attr ) { return $ a -> oid ( ) != $ attr -> oid ( ) ; } ) ; $ obj -> _attributes [ ] = $ attr ; return $ obj ; }
Get self with single unique attribute added .
18,750
private function _processCertificate ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ this -> _verifySignature ( $ state , $ cert ) ; $ this -> _checkValidity ( $ cert ) ; $ this -> _checkRevocation ( $ cert ) ; $ this -> _checkIssuer ( $ state , $ cert ) ; if ( ! ( $ cert -> isSelfIssued ( ) && ! $...
Apply basic certificate processing according to RFC 5280 section 6 . 1 . 3 .
18,751
private function _prepareNext ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ state = $ this -> _preparePolicyMappings ( $ state , $ cert ) ; $ state = $ state -> withWorkingIssuerName ( $ cert -> tbsCertificate ( ) -> subject ( ) ) ; $ state = $ this -> _setPublicKeyState ( $ state , $ cert ) ; $ ...
Apply preparation for the certificate i + 1 according to rfc5280 section 6 . 1 . 4 .
18,752
private function _wrapUp ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ tbs_cert = $ cert -> tbsCertificate ( ) ; $ extensions = $ tbs_cert -> extensions ( ) ; if ( $ state -> explicitPolicy ( ) > 0 ) { $ state = $ state -> withExplicitPolicy ( $ state -> explicitPolicy ( ) - 1 ) ; } if ( $ extens...
Apply wrap - up procedure according to RFC 5280 section 6 . 1 . 5 .
18,753
private function _setPublicKeyState ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ pk_info = $ cert -> tbsCertificate ( ) -> subjectPublicKeyInfo ( ) ; $ state = $ state -> withWorkingPublicKey ( $ pk_info ) ; $ params = ValidatorState :: getAlgorithmParameters ( $ pk_info -> algorithmIdentifier (...
Update working_public_key working_public_key_parameters and working_public_key_algorithm state variables from certificate .
18,754
private function _verifySignature ( ValidatorState $ state , Certificate $ cert ) { try { $ valid = $ cert -> verify ( $ state -> workingPublicKey ( ) , $ this -> _crypto ) ; } catch ( \ RuntimeException $ e ) { throw new PathValidationException ( "Failed to verify signature: " . $ e -> getMessage ( ) , 0 , $ e ) ; } i...
Verify certificate signature .
18,755
private function _checkValidity ( Certificate $ cert ) { $ refdt = $ this -> _config -> dateTime ( ) ; $ validity = $ cert -> tbsCertificate ( ) -> validity ( ) ; if ( $ validity -> notBefore ( ) -> dateTime ( ) -> diff ( $ refdt ) -> invert ) { throw new PathValidationException ( "Certificate validity period has not s...
Check certificate validity .
18,756
private function _checkIssuer ( ValidatorState $ state , Certificate $ cert ) { if ( ! $ cert -> tbsCertificate ( ) -> issuer ( ) -> equals ( $ state -> workingIssuerName ( ) ) ) { throw new PathValidationException ( "Certification issuer mismatch." ) ; } }
Check certificate issuer .
18,757
private function _preparePolicyMappings ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasPolicyMappings ( ) ) { if ( $ extensions -> policyMappings ( ) -> hasAnyPolicyMapping ( ) ) { throw new PathValidationExcepti...
Apply policy mappings handling for the preparation step .
18,758
private function _prepareNameConstraints ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasNameConstraints ( ) ) { $ state = $ this -> _processNameConstraints ( $ state , $ cert ) ; } return $ state ; }
Apply name constraints handling for the preparation step .
18,759
private function _prepareNonSelfIssued ( ValidatorState $ state ) : ValidatorState { if ( $ state -> explicitPolicy ( ) > 0 ) { $ state = $ state -> withExplicitPolicy ( $ state -> explicitPolicy ( ) - 1 ) ; } if ( $ state -> policyMapping ( ) > 0 ) { $ state = $ state -> withPolicyMapping ( $ state -> policyMapping ( ...
Apply preparation for a non - self - signed certificate .
18,760
private function _preparePolicyConstraints ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( ! $ extensions -> hasPolicyConstraints ( ) ) { return $ state ; } $ ext = $ extensions -> policyConstraints ( ) ; if ( $ ext -> hasRequireExp...
Apply policy constraints handling for the preparation step .
18,761
private function _prepareInhibitAnyPolicy ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasInhibitAnyPolicy ( ) ) { $ ext = $ extensions -> inhibitAnyPolicy ( ) ; if ( $ ext -> skipCerts ( ) < $ state -> inhibitAny...
Apply inhibit any - policy handling for the preparation step .
18,762
private function _verifyMaxPathLength ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { if ( ! $ cert -> isSelfIssued ( ) ) { if ( $ state -> maxPathLength ( ) <= 0 ) { throw new PathValidationException ( "Certification path length exceeded." ) ; } $ state = $ state -> withMaxPathLength ( $ state -> ma...
Verify maximum certification path length for the preparation step .
18,763
private function _checkKeyUsage ( Certificate $ cert ) { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasKeyUsage ( ) ) { $ ext = $ extensions -> keyUsage ( ) ; if ( ! $ ext -> isKeyCertSign ( ) ) { throw new PathValidationException ( "keyCertSign usage not set." ) ; } } }
Check key usage extension for the preparation step .
18,764
private function _processBasicContraints ( Certificate $ cert ) { if ( $ cert -> tbsCertificate ( ) -> version ( ) == TBSCertificate :: VERSION_3 ) { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( ! $ extensions -> hasBasicConstraints ( ) ) { throw new PathValidationException ( "v3 certificate mus...
Process basic constraints extension .
18,765
private function _processPathLengthContraint ( ValidatorState $ state , Certificate $ cert ) : ValidatorState { $ extensions = $ cert -> tbsCertificate ( ) -> extensions ( ) ; if ( $ extensions -> hasBasicConstraints ( ) ) { $ ext = $ extensions -> basicConstraints ( ) ; if ( $ ext -> hasPathLen ( ) ) { if ( $ ext -> p...
Process pathLenConstraint .
18,766
public static function retrieve ( $ uuid , ClientInterface $ client = null ) { return ( new RequestService ( $ client ) ) -> setResourceClass ( static :: class ) -> get ( $ uuid ) ; }
Get a single resource by UUID .
18,767
public function enable ( ) { if ( $ this -> detectHttps ( ) === true ) { header ( 'Strict-Transport-Security: max-age=' . $ this -> maxAge ) ; } else { header ( 'Location: https://' . $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] , true , 301 ) ; die ( ) ; } }
Enables HSTS .
18,768
public static function fromASN1 ( TaggedType $ el ) : self { switch ( $ el -> tag ( ) ) { case self :: TYPE_NAME : return TargetName :: fromChosenASN1 ( $ el -> asExplicit ( ) -> asTagged ( ) ) ; case self :: TYPE_GROUP : return TargetGroup :: fromChosenASN1 ( $ el -> asExplicit ( ) -> asTagged ( ) ) ; case self :: TYP...
Parse from ASN . 1 .
18,769
public function equals ( Target $ other ) : bool { if ( $ this -> _type != $ other -> _type ) { return false ; } if ( $ this -> toASN1 ( ) -> toDER ( ) != $ other -> toASN1 ( ) -> toDER ( ) ) { return false ; } return true ; }
Check whether target is equal to another .
18,770
public static function loadConfiguration ( $ force = false ) { if ( $ force === false && static :: $ isConfigurationLoaded === true ) { return true ; } if ( class_exists ( '\Bitrix\Main\Config\Configuration' ) ) { $ config = Configuration :: getInstance ( ) -> get ( 'monolog' ) ; if ( is_array ( $ config ) && ! empty (...
Load a configuration for the loggers from . settings . php or . settings_extra . php .
18,771
public static function all ( array $ options = [ ] , ClientInterface $ client = null ) { return Metrics \ AllKeyMetrics :: all ( $ options , $ client ) ; }
Retrieves all key metrics for the specified time period .
18,772
public static function customerChurnRate ( array $ options = [ ] , ClientInterface $ client = null ) { return Metrics \ CustomerChurnRates :: all ( $ options , $ client ) ; }
Retrieves the Customer Churn Rate for the specified time period .
18,773
public static function customerCount ( array $ options = [ ] , ClientInterface $ client = null ) { return Metrics \ CustomerCounts :: all ( $ options , $ client ) ; }
Retrieves the number of active customers for the specified time period .
18,774
public static function mrrChurnRate ( array $ options = [ ] , ClientInterface $ client = null ) { return Metrics \ MRRChurnRates :: all ( $ options , $ client ) ; }
Retrieves the Net MRR Churn Rate for the specified time period .
18,775
public function verify ( $ otp ) { $ rand = $ this -> psl [ 'crypt/rand' ] ; if ( $ this -> clientId === null || $ this -> clientSecret === null ) { $ this -> lastError = 'YUBIKEY_CLIENT_DATA_NEEDED' ; return false ; } if ( ! self :: validOtp ( $ otp ) ) { $ this -> lastError = 'YUBIKEY_INVALID_OTP' ; return false ; } ...
Verify Yubikey one time password against the Yubico servers .
18,776
public function sign ( $ data ) { unset ( $ data [ 'h' ] ) ; ksort ( $ data ) ; $ n = count ( $ data ) ; $ query = '' ; $ i = 0 ; while ( list ( $ key , $ val ) = each ( $ data ) ) { $ i ++ ; $ query .= $ key . '=' . $ val ; if ( $ i < $ n ) { $ query .= '&' ; } } $ sign = hash_hmac ( 'sha1' , utf8_encode ( $ query ) ,...
Sign data using shared secret .
18,777
private function getResponse ( $ data ) { $ query = http_build_query ( $ data ) ; $ opts = array ( 'http' => array ( 'method' => 'GET' , 'timeout' => $ this -> _serverTimeout , 'header' => "Accept-language: en\r\n" . "User-Agent: phpSec (http://phpseclib.com)\r\n" ) ) ; $ context = stream_context_create ( $ opts ) ; $ ...
Make a request to the Yubico servers and get the response .
18,778
public function validOtp ( $ otp ) { $ length = strlen ( $ otp ) ; if ( $ length > 48 || $ length < 32 ) { return false ; } return ctype_graph ( $ otp ) ; }
Validate a string as a one - time - password . A valid OTP should consist of 32 - 48 printable characters .
18,779
public function getYubikeyId ( $ otp ) { if ( ! $ this -> validOtp ( $ otp ) ) { return false ; } $ idLen = strlen ( $ otp ) - 32 ; return substr ( $ otp , 0 , $ idLen ) ; }
Get the identity of a Yubikey OTP . The identity part is the same for every OTP and it is the initial 2 - 16 modhex characters of the OTP . Since the rest of the OTP is always 32 characters the method to extract the identity is to remove 32 characters from the end and then use the remaining string which should be 2 - 1...
18,780
protected static function _wordsToIPv6String ( array $ words ) : string { $ groups = array_map ( function ( $ word ) { return sprintf ( "%04x" , $ word ) ; } , $ words ) ; return implode ( ":" , $ groups ) ; }
Convert an array of 16 bit words to an IPv6 string representation .
18,781
public static function create ( array $ data = [ ] , ClientInterface $ client = null ) { return ( new RequestService ( $ client ) ) -> setResourceClass ( static :: class ) -> create ( $ data ) ; }
Create a Resource
18,782
public function equals ( Certificate $ cert ) : bool { return $ this -> _hasEqualSerialNumber ( $ cert ) && $ this -> _hasEqualPublicKey ( $ cert ) && $ this -> _hasEqualSubject ( $ cert ) ; }
Check whether certificate is semantically equal to another .
18,783
private function _hasEqualSerialNumber ( Certificate $ cert ) : bool { $ sn1 = $ this -> _tbsCertificate -> serialNumber ( ) ; $ sn2 = $ cert -> _tbsCertificate -> serialNumber ( ) ; return $ sn1 == $ sn2 ; }
Check whether certificate has serial number equal to another .
18,784
private function _hasEqualPublicKey ( Certificate $ cert ) : bool { $ kid1 = $ this -> _tbsCertificate -> subjectPublicKeyInfo ( ) -> keyIdentifier ( ) ; $ kid2 = $ cert -> _tbsCertificate -> subjectPublicKeyInfo ( ) -> keyIdentifier ( ) ; return $ kid1 == $ kid2 ; }
Check whether certificate has public key equal to another .
18,785
private function _hasEqualSubject ( Certificate $ cert ) : bool { $ dn1 = $ this -> _tbsCertificate -> subject ( ) ; $ dn2 = $ cert -> _tbsCertificate -> subject ( ) ; return $ dn1 -> equals ( $ dn2 ) ; }
Check whether certificate has subject equal to another .
18,786
public function extensionRequest ( ) : ExtensionRequestValue { if ( ! $ this -> hasExtensionRequest ( ) ) { throw new \ LogicException ( "No extension request attribute." ) ; } return $ this -> firstOf ( ExtensionRequestValue :: OID ) -> first ( ) ; }
Get extension request attribute value .
18,787
public function equals ( GeneralName $ other ) : bool { if ( $ this -> _tag != $ other -> _tag ) { return false ; } if ( $ this -> _choiceASN1 ( ) -> toDER ( ) != $ other -> _choiceASN1 ( ) -> toDER ( ) ) { return false ; } return true ; }
Check whether GeneralName is equal to other .
18,788
protected function _findFirst ( int $ tag ) { foreach ( $ this -> _names as $ name ) { if ( $ name -> tag ( ) == $ tag ) { return $ name ; } } return null ; }
Find first GeneralName by given tag .
18,789
public function firstOf ( int $ tag ) : GeneralName { $ name = $ this -> _findFirst ( $ tag ) ; if ( ! $ name ) { throw new \ UnexpectedValueException ( "No GeneralName by tag $tag." ) ; } return $ name ; }
Get first GeneralName of given type .
18,790
public function allOf ( int $ tag ) : array { $ names = array_filter ( $ this -> _names , function ( GeneralName $ name ) use ( $ tag ) { return $ name -> tag ( ) == $ tag ; } ) ; return array_values ( $ names ) ; }
Get all GeneralName objects of given type .
18,791
public function firstDNS ( ) : string { $ gn = $ this -> firstOf ( GeneralName :: TAG_DNS_NAME ) ; if ( ! $ gn instanceof DNSName ) { throw new \ RuntimeException ( DNSName :: class . " expected, got " . get_class ( $ gn ) ) ; } return $ gn -> name ( ) ; }
Get value of the first dNSName type .
18,792
public function firstDN ( ) : Name { $ gn = $ this -> firstOf ( GeneralName :: TAG_DIRECTORY_NAME ) ; if ( ! $ gn instanceof DirectoryName ) { throw new \ RuntimeException ( DirectoryName :: class . " expected, got " . get_class ( $ gn ) ) ; } return $ gn -> dn ( ) ; }
Get value of the first directoryName type .
18,793
public function firstURI ( ) : string { $ gn = $ this -> firstOf ( GeneralName :: TAG_URI ) ; if ( ! $ gn instanceof UniformResourceIdentifier ) { throw new \ RuntimeException ( UniformResourceIdentifier :: class . " expected, got " . get_class ( $ gn ) ) ; } return $ gn -> uri ( ) ; }
Get value of the first uniformResourceIdentifier type .
18,794
public function cacheGet ( $ name ) { $ this -> cacheGc ( ) ; try { $ data = $ this -> store -> read ( 'cache' , $ this -> cacheId ( $ name ) ) ; } catch ( \ phpSec \ Exception $ e ) { return false ; } if ( $ data == ! false ) { if ( $ data [ 'ttl' ] > time ( ) ) { return unserialize ( $ data [ 'data' ] ) ; } $ this ->...
Get data from the cache .
18,795
private function cacheGc ( ) { $ probMax = 1 / self :: GC_PROB ; $ do = rand ( 1 , $ probMax ) ; if ( $ do > 1 ) { return false ; } $ cahceIds = $ this -> store -> listIds ( 'cache' ) ; foreach ( $ cahceIds as $ cahceId ) { try { $ data = $ this -> store -> read ( 'cache' , $ cahceId ) ; } catch ( \ phpSec \ Exception ...
Do garbage collection on cached data .
18,796
public function validate ( $ otp , $ action , $ uid = null , $ data = null ) { $ hash = $ this -> psl [ 'crypt/hash' ] ; $ store = $ this -> psl [ 'store' ] ; if ( $ uid === null ) { $ uid = $ this -> psl -> getUid ( ) ; } $ storeData = $ store -> read ( 'otp' , $ this -> storeId ( $ uid , $ action ) ) ; if ( $ storeDa...
Validate a one - time - password .
18,797
public function get ( string $ oid ) : PolicyInformation { if ( ! $ this -> has ( $ oid ) ) { throw new \ LogicException ( "Not certificate policy by OID $oid." ) ; } return $ this -> _policies [ $ oid ] ; }
Get policy information by OID .
18,798
public function set ( $ name , $ ttl = 3600 ) { $ rand = $ this -> psl [ 'crypt/rand' ] ; $ cache = $ this -> psl [ 'cache' ] ; $ token = $ rand -> str ( 32 , $ this -> _charset ) ; $ cache -> cacheSet ( 'token-' . $ name , $ token , $ ttl ) ; return $ token ; }
Generate and save a one - time - token for a form . Used to protect against CSRF attacks .
18,799
public static function initialize ( PathValidationConfig $ config , Certificate $ trust_anchor , $ n ) { $ state = new self ( ) ; $ state -> _pathLength = $ n ; $ state -> _index = 1 ; $ state -> _validPolicyTree = new PolicyTree ( PolicyNode :: anyPolicyNode ( ) ) ; $ state -> _permittedSubtrees = null ; $ state -> _e...
Initialize variables according to RFC 5280 6 . 1 . 2 .