org.bouncycastle.openpgp.PGPExtendedKeyAttribute Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpg-jdk14 Show documentation
Show all versions of bcpg-jdk14 Show documentation
The Bouncy Castle Java API for handling the OpenPGP protocol. This jar contains the OpenPGP API for JDK 1.4. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
package org.bouncycastle.openpgp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.bouncycastle.gpg.SExpression;
public class PGPExtendedKeyAttribute
{
private final List values;
public List getValues()
{
return values;
}
private PGPExtendedKeyAttribute(List values)
{
this.values = values;
}
public static Builder builder()
{
return new Builder();
}
public static class Builder
{
ArrayList values = new ArrayList ();
public Builder addAttribute(Object value)
{
if (value instanceof String || value instanceof SExpression.QuotedString)
{
this.values.add(value.toString());
}
else if (value instanceof byte[])
{
this.values.add(value);
}
else if (value instanceof SExpression)
{
Builder b = new Builder();
for (Iterator it = ((SExpression)value).getValues().iterator(); it.hasNext();)
{
b.addAttribute(it.next());
}
this.values.add(b.build());
}
else
{
throw new IllegalArgumentException("expected either string or SExpression object.");
}
return this;
}
public PGPExtendedKeyAttribute build()
{
return new PGPExtendedKeyAttribute(Collections.unmodifiableList(values));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy