Example usage for org.bouncycastle.asn1.esf SignerLocation SignerLocation

List of usage examples for org.bouncycastle.asn1.esf SignerLocation SignerLocation

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.esf SignerLocation SignerLocation.

Prototype

public SignerLocation(DERUTF8String countryName, DERUTF8String localityName, ASN1Sequence postalAddress) 

Source Link

Usage

From source file:eu.europa.ec.markt.dss.signature.cades.CAdESLevelBaselineB.java

License:Open Source License

/**
 * ETSI TS 101 733 V2.2.1 (2013-04)//from   w ww.j  a  v a2s . c om
 * 5.11.2 signer-location Attribute
 * The signer-location attribute specifies a mnemonic for an address associated with the signer at a particular
 * geographical (e.g. city) location. The mnemonic is registered in the country in which the signer is located and is used in
 * the provision of the Public Telegram Service (according to Recommendation ITU-T F.1 [11]).
 * The signer-location attribute shall be a signed attribute.
 *
 * @param parameters
 * @param signedAttributes
 * @return
 */
private void addSignerLocation(final SignatureParameters parameters,
        final ASN1EncodableVector signedAttributes) {

    if (!padesUsage) {
        /*
         * In PAdES, the role is in the signature dictionary
           */
        final BLevelParameters.SignerLocation signerLocationParameter = parameters.bLevel().getSignerLocation();
        if (signerLocationParameter != null) {

            final DERUTF8String country = signerLocationParameter.getCountry() == null ? null
                    : new DERUTF8String(signerLocationParameter.getCountry());
            final DERUTF8String locality = signerLocationParameter.getLocality() == null ? null
                    : new DERUTF8String(signerLocationParameter.getLocality());
            final ASN1EncodableVector postalAddress = new ASN1EncodableVector();
            final List<String> postalAddressParameter = signerLocationParameter.getPostalAddress();
            if (postalAddressParameter != null) {

                for (final String addressLine : postalAddressParameter) {

                    postalAddress.add(new DERUTF8String(addressLine));
                }
            }
            final DERSequence derSequencePostalAddress = new DERSequence(postalAddress);
            final SignerLocation signerLocation = new SignerLocation(country, locality,
                    derSequencePostalAddress);
            final DERSet attrValues = new DERSet(signerLocation);
            final Attribute attribute = new Attribute(PKCSObjectIdentifiers.id_aa_ets_signerLocation,
                    attrValues);
            signedAttributes.add(attribute);
        }
    }
}

From source file:eu.europa.esig.dss.cades.signature.CAdESLevelBaselineB.java

License:Open Source License

/**
 * ETSI TS 101 733 V2.2.1 (2013-04)//from w w w . j a va 2s. c o  m
 * 5.11.2 signer-location Attribute
 * The signer-location attribute specifies a mnemonic for an address associated with the signer at a particular
 * geographical (e.g. city) location. The mnemonic is registered in the country in which the signer is located and
 * is used in
 * the provision of the Public Telegram Service (according to Recommendation ITU-T F.1 [11]).
 * The signer-location attribute shall be a signed attribute.
 *
 * @param parameters
 * @param signedAttributes
 * @return
 */
private void addSignerLocation(final CAdESSignatureParameters parameters,
        final ASN1EncodableVector signedAttributes) {

    if (!padesUsage) {
        /*
         * In PAdES, the role is in the signature dictionary
         */
        final eu.europa.esig.dss.SignerLocation signerLocationParameter = parameters.bLevel()
                .getSignerLocation();
        if (signerLocationParameter != null) {

            final DERUTF8String country = signerLocationParameter.getCountry() == null ? null
                    : new DERUTF8String(signerLocationParameter.getCountry());
            final DERUTF8String locality = signerLocationParameter.getLocality() == null ? null
                    : new DERUTF8String(signerLocationParameter.getLocality());
            final ASN1EncodableVector postalAddress = new ASN1EncodableVector();
            final List<String> postalAddressParameter = signerLocationParameter.getPostalAddress();
            if (postalAddressParameter != null) {
                for (final String addressLine : postalAddressParameter) {
                    postalAddress.add(new DERUTF8String(addressLine));
                }
            }
            final DERSequence derSequencePostalAddress = new DERSequence(postalAddress);
            final SignerLocation signerLocation = new SignerLocation(country, locality,
                    derSequencePostalAddress);
            final DERSet attrValues = new DERSet(signerLocation);
            final Attribute attribute = new Attribute(id_aa_ets_signerLocation, attrValues);
            signedAttributes.add(attribute);
        }
    }
}