idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
34,800 | private static function ipBetween ( $ version , $ ip , $ low , $ high ) { if ( 4 === $ version ) { if ( $ low <= $ ip ) { if ( $ ip < $ high ) { return 0 ; } else { return 1 ; } } else { return - 1 ; } } else { if ( bccomp ( $ low , $ ip , 0 ) <= 0 ) { if ( bccomp ( $ ip , $ high , 0 ) <= - 1 ) { return 0 ; } else { re... | Determine whether the given IP number of the given version lies between the given bounds |
34,801 | private static function ipVersionAndNumber ( $ ip ) { if ( filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { return [ 4 , sprintf ( '%u' , ip2long ( $ ip ) ) ] ; } elseif ( filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) { $ result = 0 ; foreach ( str_split ( bin2hex ( inet_pton ( $ ip ) ) ,... | Get the IP version and number of the given IP address |
34,802 | private static function bcBin2Dec ( $ data ) { $ parts = array ( unpack ( 'V' , substr ( $ data , 12 , 4 ) ) , unpack ( 'V' , substr ( $ data , 8 , 4 ) ) , unpack ( 'V' , substr ( $ data , 4 , 4 ) ) , unpack ( 'V' , substr ( $ data , 0 , 4 ) ) , ) ; foreach ( $ parts as & $ part ) if ( $ part [ 1 ] < 0 ) $ part [ 1 ] +... | Return the decimal string representing the binary data given |
34,803 | private function read ( $ pos , $ len ) { switch ( $ this -> mode ) { case self :: SHARED_MEMORY : return shmop_read ( $ this -> resource , $ pos , $ len ) ; case self :: MEMORY_CACHE : return $ data = substr ( self :: $ buffer [ $ this -> resource ] , $ pos , $ len ) ; default : fseek ( $ this -> resource , $ pos , SE... | Low level read function to abstract away the caching mode being used |
34,804 | private function readString ( $ pos , $ additional = 0 ) { $ spos = $ this -> readWord ( $ pos ) + $ additional ; return $ this -> read ( $ spos + 1 , $ this -> readByte ( $ spos + 1 ) ) ; } | Low level function to fetch a string from the caching backend |
34,805 | private function readCountryNameAndCode ( $ pointer ) { if ( false === $ pointer ) { $ countryCode = self :: INVALID_IP_ADDRESS ; $ countryName = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: COUNTRY_CODE ] [ $ this -> type ] ) { $ countryCode = self :: FIELD_NOT_SUPPORTED ; $ countryName = ... | High level function to fetch the country name and code |
34,806 | private function readRegionName ( $ pointer ) { if ( false === $ pointer ) { $ regionName = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: REGION_NAME ] [ $ this -> type ] ) { $ regionName = self :: FIELD_NOT_SUPPORTED ; } else { $ regionName = $ this -> readString ( $ pointer + self :: $ col... | High level function to fetch the region name |
34,807 | private function readCityName ( $ pointer ) { if ( false === $ pointer ) { $ cityName = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: CITY_NAME ] [ $ this -> type ] ) { $ cityName = self :: FIELD_NOT_SUPPORTED ; } else { $ cityName = $ this -> readString ( $ pointer + self :: $ columns [ sel... | High level function to fetch the city name |
34,808 | private function readLatitudeAndLongitude ( $ pointer ) { if ( false === $ pointer ) { $ latitude = self :: INVALID_IP_ADDRESS ; $ longitude = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: LATITUDE ] [ $ this -> type ] ) { $ latitude = self :: FIELD_NOT_SUPPORTED ; $ longitude = self :: FIEL... | High level function to fetch the latitude and longitude |
34,809 | private function readIsp ( $ pointer ) { if ( false === $ pointer ) { $ isp = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: ISP ] [ $ this -> type ] ) { $ isp = self :: FIELD_NOT_SUPPORTED ; } else { $ isp = $ this -> readString ( $ pointer + self :: $ columns [ self :: ISP ] [ $ this -> typ... | High level function to fetch the ISP name |
34,810 | private function readDomainName ( $ pointer ) { if ( false === $ pointer ) { $ domainName = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: DOMAIN_NAME ] [ $ this -> type ] ) { $ domainName = self :: FIELD_NOT_SUPPORTED ; } else { $ domainName = $ this -> readString ( $ pointer + self :: $ col... | High level function to fetch the domain name |
34,811 | private function readZipCode ( $ pointer ) { if ( false === $ pointer ) { $ zipCode = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: ZIP_CODE ] [ $ this -> type ] ) { $ zipCode = self :: FIELD_NOT_SUPPORTED ; } else { $ zipCode = $ this -> readString ( $ pointer + self :: $ columns [ self :: ... | High level function to fetch the zip code |
34,812 | private function readTimeZone ( $ pointer ) { if ( false === $ pointer ) { $ timeZone = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: TIME_ZONE ] [ $ this -> type ] ) { $ timeZone = self :: FIELD_NOT_SUPPORTED ; } else { $ timeZone = $ this -> readString ( $ pointer + self :: $ columns [ sel... | High level function to fetch the time zone |
34,813 | private function readNetSpeed ( $ pointer ) { if ( false === $ pointer ) { $ netSpeed = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: NET_SPEED ] [ $ this -> type ] ) { $ netSpeed = self :: FIELD_NOT_SUPPORTED ; } else { $ netSpeed = $ this -> readString ( $ pointer + self :: $ columns [ sel... | High level function to fetch the net speed |
34,814 | private function readIddAndAreaCodes ( $ pointer ) { if ( false === $ pointer ) { $ iddCode = self :: INVALID_IP_ADDRESS ; $ areaCode = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: IDD_CODE ] [ $ this -> type ] ) { $ iddCode = self :: FIELD_NOT_SUPPORTED ; $ areaCode = self :: FIELD_NOT_SUP... | High level function to fetch the IDD and area codes |
34,815 | private function readWeatherStationNameAndCode ( $ pointer ) { if ( false === $ pointer ) { $ weatherStationName = self :: INVALID_IP_ADDRESS ; $ weatherStationCode = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: WEATHER_STATION_NAME ] [ $ this -> type ] ) { $ weatherStationName = self :: FI... | High level function to fetch the weather station name and code |
34,816 | private function readMccMncAndMobileCarrierName ( $ pointer ) { if ( false === $ pointer ) { $ mcc = self :: INVALID_IP_ADDRESS ; $ mnc = self :: INVALID_IP_ADDRESS ; $ mobileCarrierName = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: MCC ] [ $ this -> type ] ) { $ mcc = self :: FIELD_NOT_SU... | High level function to fetch the MCC MNC and mobile carrier name |
34,817 | private function readElevation ( $ pointer ) { if ( false === $ pointer ) { $ elevation = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: ELEVATION ] [ $ this -> type ] ) { $ elevation = self :: FIELD_NOT_SUPPORTED ; } else { $ elevation = $ this -> readString ( $ pointer + self :: $ columns [... | High level function to fetch the elevation |
34,818 | private function readUsageType ( $ pointer ) { if ( false === $ pointer ) { $ usageType = self :: INVALID_IP_ADDRESS ; } elseif ( 0 === self :: $ columns [ self :: USAGE_TYPE ] [ $ this -> type ] ) { $ usageType = self :: FIELD_NOT_SUPPORTED ; } else { $ usageType = $ this -> readString ( $ pointer + self :: $ columns ... | High level function to fetch the usage type |
34,819 | private function readIp ( $ version , $ pos ) { if ( 4 === $ version ) { return self :: wrap32 ( $ this -> readWord ( $ pos ) ) ; } elseif ( 6 === $ version ) { return $ this -> readQuad ( $ pos ) ; } else { return false ; } } | High level fucntion to read an IP address of the given version |
34,820 | private function binSearch ( $ version , $ ipNumber , $ cidr = false ) { if ( false === $ version ) { return false ; } $ base = $ this -> ipBase [ $ version ] ; $ offset = $ this -> offset [ $ version ] ; $ width = $ this -> columnWidth [ $ version ] ; $ high = $ this -> ipCount [ $ version ] ; $ low = 0 ; $ indexBaseS... | Perform a binary search on the given IP number and return a pointer to its record |
34,821 | public function getFields ( $ asNames = false ) { $ result = array_keys ( array_filter ( self :: $ columns , function ( $ field ) { return 0 !== $ field [ $ this -> type ] ; } ) ) ; if ( $ asNames ) { $ return = [ ] ; foreach ( $ result as $ field ) { $ return [ ] = self :: $ names [ $ field ] ; } return $ return ; } e... | Return this database s available fields |
34,822 | public function get_cidr ( $ ip ) { list ( $ ipVersion , $ ipNumber ) = self :: ipVersionAndNumber ( $ ip ) ; $ resp = $ this -> binSearch ( $ ipVersion , $ ipNumber , true ) ; if ( ! empty ( $ resp ) ) { list ( $ ip_from , $ ip_to ) = $ resp ; $ i = 32 ; $ mask = 1 ; while ( ( $ ip_to & $ mask ) == 0 ) { $ mask *= 2 ;... | For a given IP address returns the cidr of his sub - network . |
34,823 | public function decryptResponse ( $ response ) { if ( ! is_string ( $ response ) ) { return $ response ; } if ( $ this -> usesEncryption ( ) ) { return json_decode ( json_encode ( JWT :: decode ( $ response , $ this -> encryptionKey , array ( $ this -> encryptionAlgorithm ) ) ) , true ) ; } throw EncryptionConfiguratio... | Attempts to decrypt the given response . |
34,824 | public function getLogoutUrl ( array $ options = [ ] ) { $ base = $ this -> getBaseLogoutUrl ( ) ; $ params = $ this -> getAuthorizationParameters ( $ options ) ; $ query = $ this -> getAuthorizationQuery ( $ params ) ; return $ this -> appendQuery ( $ base , $ query ) ; } | Builds the logout URL . |
34,825 | public function onCommandAfterPrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; $ bucket = $ command [ 'Bucket' ] ; $ request = $ command -> getRequest ( ) ; if ( $ command -> getName ( ) == 'ListBuckets' ) { if ( $ this -> ipport != null ) { $ request -> setHost ( $ this -> ipport ) ; $ request -> setHea... | Change from path style to host style . |
34,826 | protected function parseHeaders ( RequestInterface $ request , Response $ response , array & $ data ) { $ data [ 'message' ] = $ response -> getStatusCode ( ) . ' ' . $ response -> getReasonPhrase ( ) ; if ( $ requestId = $ response -> getHeader ( 'x-cos-request-id' ) ) { $ data [ 'request_id' ] = $ requestId ; $ data ... | Parses additional exception information from the response headers |
34,827 | public function onCommandBeforePrepare ( Event $ event ) { $ command = $ event [ 'command' ] ; if ( in_array ( $ command -> getName ( ) , $ this -> commands ) ) { $ source = $ command -> get ( $ this -> sourceParameter ) ; $ body = $ command -> get ( $ this -> bodyParameter ) ; if ( is_string ( $ source ) && file_exist... | Converts filenames and file handles into EntityBody objects before the command is validated |
34,828 | public function onRequestBeforeSend ( Event $ event ) { if ( $ this -> token != null ) { $ event [ 'request' ] -> setHeader ( 'x-cos-security-token' , $ this -> token ) ; } } | Signs requests before they are sent |
34,829 | public function handle ( Exception $ exception , ServerRequestInterface $ request , ResponseInterface $ response , array $ options = [ ] ) { $ options += $ this -> defaultOptions ; if ( ! $ this -> checkException ( $ exception , $ options [ 'exceptions' ] ) ) { throw $ exception ; } $ url = $ this -> getUrl ( $ request... | Return a response with a location header set if an exception matches . |
34,830 | protected function getUrl ( ServerRequestInterface $ request , array $ options ) { $ url = $ options [ 'url' ] ; if ( $ options [ 'queryParam' ] !== null && $ request -> getMethod ( ) === 'GET' ) { $ query = urlencode ( $ options [ 'queryParam' ] ) . '=' . urlencode ( $ request -> getRequestTarget ( ) ) ; if ( strpos (... | Returns the url for the Location header . |
34,831 | public function skipAuthorization ( ) { $ request = $ this -> getController ( ) -> request ; $ service = $ this -> getService ( $ request ) ; $ service -> skipAuthorization ( ) ; return $ this ; } | Skips the authorization check . |
34,832 | protected function getService ( ServerRequestInterface $ request ) { $ serviceAttribute = $ this -> getConfig ( 'serviceAttribute' ) ; $ service = $ request -> getAttribute ( $ serviceAttribute ) ; if ( ! $ service instanceof AuthorizationServiceInterface ) { $ type = is_object ( $ service ) ? get_class ( $ service ) :... | Get the authorization service from a request . |
34,833 | protected function getIdentity ( ServerRequestInterface $ request ) { $ identityAttribute = $ this -> getConfig ( 'identityAttribute' ) ; $ identity = $ request -> getAttribute ( $ identityAttribute ) ; if ( $ identity === null ) { return $ identity ; } if ( ! $ identity instanceof IdentityInterface ) { $ type = is_obj... | Get the identity from a request . |
34,834 | public function authorizeAction ( ) { $ request = $ this -> getController ( ) -> request ; $ action = $ request -> getParam ( 'action' ) ; $ skipAuthorization = $ this -> checkAction ( $ action , 'skipAuthorization' ) ; if ( $ skipAuthorization ) { $ this -> skipAuthorization ( ) ; return ; } $ authorizeModel = $ this ... | Action authorization handler . |
34,835 | protected function checkAction ( $ action , $ configKey ) { $ actions = ( array ) $ this -> getConfig ( $ configKey ) ; return in_array ( $ action , $ actions , true ) ; } | Checks whether an action should be authorized according to the config key provided . |
34,836 | protected function getDefaultAction ( ServerRequest $ request ) { $ action = $ request -> getParam ( 'action' ) ; $ name = $ this -> getConfig ( 'actionMap.' . $ action ) ; if ( $ name === null ) { return $ action ; } if ( ! is_string ( $ name ) ) { $ type = is_object ( $ name ) ? get_class ( $ name ) : gettype ( $ nam... | Returns authorization action name for a controller action resolved from the request . |
34,837 | protected function getHandler ( ) { $ handler = $ this -> getConfig ( 'unauthorizedHandler' ) ; if ( ! is_array ( $ handler ) ) { $ handler = [ 'className' => $ handler , ] ; } if ( ! isset ( $ handler [ 'className' ] ) ) { throw new RuntimeException ( 'Missing `className` key from handler config.' ) ; } return Handler... | Returns unauthorized handler . |
34,838 | protected function getAuthorizationService ( $ request , $ response ) { $ service = $ this -> subject ; if ( $ this -> subject instanceof AuthorizationServiceProviderInterface ) { $ service = $ this -> subject -> getAuthorizationService ( $ request , $ response ) ; } if ( ! $ service instanceof AuthorizationServiceInte... | Returns AuthorizationServiceInterface instance . |
34,839 | protected function buildIdentity ( AuthorizationServiceInterface $ service , $ identity ) { $ class = $ this -> getConfig ( 'identityDecorator' ) ; if ( is_callable ( $ class ) ) { $ identity = $ class ( $ service , $ identity ) ; } else { if ( ! $ identity instanceof IdentityInterface ) { $ identity = new $ class ( $ ... | Builds the identity object . |
34,840 | public static function create ( $ name ) { $ class = App :: className ( $ name , 'Middleware/UnauthorizedHandler' , 'Handler' ) ; if ( ! $ class ) { $ message = sprintf ( 'Handler `%s` does not exist.' , $ name ) ; throw new RuntimeException ( $ message ) ; } $ instance = new $ class ( ) ; if ( ! $ instance instanceof ... | Creates unauthorized request handler . |
34,841 | protected function getServiceFromRequest ( ServerRequestInterface $ request ) { $ serviceAttribute = $ this -> getConfig ( 'authorizationAttribute' ) ; $ service = ( $ request -> getAttribute ( $ serviceAttribute ) ) ; if ( ! $ service instanceof AuthorizationServiceInterface ) { $ errorMessage = __CLASS__ . ' could no... | Gets the authorization service from the request attribute |
34,842 | public function getPolicy ( $ resource ) { if ( $ resource instanceof EntityInterface ) { return $ this -> getEntityPolicy ( $ resource ) ; } if ( $ resource instanceof RepositoryInterface ) { return $ this -> getRepositoryPolicy ( $ resource ) ; } if ( $ resource instanceof QueryInterface ) { return $ this -> getRepos... | Get a policy for an ORM Table Entity or Query . |
34,843 | protected function getEntityPolicy ( EntityInterface $ entity ) { $ class = get_class ( $ entity ) ; $ entityNamespace = '\Model\Entity\\' ; $ namespace = str_replace ( '\\' , '/' , substr ( $ class , 0 , strpos ( $ class , $ entityNamespace ) ) ) ; $ name = substr ( $ class , strpos ( $ class , $ entityNamespace ) + s... | Get a policy for an entity |
34,844 | protected function getRepositoryPolicy ( RepositoryInterface $ table ) { $ class = get_class ( $ table ) ; $ tableNamespace = '\Model\Table\\' ; $ namespace = str_replace ( '\\' , '/' , substr ( $ class , 0 , strpos ( $ class , $ tableNamespace ) ) ) ; $ name = substr ( $ class , strpos ( $ class , $ tableNamespace ) +... | Get a policy for a table |
34,845 | protected function findPolicy ( $ class , $ name , $ namespace ) { $ namespace = $ this -> getNamespace ( $ namespace ) ; $ policyClass = false ; if ( $ namespace !== $ this -> appNamespace ) { $ policyClass = App :: className ( $ name , 'Policy\\' . $ namespace , 'Policy' ) ; } if ( $ policyClass === false ) { $ polic... | Locate a policy class using conventions |
34,846 | protected function getCanHandler ( $ policy , $ action ) { $ method = 'can' . ucfirst ( $ action ) ; if ( ! method_exists ( $ policy , $ method ) && ! method_exists ( $ policy , '__call' ) ) { throw new MissingMethodException ( [ $ method , $ action , get_class ( $ policy ) ] ) ; } return [ $ policy , $ method ] ; } | Returns a policy action handler . |
34,847 | protected function getScopeHandler ( $ policy , $ action ) { $ method = 'scope' . ucfirst ( $ action ) ; if ( ! method_exists ( $ policy , $ method ) ) { throw new MissingMethodException ( [ $ method , $ action , get_class ( $ policy ) ] ) ; } return [ $ policy , $ method ] ; } | Returns a policy scope action handler . |
34,848 | public function map ( $ resourceClass , $ policy ) { if ( ! class_exists ( $ resourceClass ) ) { $ message = sprintf ( 'Resource class `%s` does not exist.' , $ resourceClass ) ; throw new InvalidArgumentException ( $ message ) ; } if ( ! is_string ( $ policy ) && ! is_object ( $ policy ) && ! is_callable ( $ policy ) ... | Maps a resource class to the policy class name . |
34,849 | private static function fetchApnsId ( string $ headers ) : string { $ data = explode ( "\n" , trim ( $ headers ) ) ; foreach ( $ data as $ part ) { $ middle = explode ( ":" , $ part ) ; if ( $ middle [ 0 ] !== 'apns-id' ) { continue ; } return trim ( $ middle [ 1 ] ) ; } return '' ; } | Fetch APNs Id from response headers . |
34,850 | public function getErrorDescription ( ) : string { if ( isset ( self :: $ errorReasons [ $ this -> statusCode ] [ $ this -> errorReason ] ) ) { return self :: $ errorReasons [ $ this -> statusCode ] [ $ this -> errorReason ] ; } return '' ; } | Get error description . |
34,851 | public static function create ( array $ options ) : Token { $ token = new self ( $ options ) ; $ token -> token = $ token -> generate ( ) ; return $ token ; } | Create Token Auth Provider . |
34,852 | public static function useExisting ( string $ tokenString , array $ options ) : Token { $ token = new self ( $ options ) ; $ token -> token = $ tokenString ; return $ token ; } | Use previously generated token . |
34,853 | private function generatePrivateECKey ( ) : JWK { return JWKFactory :: createFromKeyFile ( $ this -> privateKeyPath , $ this -> privateKeySecret , [ 'kid' => $ this -> keyId , 'alg' => 'ES512' , 'use' => 'sig' ] ) ; } | Generate private EC key . |
34,854 | public function setAlert ( $ alert ) : Payload { if ( $ alert instanceof Alert || is_string ( $ alert ) ) { $ this -> alert = $ alert ; } return $ this ; } | Set Alert . |
34,855 | public function setCustomValue ( string $ key , $ value ) : Payload { if ( $ key === self :: PAYLOAD_ROOT_KEY ) { throw InvalidPayloadException :: reservedKey ( ) ; } $ this -> customValues [ $ key ] = $ value ; return $ this ; } | Set custom value for Payload . |
34,856 | public function getCustomValue ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> customValues ) ) { throw InvalidPayloadException :: notExistingCustomValue ( $ key ) ; } return $ this -> customValues [ $ key ] ; } | Get custom value . |
34,857 | public function getDecoratedHeaders ( ) : array { $ decoratedHeaders = [ ] ; foreach ( $ this -> headers as $ name => $ value ) { $ decoratedHeaders [ ] = $ name . ': ' . $ value ; } return $ decoratedHeaders ; } | Get decorated request headers . |
34,858 | private function prepareApnsHeaders ( Notification $ notification ) { if ( ! empty ( $ notification -> getId ( ) ) ) { $ this -> headers [ self :: HEADER_APNS_ID ] = $ notification -> getId ( ) ; } if ( $ notification -> getExpirationAt ( ) instanceof \ DateTime ) { $ this -> headers [ self :: HEADER_APNS_EXPIRATION ] ... | Prepare APNs headers before sending request . |
34,859 | public function push ( ) : array { $ responseCollection = [ ] ; if ( ! $ this -> curlMultiHandle ) { $ this -> curlMultiHandle = curl_multi_init ( ) ; if ( ! defined ( 'CURLPIPE_MULTIPLEX' ) ) { define ( 'CURLPIPE_MULTIPLEX' , 2 ) ; } curl_multi_setopt ( $ this -> curlMultiHandle , CURLMOPT_PIPELINING , CURLPIPE_MULTIP... | Push notifications to APNs . |
34,860 | private function prepareHandle ( Notification $ notification ) { $ request = new Request ( $ notification , $ this -> isProductionEnv ) ; $ ch = curl_init ( ) ; $ this -> authProvider -> authenticateClient ( $ request ) ; curl_setopt_array ( $ ch , $ request -> getOptions ( ) ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER... | Prepares a curl handle from a Notification object . |
34,861 | public function addNotifications ( array $ notifications ) { foreach ( $ notifications as $ notification ) { if ( in_array ( $ notification , $ this -> notifications , true ) ) { continue ; } $ this -> addNotification ( $ notification ) ; } } | Add several notifications in queue for sending . |
34,862 | public function identifiers ( ) { if ( ! $ this -> _identifiers ) { $ this -> _identifiers = new IdentifierCollection ( $ this -> getConfig ( 'identifiers' ) ) ; } return $ this -> _identifiers ; } | Access the identifier collection |
34,863 | public function authenticators ( ) { if ( ! $ this -> _authenticators ) { $ identifiers = $ this -> identifiers ( ) ; $ authenticators = $ this -> getConfig ( 'authenticators' ) ; $ this -> _authenticators = new AuthenticatorCollection ( $ identifiers , $ authenticators ) ; } return $ this -> _authenticators ; } | Access the authenticator collection |
34,864 | public function clearIdentity ( ServerRequestInterface $ request , ResponseInterface $ response ) { foreach ( $ this -> authenticators ( ) as $ authenticator ) { if ( $ authenticator instanceof PersistenceInterface ) { $ result = $ authenticator -> clearIdentity ( $ request , $ response ) ; $ request = $ result [ 'requ... | Clears the identity from authenticators that store them and the request |
34,865 | public function persistIdentity ( ServerRequestInterface $ request , ResponseInterface $ response , $ identity ) { foreach ( $ this -> authenticators ( ) as $ authenticator ) { if ( $ authenticator instanceof PersistenceInterface ) { $ result = $ authenticator -> persistIdentity ( $ request , $ response , $ identity ) ... | Sets identity data and persists it in the authenticators that support it . |
34,866 | public function getIdentity ( ) { if ( $ this -> _result === null || ! $ this -> _result -> isValid ( ) ) { return null ; } $ identity = $ this -> _result -> getData ( ) ; if ( ! ( $ identity instanceof IdentityInterface ) ) { $ identity = $ this -> buildIdentity ( $ identity ) ; } return $ identity ; } | Gets an identity object |
34,867 | public function buildIdentity ( $ identityData ) { $ class = $ this -> getConfig ( 'identityClass' ) ; if ( is_callable ( $ class ) ) { $ identity = $ class ( $ identityData ) ; } else { $ identity = new $ class ( $ identityData ) ; } if ( ! ( $ identity instanceof IdentityInterface ) ) { throw new RuntimeException ( s... | Builds the identity object |
34,868 | public function authenticate ( ServerRequestInterface $ request , ResponseInterface $ response ) { try { $ result = $ this -> getPayload ( $ request ) ; } catch ( Exception $ e ) { return new Result ( null , Result :: FAILURE_CREDENTIALS_INVALID , [ 'message' => $ e -> getMessage ( ) , 'exception' => $ e ] ) ; } if ( !... | Authenticates the identity based on a JWT token contained in a request . |
34,869 | public function beforeFilter ( ) { $ authentication = $ this -> getAuthenticationService ( ) ; $ provider = $ authentication -> getAuthenticationProvider ( ) ; if ( $ provider === null || $ provider instanceof PersistenceInterface || $ provider instanceof StatelessInterface ) { return ; } $ this -> dispatchEvent ( 'Aut... | Triggers the Authentication . afterIdentify event for non stateless adapters that are not persistent either |
34,870 | public function getAuthenticationService ( ) { $ controller = $ this -> getController ( ) ; $ service = $ controller -> request -> getAttribute ( 'authentication' ) ; if ( $ service === null ) { throw new Exception ( 'The request object does not contain the required `authentication` attribute' ) ; } if ( ! ( $ service ... | Returns authentication service . |
34,871 | public function startup ( ) { if ( ! $ this -> getConfig ( 'requireIdentity' ) ) { return ; } $ request = $ this -> getController ( ) -> request ; $ action = $ request -> getParam ( 'action' ) ; if ( in_array ( $ action , $ this -> unauthenticatedActions ) ) { return ; } $ identity = $ request -> getAttribute ( $ this ... | Start up event handler |
34,872 | public function addUnauthenticatedActions ( array $ actions ) { $ this -> unauthenticatedActions = array_merge ( $ this -> unauthenticatedActions , $ actions ) ; $ this -> unauthenticatedActions = array_values ( array_unique ( $ this -> unauthenticatedActions ) ) ; return $ this ; } | Add to the list of actions that don t require an authentication identity to be present . |
34,873 | public function setIdentity ( ArrayAccess $ identity ) { $ controller = $ this -> getController ( ) ; $ result = $ this -> getAuthenticationService ( ) -> persistIdentity ( $ controller -> request , $ controller -> response , $ identity ) ; $ controller -> setRequest ( $ result [ 'request' ] ) ; $ controller -> respons... | Set identity data to all authenticators that are loaded and support persistence . |
34,874 | protected function _checkLdapConfig ( ) { if ( ! isset ( $ this -> _config [ 'bindDN' ] ) ) { throw new RuntimeException ( 'Config `bindDN` is not set.' ) ; } if ( ! is_callable ( $ this -> _config [ 'bindDN' ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The `bindDN` config is not a callable. Got `%s` instead... | Checks the LDAP config |
34,875 | protected function _buildLdapObject ( ) { $ ldap = $ this -> _config [ 'ldap' ] ; if ( is_string ( $ ldap ) ) { $ class = App :: className ( $ ldap , 'Identifier/Ldap' ) ; $ ldap = new $ class ( ) ; } if ( ! ( $ ldap instanceof AdapterInterface ) ) { $ message = sprintf ( 'Option `ldap` must implement `%s`.' , AdapterI... | Constructs the LDAP object and sets it to the property |
34,876 | protected function _connectLdap ( ) { $ config = $ this -> getConfig ( ) ; $ this -> _ldap -> connect ( $ config [ 'host' ] , $ config [ 'port' ] , $ this -> getConfig ( 'options' ) ) ; } | Initializes the LDAP connection |
34,877 | protected function _bindUser ( $ username , $ password ) { $ config = $ this -> getConfig ( ) ; try { $ ldapBind = $ this -> _ldap -> bind ( $ config [ 'bindDN' ] ( $ username ) , $ password ) ; if ( $ ldapBind === true ) { $ this -> _ldap -> unbind ( ) ; return new ArrayObject ( [ $ config [ 'fields' ] [ self :: CREDE... | Try to bind the given user to the LDAP server |
34,878 | protected function _handleLdapError ( $ message ) { $ extendedError = $ this -> _ldap -> getDiagnosticMessage ( ) ; if ( ! is_null ( $ extendedError ) ) { $ this -> _errors [ ] = $ extendedError ; } $ this -> _errors [ ] = $ message ; } | Handles an LDAP error |
34,879 | protected function generateNonce ( ) { $ expiryTime = microtime ( true ) + $ this -> getConfig ( 'nonceLifetime' ) ; $ secret = $ this -> getConfig ( 'secret' ) ; $ signatureValue = hash_hmac ( 'sha1' , $ expiryTime . ':' . $ secret , $ secret ) ; $ nonceValue = $ expiryTime . ':' . $ signatureValue ; return base64_enc... | Generate a nonce value that is validated in future requests . |
34,880 | protected function validNonce ( $ nonce ) { $ value = base64_decode ( $ nonce ) ; if ( $ value === false ) { return false ; } $ parts = explode ( ':' , $ value ) ; if ( count ( $ parts ) !== 2 ) { return false ; } list ( $ expires , $ checksum ) = $ parts ; if ( $ expires < microtime ( true ) ) { return false ; } $ sec... | Check the nonce to ensure it is valid and not expired . |
34,881 | protected function checkCallable ( ) { $ callback = $ this -> getConfig ( 'callback' ) ; if ( ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( sprintf ( 'The `callback` option is not a callable. Got `%s` instead.' , gettype ( $ callback ) ) ) ; } } | Check the callable option |
34,882 | protected function getRedirectUrl ( $ target , ServerRequestInterface $ request ) { $ param = $ this -> getConfig ( 'queryParam' ) ; if ( $ param === null ) { return $ target ; } $ uri = $ request -> getUri ( ) ; if ( property_exists ( $ uri , 'base' ) ) { $ uri = $ uri -> withPath ( $ uri -> base . $ uri -> getPath ( ... | Returns redirect URL . |
34,883 | protected function getAuthenticationService ( $ request , $ response ) { $ subject = $ this -> subject ; if ( $ subject instanceof AuthenticationServiceProviderInterface ) { $ subject = $ this -> subject -> getAuthenticationService ( $ request , $ response ) ; } if ( ! $ subject instanceof AuthenticationServiceInterfac... | Returns AuthenticationServiceInterface instance . |
34,884 | protected function getToken ( ServerRequestInterface $ request ) { $ token = $ this -> getTokenFromHeader ( $ request , $ this -> getConfig ( 'header' ) ) ; if ( $ token === null ) { $ token = $ this -> getTokenFromQuery ( $ request , $ this -> getConfig ( 'queryParam' ) ) ; } $ prefix = $ this -> getConfig ( 'tokenPre... | Checks if the token is in the headers or a request parameter |
34,885 | protected function _createPlainToken ( $ identity ) { $ usernameField = $ this -> getConfig ( 'fields.username' ) ; $ passwordField = $ this -> getConfig ( 'fields.password' ) ; return $ identity [ $ usernameField ] . $ identity [ $ passwordField ] ; } | Creates a plain part of a cookie token . |
34,886 | protected function _createToken ( $ identity ) { $ plain = $ this -> _createPlainToken ( $ identity ) ; $ hash = $ this -> getPasswordHasher ( ) -> hash ( $ plain ) ; $ usernameField = $ this -> getConfig ( 'fields.username' ) ; return json_encode ( [ $ identity [ $ usernameField ] , $ hash ] ) ; } | Creates a full cookie token serialized as a JSON sting . |
34,887 | protected function _checkToken ( $ identity , $ tokenHash ) { $ plain = $ this -> _createPlainToken ( $ identity ) ; return $ this -> getPasswordHasher ( ) -> check ( $ plain , $ tokenHash ) ; } | Checks whether a token hash matches the identity data . |
34,888 | protected function _createCookie ( $ value ) { $ data = $ this -> getConfig ( 'cookie' ) ; $ cookie = new Cookie ( $ data [ 'name' ] , $ value , $ data [ 'expire' ] , $ data [ 'path' ] , $ data [ 'domain' ] , $ data [ 'secure' ] , $ data [ 'httpOnly' ] ) ; return $ cookie ; } | Creates a cookie instance with configured defaults . |
34,889 | public function getResolver ( ) { if ( $ this -> resolver === null ) { $ config = $ this -> getConfig ( 'resolver' ) ; if ( $ config !== null ) { $ this -> resolver = $ this -> buildResolver ( $ config ) ; } else { throw new RuntimeException ( 'Resolver has not been set.' ) ; } } return $ this -> resolver ; } | Returns ResolverInterface instance . |
34,890 | protected function buildResolver ( $ config ) { if ( is_string ( $ config ) ) { $ config = [ 'className' => $ config ] ; } if ( ! isset ( $ config [ 'className' ] ) ) { $ message = 'Option `className` is not present.' ; throw new InvalidArgumentException ( $ message ) ; } $ class = App :: className ( $ config [ 'classN... | Builds a ResolverInterface instance . |
34,891 | public function authenticate ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ user = $ this -> getUser ( $ request ) ; if ( empty ( $ user ) ) { return new Result ( null , Result :: FAILURE_CREDENTIALS_MISSING ) ; } return new Result ( $ user , Result :: SUCCESS ) ; } | Authenticate a user using HTTP auth . Will use the configured User model and attempt a login using HTTP auth . |
34,892 | protected function _checkUrl ( ServerRequestInterface $ request ) { return $ this -> _getUrlChecker ( ) -> check ( $ request , $ this -> getConfig ( 'loginUrl' ) , ( array ) $ this -> getConfig ( 'urlChecker' ) ) ; } | Checks the Login URL |
34,893 | protected function _getUrlChecker ( ) { $ options = $ this -> getConfig ( 'urlChecker' ) ; if ( ! is_array ( $ options ) ) { $ options = [ 'className' => $ options ] ; } if ( ! isset ( $ options [ 'className' ] ) ) { $ options [ 'className' ] = DefaultUrlChecker :: class ; } $ className = App :: className ( $ options [... | Gets the login URL checker |
34,894 | public function authenticate ( ServerRequestInterface $ request , ResponseInterface $ response ) { $ sessionKey = $ this -> getConfig ( 'sessionKey' ) ; $ session = $ request -> getAttribute ( 'session' ) ; $ user = $ session -> read ( $ sessionKey ) ; if ( empty ( $ user ) ) { return new Result ( null , Result :: FAIL... | Authenticate a user using session data . |
34,895 | public function identify ( array $ credentials ) { foreach ( $ this -> _loaded as $ name => $ identifier ) { $ result = $ identifier -> identify ( $ credentials ) ; if ( $ result ) { return $ result ; } $ this -> _errors [ $ name ] = $ identifier -> getErrors ( ) ; } return null ; } | Identifies an user or service by the passed credentials |
34,896 | protected function _create ( $ className , $ alias , $ config ) { $ identifier = new $ className ( $ config ) ; if ( ! ( $ identifier instanceof IdentifierInterface ) ) { throw new RuntimeException ( sprintf ( 'Identifier class `%s` must implement `%s`.' , $ className , IdentifierInterface :: class ) ) ; } return $ ide... | Creates identifier instance . |
34,897 | public function bind ( $ bind , $ password ) { $ this -> _setErrorHandler ( ) ; $ result = ldap_bind ( $ this -> getConnection ( ) , $ bind , $ password ) ; $ this -> _unsetErrorHandler ( ) ; return $ result ; } | Bind to LDAP directory |
34,898 | public function setOption ( $ option , $ value ) { $ this -> _setErrorHandler ( ) ; ldap_set_option ( $ this -> getConnection ( ) , $ option , $ value ) ; $ this -> _unsetErrorHandler ( ) ; } | Set the value of the given option |
34,899 | public function getOption ( $ option ) { $ this -> _setErrorHandler ( ) ; ldap_get_option ( $ this -> getConnection ( ) , $ option , $ returnValue ) ; $ this -> _unsetErrorHandler ( ) ; return $ returnValue ; } | Get the current value for given option |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.