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

com.authlete.cose.constants.COSEHeaderParameters Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2023 Authlete, Inc.
 *
 * 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
 *
 *     https://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.authlete.cose.constants;


import java.util.LinkedHashMap;
import java.util.Map;


/**
 * COSE Header Parameters
 *
 * 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
NameLabelValue TypeDescriptionReference
{@link #ALG alg}1int / tstrCryptographic algorithm to useRFC 9052
{@link #CRIT crit}2[+ label]Critical headers to be understoodRFC 9052
{@link #CONTENT_TYPE content type}3tstr / uintContent type of the payloadRFC 9052
{@link #KID kid}4bstrKey identifierRFC 9052
{@link #IV IV}5bstrFull Initialization VectorRFC 9052
{@link #PARTIAL_IV Partial IV}6bstrPartial Initialization VectorRFC 9052
{@link #X5CHAIN x5chain}33COSE_X509An ordered chain of X.509 certificatesRFC 9360
*
* * @since 1.1 * * @see IANA: COSE Header Parameters */ public final class COSEHeaderParameters { /** * alg (1) */ public static final int ALG = 1; /** * crit (2) */ public static final int CRIT = 2; /** * content type (3) */ public static final int CONTENT_TYPE = 3; /** * kid (4) */ public static final int KID = 4; /** * IV (5) */ public static final int IV = 5; /** * Partial IV (6) */ public static final int PARTIAL_IV = 6; /** * x5chain (33) * * @see RFC 9360 CBOR Object Signing and Encryption (COSE): Header Parameters for Carrying and Referencing X.509 Certificates * * @since 1.2 */ public static final int X5CHAIN = 33; private static final int[] values = { ALG, CRIT, CONTENT_TYPE, KID, IV, PARTIAL_IV, X5CHAIN, }; private static final String[] names = { "alg", "crit", "content type", "kid", "IV", "Partial IV", "x5chain", }; private static final Map valueToNameMap = createValueToNameMap(); private static Map createValueToNameMap() { Map map = new LinkedHashMap<>(); for (int i = 0; i < values.length; i++) { map.put(values[i], names[i]); } return map; } /** * Get the name of the header parameter to which the integer identifier * has been assigned to. * * @param value * An integer identifier assigned to a header parameter. * * @return * The name of the header parameter to which the integer identifier * has been assigned to. If the given identifier is not recognized, * {@code null} is returned. * * @since 1.5 */ public static String getNameByValue(int value) { return valueToNameMap.getOrDefault(value, null); } private COSEHeaderParameters() { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy