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.handlers; 018 019import org.forgerock.json.jose.jws.JwsAlgorithm; 020import org.forgerock.json.jose.utils.Utils; 021 022/** 023 * An implementation of the SigningHandler which does not perform any signing or verifying. 024 * 025 * @since 2.0.0 026 */ 027public class NOPSigningHandler implements SigningHandler { 028 029 /** 030 * Simply returns a byte array of a UTF-8 empty string. 031 * 032 * @param algorithm {@inheritDoc} 033 * @param data {@inheritDoc} 034 * @return {@inheritDoc} 035 */ 036 @Override 037 public byte[] sign(JwsAlgorithm algorithm, String data) { 038 return "".getBytes(Utils.CHARSET); 039 } 040 041 /** 042 * Returns an empty byte array. 043 * 044 * @param algorithm {@inheritDoc} 045 * @param data {@inheritDoc} 046 * @return {@inheritDoc} 047 */ 048 @Override 049 public byte[] sign(final JwsAlgorithm algorithm, final byte[] data) { 050 return new byte[0]; 051 } 052 053 /** 054 * Verifies that the signature length is zero. 055 * 056 * @param algorithm {@inheritDoc} 057 * @param data {@inheritDoc} 058 * @param signature {@inheritDoc} 059 * @return {@inheritDoc} 060 */ 061 @Override 062 public boolean verify(JwsAlgorithm algorithm, byte[] data, byte[] signature) { 063 return signature.length == 0; 064 } 065}