/*
 * Copyright 2015 eBay Software Foundation
 *
 * 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 org.ebayopensource.fidouaf.res.util;

import org.ebayopensource.fido.uaf.crypto.Notary;
import org.ebayopensource.fido.uaf.crypto.SHA;

public class NotaryImpl implements Notary {

	private static Notary instance = new NotaryImpl();

	private NotaryImpl() {
		// Init
	}

	public static Notary getInstance() {
		return instance;
	}

	public String sign(String signData) {
		return SHA.sha256(signData);
	}

	public boolean verify(String signData, String signature) {
		return signature.equals(SHA.sha256(signData));
	}

}

@@ -748,387 +748,1219 @@
 HA;%0A
-%0Apublic class NotaryImpl implements Notary %7B%0A%0A%09private static Notary instance = new NotaryImpl();%0A%0A%09private NotaryImpl() %7B%0A%09%09// Init%0A%09%7D%0A%0A%09public static Notary getInstance() %7B%0A%09%09return instance;%0A%09%7D%0A%0A%09public String sign(String signData) %7B%0A%09%09return SHA.sha256(signData);%0A%09%7D%0A%0A%09public boolean verify(String signData, String signature) %7B%0A%09%09return signature.equals(SHA.sha256(signData))
+import org.ebayopensource.fido.uaf.crypto.HMAC;%0Aimport org.apache.commons.codec.binary.Base64;%0A%0Aimport java.util.logging.Logger;%0A%0A/**%0A * This is just en example implementation. You should implement this class based on your operational environment.%0A */%0Apublic class NotaryImpl implements Notary %7B%0A%0A%09private Logger logger = Logger.getLogger(this.getClass().getName());%0A%09private String hmacSecret = %22HMAC-is-just-one-way%22;%0A%09private static Notary instance = new NotaryImpl();%0A%0A%09private NotaryImpl() %7B%0A%09%09// Init%0A%09%7D%0A%0A%09public static Notary getInstance() %7B%0A%09%09return instance;%0A%09%7D%0A%0A%09public String sign(String signData) %7B%0A%09%09try %7B%0A%09%09%09return Base64.encodeBase64URLSafeString(HMAC.sign(signData, hmacSecret));%0A%09%09%7D catch (InvalidKeyException %7C NoSuchAlgorithmException%0A%09%09%09%09%7C InvalidKeySpecException %7C UnsupportedEncodingException e) %7B%0A%09%09%09logger.info(e.toString());%0A%09%09%7D%0A%09%09return null;%0A%09%7D%0A%0A%09public boolean verify(String signData, String signature) %7B%0A%09%09try %7B%0A%09%09%09return MessageDigest.isEqual(Base64.decodeBase64(signature), HMAC.sign(signData, hmacSecret));%0A%09%09%7D catch (InvalidKeyException %7C NoSuchAlgorithmException%0A%09%09%09%09%7C InvalidKeySpecException %7C UnsupportedEncodingException e) %7B%0A%09%09%09logger.info(e.toString());%0A%09%09%7D%0A%09%09return false
 ;%0A%09%7D

Update NotaryImpl.java