From e679c0f8e77ae92f05c2e073ce761a97fcc2abfa Mon Sep 17 00:00:00 2001 From: Andrew Hoffmann <andrew.hoffmann@wisc.edu> Date: Tue, 28 Apr 2015 15:00:39 -0500 Subject: [PATCH] checkAnswers now requires an IP address because Middleware web service requires one. --- src/main/edu/wisc/doit/RpcNetidClient.php | 4 ++-- src/main/edu/wisc/doit/RpcNetidClientSoap.php | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/edu/wisc/doit/RpcNetidClient.php b/src/main/edu/wisc/doit/RpcNetidClient.php index be4e7db..7a6a900 100644 --- a/src/main/edu/wisc/doit/RpcNetidClient.php +++ b/src/main/edu/wisc/doit/RpcNetidClient.php @@ -47,11 +47,11 @@ interface RpcNetidClient { * Validates the answers to the NetID security questions for a given user * @param string $uid the uid of the user to search for (typically the NetID) * @param RpcNetidStructQuestion[] $questions array containing security questions for the user (Number and Answer required) - * @param string $ip ip address of the user (optional) + * @param string $ip ip address of the user * @return bool true if the answers are correct, false otherwise * @throws edu\wisc\doit\RpcNetidClientSoapException if unexpected response from web service */ - function checkAnswers ( $uid, array $questions, $ip = "" ); + function checkAnswers ( $uid, array $questions, $ip ); /** * Retrieves the recovery email attached to the given user's uid diff --git a/src/main/edu/wisc/doit/RpcNetidClientSoap.php b/src/main/edu/wisc/doit/RpcNetidClientSoap.php index f46ee03..81a8c1a 100644 --- a/src/main/edu/wisc/doit/RpcNetidClientSoap.php +++ b/src/main/edu/wisc/doit/RpcNetidClientSoap.php @@ -189,23 +189,21 @@ class RpcNetidClientSoap implements RpcNetidClient { * (non-PHPdoc) * @see \edu\wisc\doit\RpcNetidClient::checkAnswers() */ - public function checkAnswers( $uid, array $questions, $ip = "" ){ + public function checkAnswers( $uid, array $questions, $ip ){ if( is_string($uid) !== true) { throw new \InvalidArgumentException("uid parameter must be a string"); } - - if ( empty( $ip ) === false ) { - - if ( is_string( $ip ) !== true) { - throw new \InvalidArgumentException("ip parameter must be a string"); - } - - if ( filter_var( $ip, FILTER_VALIDATE_IP ) === false ) { - throw new \DomainException( "Invalid IP address: $ip" ); - } + + if ( is_string( $ip ) !== true) { + throw new \InvalidArgumentException("ip parameter must be a string"); + } + + if ( filter_var( $ip, FILTER_VALIDATE_IP ) === false ) { + throw new \DomainException( "Invalid IP address: $ip" ); } + // Create array of parameters for the SOAP client $questionsParam = array( 'QuestionPair' => array() ); -- GitLab