/** * @return bool * @throws InvalidOpenIdMessageException */ public function isValid() { $return_to = $this->getReturnTo(); $claimed_id = $this->getClaimedId(); $identity = $this->getIdentity(); $mode = $this->getMode(); $realm = $this->getRealm(); $valid_id = $this->isValidIdentifier($claimed_id, $identity); $valid_realm = OpenIdUriHelper::checkRealm($realm, $return_to); if (empty($return_to)) { throw new InvalidOpenIdMessageException('return_to is empty.'); } if (empty($realm)) { throw new InvalidOpenIdMessageException('realm is empty.'); } if (!$valid_realm) { throw new InvalidOpenIdMessageException(sprintf('realm check is not valid realm %s - return_to %s.', $realm, $return_to)); } if (empty($claimed_id)) { throw new InvalidOpenIdMessageException('claimed_id is empty.'); } if (empty($identity)) { throw new InvalidOpenIdMessageException('identity is empty.'); } if (!$valid_id) { throw new InvalidOpenIdMessageException(sprintf('identity check is not valid claimed_id %s - identity %s.', $claimed_id, $identity)); } if (empty($mode)) { throw new InvalidOpenIdMessageException('mode is empty.'); } if (!($mode == OpenIdProtocol::ImmediateMode || $mode == OpenIdProtocol::SetupMode)) { throw new InvalidOpenIdMessageException(sprintf('mode %s is invalid.', $mode)); } return true; }
public function isValid() { $mode = $this->getMode(); $claimed_assoc = $this->getAssocHandle(); $claimed_nonce = $this->getNonce(); $claimed_sig = $this->getSig(); $claimed_op_endpoint = $this->getOPEndpoint(); $claimed_identity = $this->getClaimedId(); $claimed_realm = $this->getRealm(); $claimed_returnTo = $this->getReturnTo(); $signed = $this->getSigned(); $valid_realm = OpenIdUriHelper::checkRealm($claimed_realm, $claimed_returnTo); $res = !is_null($mode) && !empty($mode) && $mode == OpenIdProtocol::CheckAuthenticationMode && !is_null($claimed_returnTo) && !empty($claimed_returnTo) && OpenIdUriHelper::checkReturnTo($claimed_returnTo) && !is_null($claimed_realm) && !empty($claimed_realm) && $valid_realm && !is_null($claimed_assoc) && !empty($claimed_assoc) && !is_null($claimed_sig) && !empty($claimed_sig) && !is_null($signed) && !empty($signed) && !is_null($claimed_nonce) && !empty($claimed_nonce) && !is_null($claimed_op_endpoint) && !empty($claimed_op_endpoint) && $claimed_op_endpoint == $this->op_endpoint_url && !is_null($claimed_identity) && !empty($claimed_identity) && OpenIdUriHelper::isValidUrl($claimed_identity); if (!$res) { $msg = sprintf("return_to is empty? %b.", empty($claimed_returnTo)) . PHP_EOL; $msg = $msg . sprintf("realm is empty? %b.", empty($claimed_realm)) . PHP_EOL; $msg = $msg . sprintf("claimed_id is empty? %b.", empty($claimed_id)) . PHP_EOL; $msg = $msg . sprintf("identity is empty? %b.", empty($claimed_identity)) . PHP_EOL; $msg = $msg . sprintf("mode is empty? %b.", empty($mode)) . PHP_EOL; $msg = $msg . sprintf("is valid realm? %b.", $valid_realm) . PHP_EOL; throw new InvalidOpenIdMessageException($msg); } return $res; }