/** * This method attempts to validate that the record in the resultset is indeed a * record that matched the identity provided to this adapter. * * @throws Exception\UnexpectedValueException * @param object $credential * @return AuthenticationResult */ protected function validateCredential($credential) { $credentialIdentityProperty = $this->options->getCredentialIdentityProperty(); $getter = 'get' . ucfirst($credentialIdentityProperty); $identity = null; if (method_exists($credential, $getter)) { $identity = $credential->{$getter}(); } elseif (property_exists($credential, $credentialIdentityProperty)) { $identity = $credential->{$credentialIdentityProperty}; } else { throw new Exception\UnexpectedValueException(sprintf('Property (%s) in (%s) is not accessible. You should implement %s::%s()', $credentialIdentityProperty, get_class($credential), get_class($credential), $getter)); } $callable = $this->options->getCredentialCallable(); if ($callable) { $credentialValue = call_user_func($callable, $identity, $credential); } else { $credentialValue = true; } if ($credentialValue !== true) { $this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID; $this->authenticationResultInfo['messages'][] = 'Supplied credential is invalid.'; return $this->createAuthenticationResult(); } $this->authenticationResultInfo['code'] = AuthenticationResult::SUCCESS; $this->authenticationResultInfo['identity'] = $identity; $this->authenticationResultInfo['messages'][] = 'Authentication successful.'; return $this->createAuthenticationResult(); }
/** * @param object $identity * @return void */ public function write($identity) { $metadataInfo = $this->options->getClassMetadata(); $identifierValues = $metadataInfo->getIdentifierValues($identity); parent::write($identifierValues); }