All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.onixbyte.simplejwt.constants.TokenAlgorithm Maven / Gradle / Ivy

/*
 * Copyright (C) 2024-2024 OnixByte.
 *
 * 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.
 */

package com.onixbyte.simplejwt.constants;

import lombok.Getter;

import java.util.List;

/**
 * The {@code TokenAlgorithm} enum class defines the algorithms that can be
 * used for signing and verifying JSON Web Tokens (JWT). JWT allows various
 * cryptographic algorithms to be used for secure token generation and
 * validation. This enum provides a list of supported algorithms to ensure
 * consistent usage and avoid potential security issues.
 * 

* Supported Algorithms: *

    *
  • {@link TokenAlgorithm#HS256}: HMAC SHA-256
  • *
  • {@link TokenAlgorithm#HS384}: HMAC SHA-384
  • *
  • {@link TokenAlgorithm#HS512}: HMAC SHA-512
  • *
  • {@link TokenAlgorithm#RS256}: RSA PKCS#1 v1.5 with SHA-256
  • *
  • {@link TokenAlgorithm#RS384}: RSA PKCS#1 v1.5 with SHA-384
  • *
  • {@link TokenAlgorithm#RS512}: RSA PKCS#1 v1.5 with SHA-512
  • *
  • {@link TokenAlgorithm#ES256}: ECDSA with SHA-256
  • *
  • {@link TokenAlgorithm#ES384}: ECDSA with SHA-384
  • *
  • {@link TokenAlgorithm#ES512}: ECDSA with SHA-512
  • *
* * @author Zihlu Wang * @version 1.1.0 * @since 1.0.0 */ @Getter public enum TokenAlgorithm { /** * HMAC using SHA-256 */ HS256, /** * HMAC using SHA-384 */ HS384, /** * HMAC using SHA-512 */ HS512, /** * RSASSA-PKCS-v1_5 using SHA-256 */ RS256, /** * RSASSA-PKCS-v1_5 using SHA-384 */ RS384, /** * RSASSA-PKCS-v1_5 using SHA-512 */ RS512, /** * ECDSA using P-256 and SHA-256 */ ES256, /** * ECDSA using P-384 and SHA-384 */ ES384, /** * ECDSA using P-521 and SHA-512 */ ES512, ; /** * HMAC-based algorithms. */ public static final List HMAC_ALGORITHMS = List.of( TokenAlgorithm.HS256, TokenAlgorithm.HS384, TokenAlgorithm.HS512 ); /** * ECDSA-based algorithms. */ public static final List ECDSA_ALGORITHMS = List.of( TokenAlgorithm.ES256, TokenAlgorithm.ES384, TokenAlgorithm.ES512 ); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy