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

org.bouncycastle.asn1.x509.qualified.MonetaryValue Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7. Note: this package includes the IDEA and NTRU encryption algorithms.

There is a newer version: 1.70
Show newest version
package org.bouncycastle.asn1.x509.qualified;

import java.math.BigInteger;
import java.util.Enumeration;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;

/**
 * The MonetaryValue object.
 * 
 * MonetaryValue  ::=  SEQUENCE {
 *       currency              Iso4217CurrencyCode,
 *       amount               INTEGER, 
 *       exponent             INTEGER }
 * -- value = amount * 10^exponent
 * 
*/ public class MonetaryValue extends ASN1Object { private Iso4217CurrencyCode currency; private ASN1Integer amount; private ASN1Integer exponent; public static MonetaryValue getInstance( Object obj) { if (obj instanceof MonetaryValue) { return (MonetaryValue)obj; } if (obj != null) { return new MonetaryValue(ASN1Sequence.getInstance(obj)); } return null; } private MonetaryValue( ASN1Sequence seq) { Enumeration e = seq.getObjects(); // currency currency = Iso4217CurrencyCode.getInstance(e.nextElement()); // hashAlgorithm amount = ASN1Integer.getInstance(e.nextElement()); // exponent exponent = ASN1Integer.getInstance(e.nextElement()); } public MonetaryValue( Iso4217CurrencyCode currency, int amount, int exponent) { this.currency = currency; this.amount = new ASN1Integer(amount); this.exponent = new ASN1Integer(exponent); } public Iso4217CurrencyCode getCurrency() { return currency; } public BigInteger getAmount() { return amount.getValue(); } public BigInteger getExponent() { return exponent.getValue(); } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector seq = new ASN1EncodableVector(); seq.add(currency); seq.add(amount); seq.add(exponent); return new DERSequence(seq); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy