// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java
// public static byte[] stringToFingerprint(String key) {
//     byte[] bytes;
// 
//     try {
//         bytes = Hex.decode(key.substring(2));
//     } catch (DecoderException e) {
//         throw new IllegalArgumentException("Malformed keyID hex string " + key, e);
//     }
// 
//     if (bytes.length < 8 || bytes.length > 20) {
//         throw new IllegalArgumentException(
//                 String.format("Key length for = %s is %d bits, should be between 64 and 160 bits",
//                         key, bytes.length * 8));
//     }
// 
//     return bytes;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java
// @Value
// @RequiredArgsConstructor
// public class KeyFingerprint {
// 
//     byte[] fingerprint;
// 
//     /**
//      * Construct a key fingerprint from string representation.
//      * @param strFingerprint a key fingerprint as string
//      */
//     public KeyFingerprint(String strFingerprint) {
//         fingerprint = HexUtils.stringToFingerprint(strFingerprint);
//     }
// 
//     @JsonValue
//     public String toString() {
//         return HexUtils.fingerprintToString(fingerprint);
//     }
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java
// @Builder
// @Value
// public class KeyInfo {
// 
//     @NonNull
//     KeyFingerprint fingerprint;
// 
//     KeyFingerprint master;
// 
//     Collection<String> uids;
// 
//     int version;
//     int algorithm;
// 
//     int bits;
// 
//     Date date;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java
// @UtilityClass
// public class HexUtils {
// 
//     /**
//      * Convert byte array of fingerprint to string of hex
//      * @param bytes fingerprint
//      * @return fingerprint as string
//      */
//     public static String fingerprintToString(byte[] bytes) {
//         StringBuilder ret = new StringBuilder();
//         ret.append("0x");
//         for (byte b : bytes) {
//             ret.append(String.format("%02X", b));
//         }
//         return ret.toString();
//     }
// 
//     /**
//      * Convert fingerprint in string format to byte array.
//      * @param key fingerprint as string
//      * @return fingerprint as byte array
//      */
//     public static byte[] stringToFingerprint(String key) {
//         byte[] bytes;
// 
//         try {
//             bytes = Hex.decode(key.substring(2));
//         } catch (DecoderException e) {
//             throw new IllegalArgumentException("Malformed keyID hex string " + key, e);
//         }
// 
//         if (bytes.length < 8 || bytes.length > 20) {
//             throw new IllegalArgumentException(
//                     String.format("Key length for = %s is %d bits, should be between 64 and 160 bits",
//                             key, bytes.length * 8));
//         }
// 
//         return bytes;
//     }
// }


import java.util.Optional;
import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint;
import lombok.EqualsAndHashCode;
import org.simplify4u.plugins.pgp.KeyFingerprint;
import org.simplify4u.plugins.pgp.KeyInfo;
import org.simplify4u.plugins.utils.HexUtils;
/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * 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.simplify4u.plugins.keysmap;




/**
 * Represent key as fingerprint for given artifact pattern.
 */
@EqualsAndHashCode
class KeyItemFingerprint implements KeyItem {

    private final byte[] fingerPrint;

    public KeyItemFingerprint(String key) {
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java
// public static byte[] stringToFingerprint(String key) {
//     byte[] bytes;
// 
//     try {
//         bytes = Hex.decode(key.substring(2));
//     } catch (DecoderException e) {
//         throw new IllegalArgumentException("Malformed keyID hex string " + key, e);
//     }
// 
//     if (bytes.length < 8 || bytes.length > 20) {
//         throw new IllegalArgumentException(
//                 String.format("Key length for = %s is %d bits, should be between 64 and 160 bits",
//                         key, bytes.length * 8));
//     }
// 
//     return bytes;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java
// @Value
// @RequiredArgsConstructor
// public class KeyFingerprint {
// 
//     byte[] fingerprint;
// 
//     /**
//      * Construct a key fingerprint from string representation.
//      * @param strFingerprint a key fingerprint as string
//      */
//     public KeyFingerprint(String strFingerprint) {
//         fingerprint = HexUtils.stringToFingerprint(strFingerprint);
//     }
// 
//     @JsonValue
//     public String toString() {
//         return HexUtils.fingerprintToString(fingerprint);
//     }
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java
// @Builder
// @Value
// public class KeyInfo {
// 
//     @NonNull
//     KeyFingerprint fingerprint;
// 
//     KeyFingerprint master;
// 
//     Collection<String> uids;
// 
//     int version;
//     int algorithm;
// 
//     int bits;
// 
//     Date date;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java
// @UtilityClass
// public class HexUtils {
// 
//     /**
//      * Convert byte array of fingerprint to string of hex
//      * @param bytes fingerprint
//      * @return fingerprint as string
//      */
//     public static String fingerprintToString(byte[] bytes) {
//         StringBuilder ret = new StringBuilder();
//         ret.append("0x");
//         for (byte b : bytes) {
//             ret.append(String.format("%02X", b));
//         }
//         return ret.toString();
//     }
// 
//     /**
//      * Convert fingerprint in string format to byte array.
//      * @param key fingerprint as string
//      * @return fingerprint as byte array
//      */
//     public static byte[] stringToFingerprint(String key) {
//         byte[] bytes;
// 
//         try {
//             bytes = Hex.decode(key.substring(2));
//         } catch (DecoderException e) {
//             throw new IllegalArgumentException("Malformed keyID hex string " + key, e);
//         }
// 
//         if (bytes.length < 8 || bytes.length > 20) {
//             throw new IllegalArgumentException(
//                     String.format("Key length for = %s is %d bits, should be between 64 and 160 bits",
//                             key, bytes.length * 8));
//         }
// 
//         return bytes;
//     }
// }


// Path: src/main/java/org/simplify4u/plugins/keysmap/KeyItemFingerprint.java
import java.util.Optional;
import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint;
import lombok.EqualsAndHashCode;
import org.simplify4u.plugins.pgp.KeyFingerprint;
import org.simplify4u.plugins.pgp.KeyInfo;
import org.simplify4u.plugins.utils.HexUtils;

/*
 * Copyright 2021 Slawomir Jaranowski
 *
 * 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.simplify4u.plugins.keysmap;




/**
 * Represent key as fingerprint for given artifact pattern.
 */
@EqualsAndHashCode
class KeyItemFingerprint implements KeyItem {

    private final byte[] fingerPrint;

    public KeyItemFingerprint(String key) {
        fingerPrint = stringToFingerprint(key);