idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,300
public static function createOKPKey ( string $ curve , array $ values = [ ] ) : JWK { switch ( $ curve ) { case 'X25519' : $ keyPair = \ sodium_crypto_box_keypair ( ) ; $ secret = \ sodium_crypto_box_secretkey ( $ keyPair ) ; $ x = \ sodium_crypto_box_publickey ( $ keyPair ) ; break ; case 'Ed25519' : $ keyPair = \ sod...
Creates a OKP key with the given curve and additional values .
44,301
private function bnNumBits ( \ GMP $ x ) : int { $ zero = \ gmp_init ( 0 , 10 ) ; if ( Math :: equals ( $ x , $ zero ) ) { return 0 ; } $ log2 = 0 ; while ( false === Math :: equals ( $ x , $ zero ) ) { $ x = Math :: rightShift ( $ x , 1 ) ; ++ $ log2 ; } return $ log2 ; }
Returns the number of bits used to store this number . Non - significant upper bits are not counted .
44,302
public function get ( string $ algorithm ) : Algorithm { if ( ! $ this -> has ( $ algorithm ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The algorithm "%s" is not supported.' , $ algorithm ) ) ; } return $ this -> algorithms [ $ algorithm ] ; }
Returns the algorithm if supported otherwise throw an exception .
44,303
private function add ( Algorithm $ algorithm ) : self { $ name = $ algorithm -> name ( ) ; $ this -> algorithms [ $ name ] = $ algorithm ; return $ this ; }
Adds an algorithm to the manager .
44,304
protected function getSignatureIndex ( array $ context ) : int { $ signatureIndex = 0 ; if ( isset ( $ context [ 'signature_index' ] ) && \ is_int ( $ context [ 'signature_index' ] ) ) { $ signatureIndex = $ context [ 'signature_index' ] ; } return $ signatureIndex ; }
Get JWS signature index from context .
44,305
public static function createFromJson ( string $ json ) : self { $ data = \ json_decode ( $ json , true ) ; if ( ! \ is_array ( $ data ) ) { throw new InvalidArgumentException ( 'Invalid argument.' ) ; } return self :: createFromKeyData ( $ data ) ; }
Creates a JWKSet object using the given Json string .
44,306
public function with ( JWK $ jwk ) : self { $ clone = clone $ this ; if ( $ jwk -> has ( 'kid' ) ) { $ clone -> keys [ $ jwk -> get ( 'kid' ) ] = $ jwk ; } else { $ clone -> keys [ ] = $ jwk ; } return $ clone ; }
Add key to store in the key set . This method is immutable and will return a new object .
44,307
public function without ( $ key ) : self { if ( ! $ this -> has ( $ key ) ) { return $ this ; } $ clone = clone $ this ; unset ( $ clone -> keys [ $ key ] ) ; return $ clone ; }
Remove key from the key set . This method is immutable and will return a new object .
44,308
public function get ( $ index ) : JWK { if ( ! $ this -> has ( $ index ) ) { throw new InvalidArgumentException ( 'Undefined index.' ) ; } return $ this -> keys [ $ index ] ; }
Returns the key with the given index . Throws an exception if the index is not present in the key store .
44,309
public function selectKey ( string $ type , ? Algorithm $ algorithm = null , array $ restrictions = [ ] ) : ? JWK { if ( ! \ in_array ( $ type , [ 'enc' , 'sig' ] , true ) ) { throw new InvalidArgumentException ( 'Allowed key types are "sig" or "enc".' ) ; } $ result = [ ] ; foreach ( $ this -> keys as $ key ) { $ ind ...
Try to find a key that fits on the selected requirements . Returns null if not found .
44,310
public function verifyWithKey ( JWS $ jws , JWK $ jwk , int $ signature , ? string $ detachedPayload = null ) : bool { $ jwkset = new JWKSet ( [ $ jwk ] ) ; return $ this -> verifyWithKeySet ( $ jws , $ jwkset , $ signature , $ detachedPayload ) ; }
This method will try to verify the JWS object using the given key and for the given signature . It returns true if the signature is verified otherwise false .
44,311
public function verifyWithKeySet ( JWS $ jws , JWKSet $ jwkset , int $ signature , ? string $ detachedPayload = null ) : bool { $ this -> checkJWKSet ( $ jwkset ) ; $ this -> checkSignatures ( $ jws ) ; $ this -> checkPayload ( $ jws , $ detachedPayload ) ; $ signature = $ jws -> getSignature ( $ signature ) ; return $...
This method will try to verify the JWS object using the given key set and for the given signature . It returns true if the signature is verified otherwise false .
44,312
public function create ( array $ aliases ) : HeaderCheckerManager { $ checkers = [ ] ; foreach ( $ aliases as $ alias ) { if ( \ array_key_exists ( $ alias , $ this -> checkers ) ) { $ checkers [ ] = $ this -> checkers [ $ alias ] ; } else { throw new \ InvalidArgumentException ( \ sprintf ( 'The header checker with th...
This method creates a Header Checker Manager and populate it with the header parameter checkers found based on the alias . If the alias is not supported an InvalidArgumentException is thrown .
44,313
public static function curve256 ( ) : Curve { $ p = \ gmp_init ( 'ffffffff00000001000000000000000000000000ffffffffffffffffffffffff' , 16 ) ; $ a = \ gmp_init ( 'ffffffff00000001000000000000000000000000fffffffffffffffffffffffc' , 16 ) ; $ b = \ gmp_init ( '5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b...
Returns an NIST P - 256 curve .
44,314
public static function create ( string $ ciphertext , string $ iv , string $ tag , ? string $ aad = null , array $ sharedHeader = [ ] , array $ sharedProtectedHeader = [ ] , ? string $ encodedSharedProtectedHeader = null , array $ recipients = [ ] ) : self { return new self ( $ ciphertext , $ iv , $ tag , $ aad , $ sha...
Creates a new JWE object .
44,315
public function getRecipient ( int $ id ) : Recipient { if ( ! \ array_key_exists ( $ id , $ this -> recipients ) ) { throw new \ InvalidArgumentException ( 'The recipient does not exist.' ) ; } return $ this -> recipients [ $ id ] ; }
Returns the recipient object at the given index .
44,316
public function getSharedProtectedHeaderParameter ( string $ key ) { if ( $ this -> hasSharedProtectedHeaderParameter ( $ key ) ) { return $ this -> sharedProtectedHeader [ $ key ] ; } throw new \ InvalidArgumentException ( \ sprintf ( 'The shared protected header "%s" does not exist.' , $ key ) ) ; }
Returns the shared protected header parameter identified by the given key . Throws an exception is the the parameter is not available .
44,317
public function getSharedHeaderParameter ( string $ key ) { if ( $ this -> hasSharedHeaderParameter ( $ key ) ) { return $ this -> sharedHeader [ $ key ] ; } throw new \ InvalidArgumentException ( \ sprintf ( 'The shared header "%s" does not exist.' , $ key ) ) ; }
Returns the shared header parameter identified by the given key . Throws an exception is the the parameter is not available .
44,318
public function create ( array $ aliases ) : CompressionMethodManager { $ compressionMethods = [ ] ; foreach ( $ aliases as $ alias ) { if ( \ array_key_exists ( $ alias , $ this -> compressionMethods ) ) { $ compressionMethods [ ] = $ this -> compressionMethods [ $ alias ] ; } else { throw new \ InvalidArgumentExcepti...
Creates a compression method manager using the compression methods identified by the given aliases . If one of the aliases does not exist an exception is thrown .
44,319
public function create ( array $ aliases ) : ClaimCheckerManager { $ checkers = [ ] ; foreach ( $ aliases as $ alias ) { if ( \ array_key_exists ( $ alias , $ this -> checkers ) ) { $ checkers [ ] = $ this -> checkers [ $ alias ] ; } else { throw new \ InvalidArgumentException ( \ sprintf ( 'The claim checker with the ...
This method creates a Claim Checker Manager and populate it with the claim checkers found based on the alias . If the alias is not supported an InvalidArgumentException is thrown .
44,320
public function add ( string $ alias , ClaimChecker $ checker ) : self { $ this -> checkers [ $ alias ] = $ checker ; return $ this ; }
This method adds a claim checker to this factory .
44,321
public function create ( array $ algorithms ) : JWSVerifier { $ algorithmManager = $ this -> algorithmManagerFactory -> create ( $ algorithms ) ; return new JWSVerifier ( $ algorithmManager ) ; }
Creates a JWSVerifier using the given signature algorithm aliases .
44,322
public function serialize ( string $ name , JWS $ jws , ? int $ signatureIndex = null ) : string { if ( ! \ array_key_exists ( $ name , $ this -> serializers ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Unsupported serializer "%s".' , $ name ) ) ; } return ( $ this -> serializers [ $ name ] ) -> serialize ...
Converts a JWS into a string .
44,323
public function get ( string $ key ) { if ( ! $ this -> has ( $ key ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The value identified by "%s" does not exist.' , $ key ) ) ; } return $ this -> values [ $ key ] ; }
Get the value with a specific key .
44,324
public function thumbprint ( string $ hash_algorithm ) : string { if ( ! \ in_array ( $ hash_algorithm , \ hash_algos ( ) , true ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The hash algorithm "%s" is not supported.' , $ hash_algorithm ) ) ; } $ values = \ array_intersect_key ( $ this -> values , \ array_f...
Returns the thumbprint of the key .
44,325
public function withPayload ( string $ payload , bool $ isPayloadDetached = false ) : self { if ( false === \ mb_detect_encoding ( $ payload , 'UTF-8' , true ) ) { throw new \ InvalidArgumentException ( 'The payload must be encoded in UTF-8' ) ; } $ clone = clone $ this ; $ clone -> payload = $ payload ; $ clone -> isP...
Set the payload . This method will return a new JWSBuilder object .
44,326
public function addSignature ( JWK $ signatureKey , array $ protectedHeader , array $ header = [ ] ) : self { $ this -> checkB64AndCriticalHeader ( $ protectedHeader ) ; $ isPayloadEncoded = $ this -> checkIfPayloadIsEncoded ( $ protectedHeader ) ; if ( null === $ this -> isPayloadEncoded ) { $ this -> isPayloadEncoded...
Adds the information needed to compute the signature . This method will return a new JWSBuilder object .
44,327
public function build ( ) : JWS { if ( null === $ this -> payload ) { throw new \ RuntimeException ( 'The payload is not set.' ) ; } if ( 0 === \ count ( $ this -> signatures ) ) { throw new \ RuntimeException ( 'At least one signature must be set.' ) ; } $ encodedPayload = false === $ this -> isPayloadEncoded ? $ this...
Computes all signatures and return the expected JWS object .
44,328
public function create ( string $ payload , array $ signatures , string $ jws_serialization_mode , array $ jweSharedProtectedHeader , array $ jweSharedHeader , array $ recipients , string $ jwe_serialization_mode , ? string $ aad = null ) : string { $ jws = $ this -> jwsBuilder -> create ( ) -> withPayload ( $ payload ...
Creates a nested token .
44,329
public function analyze ( JWK $ jwk ) : MessageBag { $ bag = new MessageBag ( ) ; foreach ( $ this -> analyzers as $ analyzer ) { $ analyzer -> analyze ( $ jwk , $ bag ) ; } return $ bag ; }
This method will analyze the JWK object using all analyzers . It returns a message bag that may contains messages .
44,330
public function create ( array $ serializers , array $ keyEncryptionAlgorithms , array $ contentEncryptionAlgorithms , array $ compressionMethods , array $ headerCheckers = [ ] ) : JWELoader { $ serializerManager = $ this -> jweSerializerManagerFactory -> create ( $ serializers ) ; $ jweDecrypter = $ this -> jweDecrypt...
Creates a JWELoader using the given serializer aliases encryption algorithm aliases compression method aliases and header checker aliases .
44,331
public static function create ( array $ methods ) : self { $ manager = new self ( ) ; foreach ( $ methods as $ method ) { $ manager -> add ( $ method ) ; } return $ manager ; }
This method creates a Compression Manager with the selected compression methods .
44,332
protected function add ( CompressionMethod $ compressionMethod ) { $ name = $ compressionMethod -> name ( ) ; if ( $ this -> has ( $ name ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The compression method "%s" is already supported.' , $ name ) ) ; } $ this -> compressionMethods [ $ name ] = $ compressionM...
Add the given compression method to the manager .
44,333
public function get ( string $ name ) : CompressionMethod { if ( ! $ this -> has ( $ name ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'The compression method "%s" is not supported.' , $ name ) ) ; } return $ this -> compressionMethods [ $ name ] ; }
This method returns the compression method with the given name . Throws an exception if the method is not supported .
44,334
protected function getRecipientIndex ( array $ context ) : int { $ recipientIndex = 0 ; if ( isset ( $ context [ 'recipient_index' ] ) && \ is_int ( $ context [ 'recipient_index' ] ) ) { $ recipientIndex = $ context [ 'recipient_index' ] ; } return $ recipientIndex ; }
Get JWE recipient index from context .
44,335
public static function create ( string $ signature , array $ protectedHeader , ? string $ encodedProtectedHeader , array $ header = [ ] ) : self { return new self ( $ signature , $ protectedHeader , $ encodedProtectedHeader , $ header ) ; }
Creates a new signature .
44,336
public function getProtectedHeaderParameter ( string $ key ) { if ( $ this -> hasProtectedHeaderParameter ( $ key ) ) { return $ this -> getProtectedHeader ( ) [ $ key ] ; } throw new \ InvalidArgumentException ( \ sprintf ( 'The protected header "%s" does not exist' , $ key ) ) ; }
Returns the value of the protected header of the specified key .
44,337
public function getHeaderParameter ( string $ key ) { if ( $ this -> hasHeaderParameter ( $ key ) ) { return $ this -> header [ $ key ] ; } throw new \ InvalidArgumentException ( \ sprintf ( 'The header "%s" does not exist' , $ key ) ) ; }
Returns the value of the unprotected header of the specified key .
44,338
public function decryptUsingKey ( JWE & $ jwe , JWK $ jwk , int $ recipient ) : bool { $ jwkset = new JWKSet ( [ $ jwk ] ) ; return $ this -> decryptUsingKeySet ( $ jwe , $ jwkset , $ recipient ) ; }
This method will try to decrypt the given JWE and recipient using a JWK .
44,339
public function decryptUsingKeySet ( JWE & $ jwe , JWKSet $ jwkset , int $ recipient ) : bool { $ this -> checkJWKSet ( $ jwkset ) ; $ this -> checkPayload ( $ jwe ) ; $ this -> checkRecipients ( $ jwe ) ; $ plaintext = $ this -> decryptRecipientKey ( $ jwe , $ jwkset , $ recipient ) ; if ( null !== $ plaintext ) { $ j...
This method will try to decrypt the given JWE and recipient using a JWKSet .
44,340
public function withPayload ( $ payload ) : self { $ payload = \ is_string ( $ payload ) ? $ payload : $ this -> jsonConverter -> encode ( $ payload ) ; if ( false === \ mb_detect_encoding ( $ payload , 'UTF-8' , true ) ) { throw new \ InvalidArgumentException ( 'The payload must be encoded in UTF-8' ) ; } $ clone = cl...
Set the payload of the JWE to build .
44,341
public function withSharedProtectedHeader ( array $ sharedProtectedHeader ) : self { $ this -> checkDuplicatedHeaderParameters ( $ sharedProtectedHeader , $ this -> sharedHeader ) ; foreach ( $ this -> recipients as $ recipient ) { $ this -> checkDuplicatedHeaderParameters ( $ sharedProtectedHeader , $ recipient -> get...
Set the shared protected header of the JWE to build .
44,342
public function withSharedHeader ( array $ sharedHeader ) : self { $ this -> checkDuplicatedHeaderParameters ( $ this -> sharedProtectedHeader , $ sharedHeader ) ; foreach ( $ this -> recipients as $ recipient ) { $ this -> checkDuplicatedHeaderParameters ( $ sharedHeader , $ recipient -> getHeader ( ) ) ; } $ clone = ...
Set the shared header of the JWE to build .
44,343
public function addRecipient ( JWK $ recipientKey , array $ recipientHeader = [ ] ) : self { $ this -> checkDuplicatedHeaderParameters ( $ this -> sharedProtectedHeader , $ recipientHeader ) ; $ this -> checkDuplicatedHeaderParameters ( $ this -> sharedHeader , $ recipientHeader ) ; $ clone = clone $ this ; $ completeH...
Adds a recipient to the JWE to build .
44,344
public function build ( ) : JWE { if ( null === $ this -> payload ) { throw new \ LogicException ( 'Payload not set.' ) ; } if ( 0 === \ count ( $ this -> recipients ) ) { throw new \ LogicException ( 'No recipient.' ) ; } $ additionalHeader = [ ] ; $ cek = $ this -> determineCEK ( $ additionalHeader ) ; $ recipients =...
Builds the JWE .
44,345
public function check ( array $ claims , array $ mandatoryClaims = [ ] ) : array { $ this -> checkMandatoryClaims ( $ mandatoryClaims , $ claims ) ; $ checkedClaims = [ ] ; foreach ( $ this -> checkers as $ claim => $ checker ) { if ( \ array_key_exists ( $ claim , $ claims ) ) { $ checker -> checkClaim ( $ claims [ $ ...
This method checks all the claims passed as argument . All claims are checked against the claim checkers . If one fails the InvalidClaimException is thrown .
44,346
public static function create ( ? string $ payload , ? string $ encodedPayload = null , bool $ isPayloadDetached = false ) : self { return new self ( $ payload , $ encodedPayload , $ isPayloadDetached ) ; }
Creates a JWS object .
44,347
public function getSignature ( int $ id ) : Signature { if ( isset ( $ this -> signatures [ $ id ] ) ) { return $ this -> signatures [ $ id ] ; } throw new \ InvalidArgumentException ( 'The signature does not exist.' ) ; }
Returns the signature at the given index .
44,348
public function addSignature ( string $ signature , array $ protectedHeader , ? string $ encodedProtectedHeader , array $ header = [ ] ) : self { $ jws = clone $ this ; $ jws -> signatures [ ] = Signature :: create ( $ signature , $ protectedHeader , $ encodedProtectedHeader , $ header ) ; return $ jws ; }
This method adds a signature to the JWS object . Its returns a new JWS object .
44,349
public function create ( array $ keyEncryptionAlgorithms , array $ contentEncryptionAlgorithm , array $ compressionMethods ) : JWEBuilder { $ keyEncryptionAlgorithmManager = $ this -> algorithmManagerFactory -> create ( $ keyEncryptionAlgorithms ) ; $ contentEncryptionAlgorithmManager = $ this -> algorithmManagerFactor...
Creates a JWE Builder object using the given key encryption algorithms content encryption algorithms and compression methods .
44,350
public function add ( string $ alias , Algorithm $ algorithm ) : self { $ this -> algorithms [ $ alias ] = $ algorithm ; return $ this ; }
Adds an algorithm .
44,351
public function create ( array $ aliases ) : AlgorithmManager { $ algorithms = [ ] ; foreach ( $ aliases as $ alias ) { if ( \ array_key_exists ( $ alias , $ this -> algorithms ) ) { $ algorithms [ ] = $ this -> algorithms [ $ alias ] ; } else { throw new \ InvalidArgumentException ( \ sprintf ( 'The algorithm with the...
Create an algorithm manager using the given aliases .
44,352
private static function getRSAEP ( RSAKey $ key , BigInteger $ m ) : BigInteger { if ( $ m -> compare ( BigInteger :: createFromDecimal ( 0 ) ) < 0 || $ m -> compare ( $ key -> getModulus ( ) ) > 0 ) { throw new \ RuntimeException ( ) ; } return RSAKey :: exponentiate ( $ key , $ m ) ; }
RSA EP .
44,353
private static function getRSAESOAEP ( RSAKey $ key , string $ c , Hash $ hash ) : string { $ c = self :: convertOctetStringToInteger ( $ c ) ; $ m = self :: getRSADP ( $ key , $ c ) ; $ em = self :: convertIntegerToOctetString ( $ m , $ key -> getModulusLength ( ) ) ; $ lHash = $ hash -> hash ( '' ) ; $ maskedSeed = \...
RSAES - OAEP - DECRYPT .
44,354
protected function dbalLoad ( array $ config , ContainerBuilder $ container ) { $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'dbal.xml' ) ; if ( empty ( $ config [ 'default_connection' ] ) ) { $ keys = array_keys ( $ config [ 'connections' ] ) ...
Loads the DBAL configuration .
44,355
protected function ormLoad ( array $ config , ContainerBuilder $ container ) { $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'orm.xml' ) ; $ entityManagers = [ ] ; foreach ( array_keys ( $ config [ 'entity_managers' ] ) as $ name ) { $ entityMan...
Loads the Doctrine ORM configuration .
44,356
protected function loadOrmEntityManagerMappingInformation ( array $ entityManager , Definition $ ormConfigDef , ContainerBuilder $ container ) { $ this -> drivers = [ ] ; $ this -> aliasMap = [ ] ; $ this -> loadMappingInformation ( $ entityManager , $ container ) ; $ this -> registerMappingDrivers ( $ entityManager , ...
Loads an ORM entity managers bundle mapping information .
44,357
protected function loadOrmCacheDrivers ( array $ entityManager , ContainerBuilder $ container ) { $ this -> loadCacheDriver ( 'metadata_cache' , $ entityManager [ 'name' ] , $ entityManager [ 'metadata_cache_driver' ] , $ container ) ; $ this -> loadCacheDriver ( 'result_cache' , $ entityManager [ 'name' ] , $ entityMa...
Loads a configured entity managers cache drivers .
44,358
private function loadPropertyInfoExtractor ( $ entityManagerName , ContainerBuilder $ container ) { $ propertyExtractorDefinition = $ container -> register ( sprintf ( 'doctrine.orm.%s_entity_manager.property_info_extractor' , $ entityManagerName ) , DoctrineExtractor :: class ) ; if ( property_exists ( DoctrineExtract...
Loads a property info extractor for each defined entity manager .
44,359
private function loadValidatorLoader ( string $ entityManagerName , ContainerBuilder $ container ) : void { if ( ! interface_exists ( LoaderInterface :: class ) || ! class_exists ( DoctrineLoader :: class ) ) { return ; } $ validatorLoaderDefinition = $ container -> register ( sprintf ( 'doctrine.orm.%s_entity_manager....
Loads a validator loader for each defined entity manager .
44,360
private function addDbalSection ( ArrayNodeDefinition $ node ) { $ node -> children ( ) -> arrayNode ( 'dbal' ) -> beforeNormalization ( ) -> ifTrue ( static function ( $ v ) { return is_array ( $ v ) && ! array_key_exists ( 'connections' , $ v ) && ! array_key_exists ( 'connection' , $ v ) ; } ) -> then ( static funct...
Add DBAL section to configuration tree
44,361
private function getDbalConnectionsNode ( ) { $ treeBuilder = new TreeBuilder ( 'connections' ) ; if ( method_exists ( $ treeBuilder , 'getRootNode' ) ) { $ node = $ treeBuilder -> getRootNode ( ) ; } else { $ node = $ treeBuilder -> root ( 'connections' ) ; } $ connectionNode = $ node -> requiresAtLeastOneElement ( ) ...
Return the dbal connections node
44,362
private function getOrmTargetEntityResolverNode ( ) { $ treeBuilder = new TreeBuilder ( 'resolve_target_entities' ) ; if ( method_exists ( $ treeBuilder , 'getRootNode' ) ) { $ node = $ treeBuilder -> getRootNode ( ) ; } else { $ node = $ treeBuilder -> root ( 'resolve_target_entities' ) ; } $ node -> useAttributeAsKey...
Return ORM target entity resolver node
44,363
private function getOrmEntityListenersNode ( ) { $ treeBuilder = new TreeBuilder ( 'entity_listeners' ) ; if ( method_exists ( $ treeBuilder , 'getRootNode' ) ) { $ node = $ treeBuilder -> getRootNode ( ) ; } else { $ node = $ treeBuilder -> root ( 'entity_listeners' ) ; } $ normalizer = static function ( $ mappings ) ...
Return ORM entity listener node
44,364
private function getOrmCacheDriverNode ( $ name ) { $ treeBuilder = new TreeBuilder ( $ name ) ; if ( method_exists ( $ treeBuilder , 'getRootNode' ) ) { $ node = $ treeBuilder -> getRootNode ( ) ; } else { $ node = $ treeBuilder -> root ( $ name ) ; } $ node -> addDefaultsIfNotSet ( ) -> beforeNormalization ( ) -> ifS...
Return a ORM cache driver node for an given entity manager
44,365
private function getAutoGenerateModes ( ) { $ constPrefix = 'AUTOGENERATE_' ; $ prefixLen = strlen ( $ constPrefix ) ; $ refClass = new ReflectionClass ( 'Doctrine\Common\Proxy\AbstractProxyFactory' ) ; $ constsArray = $ refClass -> getConstants ( ) ; $ namesArray = [ ] ; $ valuesArray = [ ] ; foreach ( $ constsArray a...
Find proxy auto generate modes for their names and int values
44,366
private function getPossibleCombinations ( array $ elements , $ combinationsLevel ) { $ baseCount = count ( $ elements ) ; $ result = [ ] ; if ( $ combinationsLevel === 1 ) { foreach ( $ elements as $ element ) { $ result [ ] = [ $ element ] ; } return $ result ; } $ nextLevelElements = $ this -> getPossibleCombination...
Get the possible combinations of elements from the given array
44,367
private function shrinkParameters ( array $ parameters , array $ combination ) { array_shift ( $ parameters ) ; $ result = '' ; $ maxLength = $ this -> maxCharWidth ; $ maxLength -= count ( $ parameters ) * 5 ; $ maxLength /= count ( $ parameters ) ; foreach ( $ parameters as $ key => $ value ) { $ isLarger = false ; i...
Shrink the values of parameters from a combination
44,368
private function composeMiniQuery ( $ query , array $ keywords , $ required ) { $ mandatoryKeywords = array_splice ( $ keywords , 0 , $ required ) ; $ combinations = [ ] ; $ combinationsCount = count ( $ keywords ) ; while ( $ combinationsCount > 0 ) { $ combinations = array_merge ( $ combinations , $ this -> getPossib...
Attempt to compose the best scenario minified query so that a user could find it without expanding it
44,369
private function getDatabasePlatform ( Connection $ connection ) { try { return $ connection -> getDatabasePlatform ( ) ; } catch ( DriverException $ driverException ) { throw new DBALException ( 'An exception occured while establishing a connection to figure out your platform version.' . PHP_EOL . "You can circumvent ...
Try to get the database platform .
44,370
private function initializeTypes ( ) { foreach ( $ this -> typesConfig as $ typeName => $ typeConfig ) { if ( Type :: hasType ( $ typeName ) ) { Type :: overrideType ( $ typeName , $ typeConfig [ 'class' ] ) ; } else { Type :: addType ( $ typeName , $ typeConfig [ 'class' ] ) ; } } $ this -> initialized = true ; }
initialize the types
44,371
private function enableFilters ( EntityManagerInterface $ entityManager ) { if ( empty ( $ this -> enabledFilters ) ) { return ; } $ filterCollection = $ entityManager -> getFilters ( ) ; foreach ( $ this -> enabledFilters as $ filter ) { $ filterObject = $ filterCollection -> enable ( $ filter ) ; if ( $ filterObject ...
Enables filters for a given entity manager
44,372
private function setFilterParameters ( $ name , SQLFilter $ filter ) { if ( empty ( $ this -> filtersParameters [ $ name ] ) ) { return ; } $ parameters = $ this -> filtersParameters [ $ name ] ; foreach ( $ parameters as $ paramName => $ paramValue ) { $ filter -> setParameter ( $ paramName , $ paramValue ) ; } }
Sets default parameters for a given filter
44,373
public function getClassMetadata ( $ class , $ path = null ) { $ metadata = $ this -> getMetadataForClass ( $ class ) ; if ( ! $ metadata -> getMetadata ( ) ) { throw MappingException :: classIsNotAValidEntityOrMappedSuperClass ( $ class ) ; } $ this -> findNamespaceAndPathForMetadata ( $ metadata , $ path ) ; return $...
Gets the metadata of a class .
44,374
private function getBasePathForClass ( $ name , $ namespace , $ path ) { $ namespace = str_replace ( '\\' , '/' , $ namespace ) ; $ search = str_replace ( '\\' , '/' , $ path ) ; $ destination = str_replace ( '/' . $ namespace , '' , $ search , $ c ) ; if ( $ c !== 1 ) { throw new RuntimeException ( sprintf ( 'Can\'t f...
Get a base path for a class
44,375
protected function getEntityManager ( $ name , $ shardId = null ) { $ manager = $ this -> getDoctrine ( ) -> getManager ( $ name ) ; if ( $ shardId ) { if ( ! $ manager -> getConnection ( ) instanceof PoolingShardConnection ) { throw new LogicException ( sprintf ( "Connection of EntityManager '%s' must implement shards...
Get a doctrine entity manager by symfony name .
44,376
protected function retrieveAuthenticatedUser ( $ username ) { if ( $ user = $ this -> resolveUserByUsername ( $ username ) ) { $ provider = $ this -> auth -> getProvider ( ) ; if ( $ provider instanceof NoDatabaseUserProvider ) { $ this -> fireAuthenticatedEvent ( $ user ) ; return $ user ; } elseif ( $ provider instan...
Returns the authenticatable user instance if found .
44,377
protected function fireAuthenticatedEvent ( User $ user , $ model = null ) { Event :: dispatch ( new AuthenticatedWithWindows ( $ user , $ model ) ) ; }
Fires the windows authentication event .
44,378
protected function username ( $ account ) { $ username = explode ( '\\' , $ account ) ; if ( count ( $ username ) === 2 ) { list ( $ domain , $ username ) = $ username ; } else { $ username = $ username [ key ( $ username ) ] ; } return $ username ; }
Retrieves the users username from their full account name .
44,379
protected function user ( Builder $ query ) { $ query -> where ( Resolver :: getDatabaseIdColumn ( ) , '=' , $ this -> getGuid ( ) ) -> orWhere ( Resolver :: getDatabaseUsernameColumn ( ) , '=' , $ this -> getUsername ( ) ) ; }
Applies the user scope to the given Eloquent query builder .
44,380
public function handle ( ) { $ model = $ this -> findUser ( ) ? : $ this -> model -> newInstance ( ) ; if ( ! $ model -> exists ) { Event :: dispatch ( new Importing ( $ this -> user , $ model ) ) ; } Event :: dispatch ( new Synchronizing ( $ this -> user , $ model ) ) ; $ this -> sync ( $ model ) ; Event :: dispatch (...
Imports the current LDAP user .
44,381
protected function findUser ( ) { $ query = $ this -> model -> newQuery ( ) ; if ( $ query -> getMacro ( 'withTrashed' ) ) { $ query -> withTrashed ( ) ; } $ scope = new static :: $ scope ( $ this -> getUserObjectGuid ( ) , $ this -> getUserUsername ( ) ) ; $ scope -> apply ( $ query , $ this -> model ) ; return $ quer...
Retrieves an eloquent user by their GUID or their username .
44,382
protected function sync ( Model $ model ) { $ model -> setAttribute ( Resolver :: getDatabaseIdColumn ( ) , $ this -> getUserObjectGuid ( ) ) ; foreach ( $ this -> getLdapSyncAttributes ( ) as $ modelField => $ ldapField ) { if ( $ this -> isHandler ( $ ldapField ) ) { $ handler = app ( $ ldapField ) ; $ handler -> han...
Fills a models attributes by the specified Users attributes .
44,383
protected function getUserUsername ( ) { $ attribute = Resolver :: getLdapDiscoveryAttribute ( ) ; $ username = $ this -> user -> getFirstAttribute ( $ attribute ) ; if ( trim ( $ username ) == false ) { throw new UnexpectedValueException ( "Unable to locate a user without a {$attribute}" ) ; } return $ username ; }
Returns the LDAP users configured username .
44,384
protected function getUserObjectGuid ( ) { $ guid = $ this -> user -> getConvertedGuid ( ) ; if ( trim ( $ guid ) == false ) { $ attribute = $ this -> user -> getSchema ( ) -> objectGuid ( ) ; throw new UnexpectedValueException ( "Unable to locate a user without a {$attribute}" ) ; } return $ guid ; }
Returns the LDAP users object GUID .
44,385
protected function getSelectedAttributes ( Builder $ builder ) { $ selected = $ builder -> getSelects ( ) ; return array_merge ( $ selected , [ $ builder -> getSchema ( ) -> memberOf ( ) , ] ) ; }
Retrieve the attributes to select for the scope .
44,386
protected function passesValidation ( User $ user , Model $ model = null ) { return ( new Validator ( $ this -> rules ( $ user , $ model ) ) ) -> passes ( ) ; }
Determines if the model passes validation .
44,387
protected function rules ( User $ user , Model $ model = null ) { $ rules = [ ] ; foreach ( $ this -> getRules ( ) as $ rule ) { $ rules [ ] = new $ rule ( $ user , $ model ) ; } return $ rules ; }
Returns an array of constructed rules .
44,388
public function handle ( $ event ) { $ guard = null ; if ( property_exists ( $ event , 'guard' ) ) { $ guard = $ event -> guard ; } if ( $ this -> isUsingAdldapProvider ( $ guard ) && $ this -> canBind ( $ event -> user ) ) { $ event -> user -> setLdapUser ( Resolver :: byModel ( $ event -> user ) ) ; } }
Binds the LDAP user record to their model .
44,389
protected function canBind ( Authenticatable $ user ) : bool { return array_key_exists ( HasLdapUser :: class , class_uses_recursive ( $ user ) ) && is_null ( $ user -> ldap ) ; }
Determines if we re able to bind to the user .
44,390
protected function makeUserProvider ( Hasher $ hasher , array $ config ) { $ provider = Config :: get ( 'ldap_auth.provider' , DatabaseUserProvider :: class ) ; if ( is_a ( $ provider , DatabaseUserProvider :: class , $ allowString = true ) ) { $ model = Config :: get ( 'ldap_auth.model' ) ?? array_get ( $ config , 'mo...
Returns a new Adldap user provider .
44,391
public function handle ( ) : Model { if ( $ this -> hasPasswordColumn ( ) ) { $ password = $ this -> canSync ( ) ? $ this -> password ( ) : Str :: random ( ) ; if ( $ this -> passwordNeedsUpdate ( $ password ) ) { $ this -> applyPassword ( $ password ) ; } } return $ this -> model ; }
Sets the password on the users model .
44,392
protected function applyPassword ( $ password ) { $ password = $ this -> model -> hasSetMutator ( $ this -> column ( ) ) ? $ password : Hash :: make ( $ password ) ; $ this -> model -> setAttribute ( $ this -> column ( ) , $ password ) ; }
Applies the password to the users model .
44,393
protected function passwordNeedsUpdate ( $ password = null ) : bool { $ current = $ this -> currentModelPassword ( ) ; if ( $ current !== null && $ this -> canSync ( ) ) { return ! Hash :: check ( $ password , $ current ) ; } return is_null ( $ current ) ; }
Determines if the current model requires a password update .
44,394
public function import ( array $ users = [ ] ) : int { $ imported = 0 ; $ this -> output -> progressStart ( count ( $ users ) ) ; foreach ( $ users as $ user ) { try { $ model = Bus :: dispatch ( new ImportUser ( $ user , $ this -> model ( ) ) ) ; Bus :: dispatch ( new SyncPassword ( $ model ) ) ; $ this -> save ( $ us...
Imports the specified users and returns the total number of users successfully imported .
44,395
public function display ( array $ users = [ ] ) { $ headers = [ 'Name' , 'Account Name' , 'UPN' ] ; $ data = [ ] ; array_map ( function ( User $ user ) use ( & $ data ) { $ data [ ] = [ 'name' => $ user -> getCommonName ( ) , 'account_name' => $ user -> getAccountName ( ) , 'upn' => $ user -> getUserPrincipalName ( ) ,...
Displays the given users in a table .
44,396
public function getUsers ( ) : array { $ query = Resolver :: query ( ) ; if ( $ filter = $ this -> option ( 'filter' ) ) { $ query -> rawFilter ( $ filter ) ; } if ( $ user = $ this -> argument ( 'user' ) ) { $ users = [ $ query -> findOrFail ( $ user ) ] ; } else { $ users = $ query -> paginate ( ) -> getResults ( ) ;...
Retrieves users to be imported .
44,397
protected function save ( User $ user , Model $ model ) : bool { if ( $ model -> save ( ) && $ model -> wasRecentlyCreated ) { Event :: dispatch ( new Imported ( $ user , $ model ) ) ; if ( $ this -> isLogging ( ) ) { logger ( ) -> info ( "Imported user {$user->getCommonName()}" ) ; } return true ; } return false ; }
Saves the specified user with its model .
44,398
protected function restore ( User $ user , Model $ model ) { if ( $ this -> isUsingSoftDeletes ( $ model ) && $ model -> trashed ( ) && $ user -> isEnabled ( ) ) { $ model -> restore ( ) ; if ( $ this -> isLogging ( ) ) { $ type = get_class ( $ user -> getSchema ( ) ) ; logger ( ) -> info ( "Restored user {$user->getCo...
Restores soft - deleted models if their LDAP account is enabled .
44,399
protected function delete ( User $ user , Model $ model ) { if ( $ this -> isUsingSoftDeletes ( $ model ) && ! $ model -> trashed ( ) && $ user -> isDisabled ( ) ) { $ model -> delete ( ) ; if ( $ this -> isLogging ( ) ) { $ type = get_class ( $ user -> getSchema ( ) ) ; logger ( ) -> info ( "Soft-deleted user {$user->...
Soft deletes the specified model if their LDAP account is disabled .