All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.its.ETSIRecipientID Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, and certificate generation. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified.

There is a newer version: 2.1.9
Show newest version
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;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy