// 
// Decompiled by Procyon v0.6.0
// 

package com.google.crypto.tink;

import com.google.crypto.tink.internal.MonitoringAnnotations;
import java.util.Map;
import java.io.IOException;
import com.google.protobuf.InvalidProtocolBufferException;
import java.security.GeneralSecurityException;
import com.google.crypto.tink.proto.Keyset;
import com.google.protobuf.ExtensionRegistryLite;

public final class CleartextKeysetHandle
{
    @Deprecated
    public static final KeysetHandle parseFrom(final byte[] serialized) throws GeneralSecurityException {
        try {
            final Keyset keyset = Keyset.parseFrom(serialized, ExtensionRegistryLite.getEmptyRegistry());
            return KeysetHandle.fromKeyset(keyset);
        }
        catch (final InvalidProtocolBufferException e) {
            throw new GeneralSecurityException("invalid keyset");
        }
    }
    
    public static KeysetHandle read(final KeysetReader reader) throws GeneralSecurityException, IOException {
        return KeysetHandle.fromKeyset(reader.read());
    }
    
    @Deprecated
    public static KeysetHandle read(final KeysetReader reader, final Map<String, String> monitoringAnnotations) throws GeneralSecurityException, IOException {
        return KeysetHandle.fromKeysetAndAnnotations(reader.read(), MonitoringAnnotations.newBuilder().addAll(monitoringAnnotations).build());
    }
    
    @Deprecated
    public static Keyset getKeyset(final KeysetHandle keysetHandle) {
        return keysetHandle.getKeyset();
    }
    
    @Deprecated
    public static KeysetHandle fromKeyset(final Keyset keyset) throws GeneralSecurityException {
        return KeysetHandle.fromKeyset(keyset);
    }
    
    public static void write(final KeysetHandle handle, final KeysetWriter keysetWriter) throws IOException {
        keysetWriter.write(handle.getKeyset());
    }
    
    private CleartextKeysetHandle() {
    }
}
