*/
public Keyczar(KeyczarReader reader) throws KeyczarException {
// Reads keys from the KeyczarReader
kmd = KeyMetadata.read(reader.getMetadata());
if (!isAcceptablePurpose(kmd.getPurpose())) {
throw new KeyczarException(
Messages.getString("Keyczar.UnacceptablePurpose", kmd.getPurpose()));
}
if (kmd.isEncrypted() && !(reader instanceof EncryptedReader)) {
throw new KeyczarException(
Messages.getString("Keyczar.NeedEncryptedReader"));
}
for (KeyVersion version : kmd.getVersions()) {
if (version.getStatus() == KeyStatus.PRIMARY) {
if (primaryVersion != null) {
throw new KeyczarException(
Messages.getString("Keyczar.SinglePrimary"));
}
primaryVersion = version;
}
KeyczarKey key = KeyczarKey.readKey(kmd.getType(),