Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code for each Exception #456

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor Exception codes
nicumicle committed Sep 21, 2022
commit da07b361550e1e11789955ea40a4f01abb1f9a13
83 changes: 40 additions & 43 deletions src/ExceptionCodes.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?php

declare(strict_types=1);


namespace Firebase\JWT;

class ExceptionCodes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest making this an interface (such as JwtException) and then having the Exceptions here all implement that interface.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bshaffer I made the changes you suggested. Please have another look.

@@ -17,44 +14,44 @@ class ExceptionCodes
public const INCORRECT_KEY_FOR_ALGORITHM = 8;
public const SIGN_ALGORITHM_NOT_SUPPORTED = 9;
public const KEY_IS_NOT_STRING = 10;
const OPENSSL_CAN_NOT_SIGN_DATA = 11;
const SODIUM_KEY_IS_NOT_STRING = 12;
const SODIUM_EXCEPTION = 13;
const SIGN_GENERAL_EXCEPTION = 14;
const VERIFY_ALGORITHM_NOT_SUPPORTED = 15;
const VERIFY_OPEN_SSL_ERROR = 16;
const VERIFY_SODIUM_NOT_AVAILABLE = 17;
const VERIFY_KEY_MATERIAL_IS_NOT_STRING = 18;
const VERIFY_SODIUM_EXCEPTION = 19;
const VERIFY_KEY_IS_NOT_STRING = 20;
const DECODED_JSON_IS_NULL = 21;
const ENCODED_JSON_IS_NULL = 22;
const INVALID_JSON = 23;
const KID_IS_EMPTY = 24;
const KID_IS_INVALID = 25;
const JSON_ERROR = 26;

const KEY_ID_NOT_FOUND = 27;
const OFFSET_SET_METHOD_NOT_IMPLEMENTED = 28;
const OFFSET_UNSET_METHOD_NOT_IMPLEMENTED = 29;

const JWKS_URI_IS_EMPTY = 30;

const JWK_MISSING_KEYS = 31;
const JWT_KEYS_IS_EMPTY = 32;
const JWT_ALGORITHM_NOT_SUPPORTED = 33;
const JWK_IS_EMPTY = 34;
const JWT_MISSING_KTY_PARAMETER = 35;
const JWT_MISSING_ALG_PARAMETER = 36;
const JWT_RSA_KEYS_NOT_SUPPORTED = 37;
const JWT_RSA_KEYS_MISSING_N_AND_E = 38;
const JWT_OPEN_SSL_ERROR = 39;
const JWK_EC_D_IS_NOT_SET = 40;
const JWT_EC_CRV_IS_EMPTY = 41;
const JWK_UNSUPPORTED_EC_CURVE = 42;
const JWT_X_AND_Y_ARE_EMPTY = 42;

const KEY_MATERIAL_IS_INVALID = 43;
const KEY_MATERIAL_IS_EMPTY = 44;
const KEY_ALGORITHM_IS_EMPTY = 45;
public const OPENSSL_CAN_NOT_SIGN_DATA = 11;
public const SODIUM_KEY_IS_NOT_STRING = 12;
public const SODIUM_EXCEPTION = 13;
public const SIGN_GENERAL_EXCEPTION = 14;
public const VERIFY_ALGORITHM_NOT_SUPPORTED = 15;
public const VERIFY_OPEN_SSL_ERROR = 16;
public const VERIFY_SODIUM_NOT_AVAILABLE = 17;
public const VERIFY_KEY_MATERIAL_IS_NOT_STRING = 18;
public const VERIFY_SODIUM_EXCEPTION = 19;
public const VERIFY_KEY_IS_NOT_STRING = 20;
public const DECODED_JSON_IS_NULL = 21;
public const ENCODED_JSON_IS_NULL = 22;
public const INVALID_JSON = 23;
public const KID_IS_EMPTY = 24;
public const KID_IS_INVALID = 25;
public const JSON_ERROR = 26;

public const KEY_ID_NOT_FOUND = 27;
public const OFFSET_SET_METHOD_NOT_IMPLEMENTED = 28;
public const OFFSET_UNSET_METHOD_NOT_IMPLEMENTED = 29;

public const JWKS_URI_IS_EMPTY = 30;

public const JWK_MISSING_KEYS = 31;
public const JWT_KEYS_IS_EMPTY = 32;
public const JWT_ALGORITHM_NOT_SUPPORTED = 33;
public const JWK_IS_EMPTY = 34;
public const JWT_MISSING_KTY_PARAMETER = 35;
public const JWT_MISSING_ALG_PARAMETER = 36;
public const JWT_RSA_KEYS_NOT_SUPPORTED = 37;
public const JWT_RSA_KEYS_MISSING_N_AND_E = 38;
public const JWT_OPEN_SSL_ERROR = 39;
public const JWK_EC_D_IS_NOT_SET = 40;
public const JWT_EC_CRV_IS_EMPTY = 41;
public const JWK_UNSUPPORTED_EC_CURVE = 42;
public const JWT_X_AND_Y_ARE_EMPTY = 42;

public const KEY_MATERIAL_IS_INVALID = 43;
public const KEY_MATERIAL_IS_EMPTY = 44;
public const KEY_ALGORITHM_IS_EMPTY = 45;
}