// Path: src/main/java/com/wesabe/grendel/util/IntegerEquivalents.java
// public final class IntegerEquivalents {
// 	private IntegerEquivalents() {}
// 	
// 	/**
// 	 * Returns the collection of {@code integerEquivs} as an array of {@code int}s.
// 	 */
// 	public static int[] toIntArray(Collection<? extends IntegerEquivalent> integerEquivs) {
// 		final int[] values = new int[integerEquivs.size()];
// 		int i = 0;
// 		for (IntegerEquivalent integerEquiv : integerEquivs) {
// 			values[i] = integerEquiv.toInteger();
// 			i++;
// 		}
// 		return values;
// 	}
// 	
// 	/**
// 	 * Returns the set of {@code integerEquivs} as a bitmask {@code int}.
// 	 */
// 	public static int toBitmask(Set<? extends IntegerEquivalent> integerEquivs) {
// 		int value = 0;
// 		for (IntegerEquivalent integerEquiv : integerEquivs) {
// 			value |= integerEquiv.toInteger();
// 		}
// 		return value;
// 	}
// 	
// 	/**
// 	 * Returns the instance of {@code enumType} which is equivalent to
// 	 * {@code value}.
// 	 * 
// 	 * @throws IllegalArgumentException if {@code value} has no equivalent
// 	 */
// 	public static <T extends IntegerEquivalent> T fromInt(Class<T> enumType, int value) throws IllegalArgumentException {
// 		for (T constant : enumType.getEnumConstants()) {
// 			if (constant.toInteger() == value) {
// 				return constant;
// 			}
// 		}
// 		throw new IllegalArgumentException("No enum constant of " + enumType + " exists with value " + value);
// 	}
// 	
// 	/**
// 	 * Returns the list of the instances of {@code enumType} which are equivalent
// 	 * to {@code values}.
// 	 * 
// 	 * @throws IllegalArgumentException if {@code value} has no equivalent
// 	 */
// 	public static <T extends IntegerEquivalent> List<T> fromIntArray(Class<T> enumType, int[] values) throws IllegalArgumentException {
// 		final ImmutableList.Builder<T> builder = ImmutableList.builder();
// 		for (int value : values) {
// 			builder.add(fromInt(enumType, value));
// 		}
// 		return builder.build();
// 	}
// 	
// 	/**
// 	 * Returns the {@code bitMask} as a set of {@link IntegerEquivalent}s.
// 	 */
// 	public static <T extends IntegerEquivalent> Set<T> fromBitmask(Class<T> enumType, int bitMask) throws IllegalArgumentException {
// 		final ImmutableSet.Builder<T> builder = ImmutableSet.builder();
// 		for (T constant : enumType.getEnumConstants()) {
// 			if ((bitMask & constant.toInteger()) != 0) {
// 				builder.add(constant);
// 			}
// 		}
// 		return builder.build();
// 	}
// }


import java.security.SignatureException;
import java.util.List;
import java.util.Set;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import com.wesabe.grendel.util.IntegerEquivalents;
package com.wesabe.grendel.openpgp;




/**
 * A signature on a {@link MasterKey} or {@link SubKey}.
 * 
 * @author coda
 */
public class KeySignature {
	private final PGPSignature signature;
	private final PGPSignatureSubpacketVector subpackets;
	
	/**
	 * Creates a new {@link KeySignature} given a {@link PGPSignature}.
	 * 
	 * @param signature a {@link PGPSignature} instance
	 */
	public KeySignature(PGPSignature signature) {
		this.signature = signature;
		this.subpackets = signature.getHashedSubPackets();
	}
	
	/**
	 * Returns the type of signature {@code this} is.
	 */
	public SignatureType getSignatureType() {
		return IntegerEquivalents.fromInt(SignatureType.class, signature.getSignatureType());
	}
	
	/**
	 * Returns the {@link HashAlgorithm} used to make the signature.
	 */
	public HashAlgorithm getHashAlgorithm() {
// Path: src/main/java/com/wesabe/grendel/util/IntegerEquivalents.java
// public final class IntegerEquivalents {
// 	private IntegerEquivalents() {}
// 	
// 	/**
// 	 * Returns the collection of {@code integerEquivs} as an array of {@code int}s.
// 	 */
// 	public static int[] toIntArray(Collection<? extends IntegerEquivalent> integerEquivs) {
// 		final int[] values = new int[integerEquivs.size()];
// 		int i = 0;
// 		for (IntegerEquivalent integerEquiv : integerEquivs) {
// 			values[i] = integerEquiv.toInteger();
// 			i++;
// 		}
// 		return values;
// 	}
// 	
// 	/**
// 	 * Returns the set of {@code integerEquivs} as a bitmask {@code int}.
// 	 */
// 	public static int toBitmask(Set<? extends IntegerEquivalent> integerEquivs) {
// 		int value = 0;
// 		for (IntegerEquivalent integerEquiv : integerEquivs) {
// 			value |= integerEquiv.toInteger();
// 		}
// 		return value;
// 	}
// 	
// 	/**
// 	 * Returns the instance of {@code enumType} which is equivalent to
// 	 * {@code value}.
// 	 * 
// 	 * @throws IllegalArgumentException if {@code value} has no equivalent
// 	 */
// 	public static <T extends IntegerEquivalent> T fromInt(Class<T> enumType, int value) throws IllegalArgumentException {
// 		for (T constant : enumType.getEnumConstants()) {
// 			if (constant.toInteger() == value) {
// 				return constant;
// 			}
// 		}
// 		throw new IllegalArgumentException("No enum constant of " + enumType + " exists with value " + value);
// 	}
// 	
// 	/**
// 	 * Returns the list of the instances of {@code enumType} which are equivalent
// 	 * to {@code values}.
// 	 * 
// 	 * @throws IllegalArgumentException if {@code value} has no equivalent
// 	 */
// 	public static <T extends IntegerEquivalent> List<T> fromIntArray(Class<T> enumType, int[] values) throws IllegalArgumentException {
// 		final ImmutableList.Builder<T> builder = ImmutableList.builder();
// 		for (int value : values) {
// 			builder.add(fromInt(enumType, value));
// 		}
// 		return builder.build();
// 	}
// 	
// 	/**
// 	 * Returns the {@code bitMask} as a set of {@link IntegerEquivalent}s.
// 	 */
// 	public static <T extends IntegerEquivalent> Set<T> fromBitmask(Class<T> enumType, int bitMask) throws IllegalArgumentException {
// 		final ImmutableSet.Builder<T> builder = ImmutableSet.builder();
// 		for (T constant : enumType.getEnumConstants()) {
// 			if ((bitMask & constant.toInteger()) != 0) {
// 				builder.add(constant);
// 			}
// 		}
// 		return builder.build();
// 	}
// }


// Path: src/main/java/com/wesabe/grendel/openpgp/KeySignature.java
import java.security.SignatureException;
import java.util.List;
import java.util.Set;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import com.wesabe.grendel.util.IntegerEquivalents;

package com.wesabe.grendel.openpgp;




/**
 * A signature on a {@link MasterKey} or {@link SubKey}.
 * 
 * @author coda
 */
public class KeySignature {
	private final PGPSignature signature;
	private final PGPSignatureSubpacketVector subpackets;
	
	/**
	 * Creates a new {@link KeySignature} given a {@link PGPSignature}.
	 * 
	 * @param signature a {@link PGPSignature} instance
	 */
	public KeySignature(PGPSignature signature) {
		this.signature = signature;
		this.subpackets = signature.getHashedSubPackets();
	}
	
	/**
	 * Returns the type of signature {@code this} is.
	 */
	public SignatureType getSignatureType() {
		return IntegerEquivalents.fromInt(SignatureType.class, signature.getSignatureType());
	}
	
	/**
	 * Returns the {@link HashAlgorithm} used to make the signature.
	 */
	public HashAlgorithm getHashAlgorithm() {
		return IntegerEquivalents.fromInt(HashAlgorithm.class, signature.getHashAlgorithm());