001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2013-2015 ForgeRock AS. 015 */ 016 017package org.forgerock.json.jose.jws; 018 019import java.util.Map; 020 021/** 022 * An implementation for the JWS Header parameters. 023 * 024 * @since 2.0.0 025 */ 026public class JwsHeader extends JwtSecureHeader { 027 028 /** 029 * Constructs a new, empty JwsHeader. 030 */ 031 public JwsHeader() { 032 } 033 034 /** 035 * Constructs a new JwsHeader, with its parameters set to the contents of the given Map. 036 * 037 * @param headerParameters A Map containing the parameters to be set in the header. 038 */ 039 public JwsHeader(Map<String, Object> headerParameters) { 040 super(headerParameters); 041 } 042 043 /** 044 * Gets the Algorithm set in the JWT header. 045 * <p> 046 * If there is no algorithm set in the JWT header, then the JwsAlgorithm NONE will be returned. 047 * 048 * @return {@inheritDoc} 049 */ 050 @Override 051 public JwsAlgorithm getAlgorithm() { 052 String algorithm = getAlgorithmString(); 053 if (algorithm == null) { 054 return JwsAlgorithm.NONE; 055 } else { 056 return JwsAlgorithm.valueOf(algorithm); 057 } 058 } 059}