Reduced OpenID log noise

* added a base class for all openid exceptions
* moved invalid assoc exception from 500 to 400
* fixed bug on openid mememto request

Change-Id: I82d7c2077f1bd507b37ad3561fea924fb87d5353
This commit is contained in:
Sebastian Marcet
2017-08-11 12:43:43 -03:00
parent d343be293a
commit 76c37b61e6
19 changed files with 174 additions and 55 deletions

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidAssociation
* @package OpenId\Exceptions
*/
class InvalidAssociation extends Exception {
class InvalidAssociation extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidAssociationTypeException
* @package OpenId\Exceptions
*/
class InvalidAssociationTypeException extends Exception {
class InvalidAssociationTypeException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidDHParam
* @package OpenId\Exceptions
*/
class InvalidDHParam extends Exception {
class InvalidDHParam extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidKVFormat
* @package OpenId\Exceptions
*/
class InvalidKVFormat extends Exception {
class InvalidKVFormat extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidNonce
* @package OpenId\Exceptions
*/
class InvalidNonce extends Exception {
class InvalidNonce extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,23 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**//**
* Class InvalidOpenIdAuthenticationRequestMode
* @package OpenId\Exceptions
*/
class InvalidOpenIdAuthenticationRequestMode extends Exception {
class InvalidOpenIdAuthenticationRequestMode extends OpenIdBaseException {
public function __construct($message = "")
{
$message = "Invalid OpenId Authentication Request Mode : " . $message;

View File

@@ -21,6 +21,6 @@ class InvalidOpenIdMessageException extends Exception {
public function __construct($message = "")
{
$message = "Invalid OpenId Message : " . $message;
parent::__construct($message, 0, null);
parent::__construct($message, 400, null);
}
}

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidOpenIdMessageMode
* @package OpenId\Exceptions
*/
class InvalidOpenIdMessageMode extends Exception {
class InvalidOpenIdMessageMode extends OpenIdBaseException {
public function __construct($message = "")
{
$message = "Invalid OpenId Message Mode : " . $message;

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidRequestContextException
* @package OpenId\Exceptions
*/
class InvalidRequestContextException extends Exception {
class InvalidRequestContextException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class InvalidSessionTypeException
* @package OpenId\Exceptions
*/
class InvalidSessionTypeException extends Exception {
class InvalidSessionTypeException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -0,0 +1,19 @@
<?php namespace OpenId\Exceptions;
/**
* Copyright 2017 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
class OpenIdBaseException extends Exception
{
}

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class OpenIdCryptoException
* @package OpenId\Exceptions
*/
class OpenIdCryptoException extends Exception {
class OpenIdCryptoException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class OpenIdInvalidRealmException
* @package OpenId\Exceptions
*/
class OpenIdInvalidRealmException extends Exception {
class OpenIdInvalidRealmException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -11,12 +11,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use Exception;
/**
* Class ReplayAttackException
* @package OpenId\Exceptions
*/
class ReplayAttackException extends Exception {
class ReplayAttackException extends OpenIdBaseException {
public function __construct($message = "")
{

View File

@@ -12,6 +12,7 @@
* limitations under the License.
**/
use Exception;
use OpenId\Exceptions\InvalidAssociation;
use OpenId\Exceptions\InvalidAssociationTypeException;
use OpenId\Exceptions\InvalidOpenIdAuthenticationRequestMode;
use OpenId\Exceptions\InvalidOpenIdMessageException;
@@ -194,7 +195,16 @@ final class OpenIdAuthenticationRequestHandler extends OpenIdMessageHandler
$this->log_service->warning_msg("current request: ".$this->current_request);;
}
return new OpenIdIndirectGenericErrorResponse($inv_msg_ex->getMessage(), null, null, $this->current_request);
} catch (Exception $ex) {
}
catch(InvalidAssociation $inv_assoc_ex){
$this->checkpoint_service->trackException($inv_assoc_ex);
$this->log_service->warning($inv_assoc_ex);
if (!is_null($this->current_request)) {
$this->log_service->warning_msg("current request: ".$this->current_request);;
}
return new OpenIdIndirectGenericErrorResponse($inv_assoc_ex->getMessage(), null, null, $this->current_request);
}
catch (Exception $ex) {
$this->checkpoint_service->trackException($ex);
$this->log_service->error($ex);
if (!is_null($this->current_request)) {

View File

@@ -12,6 +12,7 @@
* limitations under the License.
**/
use Exception;
use OpenId\Exceptions\InvalidAssociation;
use OpenId\Exceptions\InvalidAssociationTypeException;
use OpenId\Exceptions\InvalidNonce;
use OpenId\Exceptions\InvalidOpenIdMessageException;
@@ -169,19 +170,28 @@ final class OpenIdCheckAuthenticationRequestHandler extends OpenIdMessageHandler
return $response;
} catch (InvalidNonce $inv_nonce_ex) {
$this->checkpoint_service->trackException($inv_nonce_ex);
$this->log_service->error($inv_nonce_ex);
$this->log_service->warning($inv_nonce_ex);
$response = new OpenIdDirectGenericErrorResponse($inv_nonce_ex->getMessage());
if(!is_null($this->current_request))
$this->log_service->warning_msg("current request: ".$this->current_request);
return $response;
} catch (InvalidOpenIdMessageException $inv_msg_ex) {
$this->checkpoint_service->trackException($inv_msg_ex);
$this->log_service->error($inv_msg_ex);
$this->log_service->warning($inv_msg_ex);
$response = new OpenIdDirectGenericErrorResponse($inv_msg_ex->getMessage());
if(!is_null($this->current_request))
$this->log_service->warning_msg("current request: ".$this->current_request);
return $response;
} catch (Exception $ex) {
}
catch(InvalidAssociation $inv_assoc_ex){
$this->checkpoint_service->trackException($inv_assoc_ex);
$this->log_service->warning($inv_assoc_ex);
$response = new OpenIdDirectGenericErrorResponse($inv_assoc_ex->getMessage());
if(!is_null($this->current_request))
$this->log_service->warning_msg("current request: ".$this->current_request);
return $response;
}
catch (Exception $ex) {
$this->checkpoint_service->trackException($ex);
$this->log_service->error($ex);
if(!is_null($this->current_request))