org.bouncycastle.its.ETSIRecipientID Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-jdk15to18 Show documentation
Show all versions of bcpkix-jdk15to18 Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. This jar contains APIs for JDK 1.5 to JDK 1.8. 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.its;
import org.bouncycastle.oer.its.ieee1609dot2.PKRecipientInfo;
import org.bouncycastle.oer.its.ieee1609dot2.RecipientInfo;
import org.bouncycastle.oer.its.ieee1609dot2.basetypes.HashedId8;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Selector;
public class ETSIRecipientID
implements Selector
{
private final HashedId8 id;
public ETSIRecipientID(byte[] id)
{
this(new HashedId8(id));
}
public ETSIRecipientID(HashedId8 id)
{
this.id = id;
}
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (o == null || getClass() != o.getClass())
{
return false;
}
ETSIRecipientID that = (ETSIRecipientID)o;
return id != null ? id.equals(that.id) : that.id == null;
}
@Override
public int hashCode()
{
return id != null ? id.hashCode() : 0;
}
public boolean match(ETSIRecipientInfo obj)
{
if (obj.getRecipientInfo().getChoice() == RecipientInfo.certRecipInfo)
{
PKRecipientInfo objPkInfo = PKRecipientInfo.getInstance(obj.getRecipientInfo().getRecipientInfo());
return Arrays.areEqual(objPkInfo.getRecipientId().getHashBytes(), this.id.getHashBytes());
}
return false;
}
public Object clone()
{
return this;
}
}