// Path: encoder/src/main/java/ru/bullyboo/encoder/constants/Constants.java
// public class Constants {
// 
//     /**
//      * Exceptions messages
//      */
//     public static final String MESSAGE_EXCEPTION = "Message was not set";
//     public static final String METHOD_EXCEPTION = "Method was not set";
//     public static final String METHOD_CFB_OFB_EXCEPTION = "Wrong method number. Set the method number between 8 and 128";
//     public static final String KEY_SIZE_EXCEPTION = "Key size can`t be equal to 0";
//     public static final String LESS_ZERO_KEY_SIZE_EXCEPTION = "Key size can`t be less than 0";
// 
//     public static final String RSA_KEY_EXCEPTION = "Wrong key size value. Set the key size between 512 and 65536";
//     public static final String RSA_KEY_MULTIPLY_EXCEPTION = "Wrong key size value. Key must be a multiple of 64";
//     public static final String RSA_KEY_CALLBACK_EXCEPTION = "Key Callback was not set";
//     public static final String RSA_HAS_NOT_KEY_EXCEPTION = "Private key was not set. Try to use privateKey() or key() methods";
//     public static final String RSA_KEY_SIZE_EXCEPTION = "Key size was not set";
// 
//     public static final String PBE_KEY_SIZE_EXCEPTION = "Key size is not valid. Key size must be: ";
// 
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/methods/HMAC.java
// public class HMAC {
// 
//     /**
//      * All supported methods
//      */
//     public enum Method{
// 
//         HMAC_MD5("HMAC-MD5"),
//         HMAC_SHA_1("HMAC-SHA1"),
//         HMAC_SHA_224("HMAC-SHA224"),
//         HMAC_SHA_256("HMAC-SHA256"),
//         HMAC_SHA_384("HMAC-SHA384"),
//         HMAC_SHA_512("HMAC-SHA512");
// 
// 
//         private final String method;
// 
//         Method(String method) {
//             this.method = method;
//         }
// 
//         public String getMethod() {
//             return method;
//         }
// 
//     }
// 
//     /**
//      * Implementation of HMAC encryption
//      */
//     public static String encrypt(HMAC.Method method, byte[] key, byte[] message) throws Exception{
// 
//         SecretKeySpec keySpec = new SecretKeySpec(key, method.getMethod());
// 
//         Mac cipher = Mac.getInstance(method.getMethod());
//         cipher.init(keySpec);
//         byte[] cipherText = cipher.doFinal(message);
// 
//         StringBuffer hash = new StringBuffer();
//         for (int i = 0; i < cipherText.length; i++) {
//             String hex = Integer.toHexString(0xFF & cipherText[i]);
//             if (hex.length() == 1) {
//                 hash.append('0');
//             }
//             hash.append(hex);
//         }
// 
//         return hash.toString();
//     }
// 
// }


import ru.bullyboo.encoder.constants.Constants;
import ru.bullyboo.encoder.methods.HMAC;
/*
 * Copyright (C) 2017 BullyBoo
 *
 * 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 ru.bullyboo.encoder.builders;


/**
 * HMAC Encrypt/Decrypt Builder
 */
public class BuilderHMAC extends BaseBuilder<BuilderHMAC>{

    private volatile HMAC.Method method;

// Path: encoder/src/main/java/ru/bullyboo/encoder/constants/Constants.java
// public class Constants {
// 
//     /**
//      * Exceptions messages
//      */
//     public static final String MESSAGE_EXCEPTION = "Message was not set";
//     public static final String METHOD_EXCEPTION = "Method was not set";
//     public static final String METHOD_CFB_OFB_EXCEPTION = "Wrong method number. Set the method number between 8 and 128";
//     public static final String KEY_SIZE_EXCEPTION = "Key size can`t be equal to 0";
//     public static final String LESS_ZERO_KEY_SIZE_EXCEPTION = "Key size can`t be less than 0";
// 
//     public static final String RSA_KEY_EXCEPTION = "Wrong key size value. Set the key size between 512 and 65536";
//     public static final String RSA_KEY_MULTIPLY_EXCEPTION = "Wrong key size value. Key must be a multiple of 64";
//     public static final String RSA_KEY_CALLBACK_EXCEPTION = "Key Callback was not set";
//     public static final String RSA_HAS_NOT_KEY_EXCEPTION = "Private key was not set. Try to use privateKey() or key() methods";
//     public static final String RSA_KEY_SIZE_EXCEPTION = "Key size was not set";
// 
//     public static final String PBE_KEY_SIZE_EXCEPTION = "Key size is not valid. Key size must be: ";
// 
// }
// 
// Path: encoder/src/main/java/ru/bullyboo/encoder/methods/HMAC.java
// public class HMAC {
// 
//     /**
//      * All supported methods
//      */
//     public enum Method{
// 
//         HMAC_MD5("HMAC-MD5"),
//         HMAC_SHA_1("HMAC-SHA1"),
//         HMAC_SHA_224("HMAC-SHA224"),
//         HMAC_SHA_256("HMAC-SHA256"),
//         HMAC_SHA_384("HMAC-SHA384"),
//         HMAC_SHA_512("HMAC-SHA512");
// 
// 
//         private final String method;
// 
//         Method(String method) {
//             this.method = method;
//         }
// 
//         public String getMethod() {
//             return method;
//         }
// 
//     }
// 
//     /**
//      * Implementation of HMAC encryption
//      */
//     public static String encrypt(HMAC.Method method, byte[] key, byte[] message) throws Exception{
// 
//         SecretKeySpec keySpec = new SecretKeySpec(key, method.getMethod());
// 
//         Mac cipher = Mac.getInstance(method.getMethod());
//         cipher.init(keySpec);
//         byte[] cipherText = cipher.doFinal(message);
// 
//         StringBuffer hash = new StringBuffer();
//         for (int i = 0; i < cipherText.length; i++) {
//             String hex = Integer.toHexString(0xFF & cipherText[i]);
//             if (hex.length() == 1) {
//                 hash.append('0');
//             }
//             hash.append(hex);
//         }
// 
//         return hash.toString();
//     }
// 
// }


// Path: encoder/src/main/java/ru/bullyboo/encoder/builders/BuilderHMAC.java
import ru.bullyboo.encoder.constants.Constants;
import ru.bullyboo.encoder.methods.HMAC;

/*
 * Copyright (C) 2017 BullyBoo
 *
 * 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 ru.bullyboo.encoder.builders;


/**
 * HMAC Encrypt/Decrypt Builder
 */
public class BuilderHMAC extends BaseBuilder<BuilderHMAC>{

    private volatile HMAC.Method method;

    private volatile byte[] key;