/** * Returns a byte-array representation of a <code>BigInteger</code> without sign bit. * * @param bigInt * <code>BigInteger</code> to be converted * @return a byte array representation of the BigInteger parameter */ static byte[] toIntegerBytes(java.math.BigInteger bigInt) { int bitlen = bigInt.bitLength(); // round bitlen bitlen = ((bitlen + 7) >> 3) << 3; byte[] bigBytes = bigInt.toByteArray(); if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) { return(bigBytes); } // set up params for copying everything but sign bit int startSrc = 0; int len = bigBytes.Length; // if bigInt is exactly byte-aligned, just skip signbit in copy if ((bigInt.bitLength() % 8) == 0) { startSrc = 1; len--; } int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec byte[] resizedBytes = new byte[bitlen / 8]; java.lang.SystemJ.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len); return(resizedBytes); }
/** * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature * * @param bigInt * a BigInteger * @return A byte array containing base64 character data * @throws NullPointerException * if null is passed in * @since 1.4 */ public static byte[] encodeInteger(java.math.BigInteger bigInt) { if (bigInt == null) { throw new java.lang.NullPointerException("encodeInteger called with null parameter"); } return(encodeBase64(toIntegerBytes(bigInt), false)); }
/* * Returns a hash code consistent with the definition of the equals method. * * @see Object#hashCode() */ // default method not twice declared //public abstract int GetHashCode(); /* * <p>Returns a <code>String</code> representation of this <code>Duration</code> <code>Object</code>.</p> * * <p>The result is formatted according to the XML Schema 1.0 spec and can be always parsed back later into the * equivalent <code>Duration</code> <code>Object</code> by {@link DatatypeFactory#newDuration(String lexicalRepresentation)}.</p> * * <p>Formally, the following holds for any <code>Duration</code> * <code>Object</code> x:</p> * <pre> * new Duration(x.toString()).equals(x) * </pre> * * @return A non-<code>null</code> valid <code>String</code> representation of this <code>Duration</code>. */ public override String ToString() { java.lang.StringBuffer buf = new java.lang.StringBuffer(); if (getSign() < 0) { buf.append('-'); } buf.append('P'); java.math.BigInteger years = (java.math.BigInteger)getField(DatatypeConstants.YEARS); if (years != null) { buf.append(years + "Y"); } java.math.BigInteger months = (java.math.BigInteger)getField(DatatypeConstants.MONTHS); if (months != null) { buf.append(months + "M"); } java.math.BigInteger days = (java.math.BigInteger)getField(DatatypeConstants.DAYS); if (days != null) { buf.append(days + "D"); } java.math.BigInteger hours = (java.math.BigInteger)getField(DatatypeConstants.HOURS); java.math.BigInteger minutes = (java.math.BigInteger)getField(DatatypeConstants.MINUTES); java.math.BigDecimal seconds = (java.math.BigDecimal)getField(DatatypeConstants.SECONDS); if (hours != null || minutes != null || seconds != null) { buf.append('T'); if (hours != null) { buf.append(hours + "H"); } if (minutes != null) { buf.append(minutes + "M"); } if (seconds != null) { buf.append(toString(seconds) + "S"); } } return(buf.toString()); }
/** * <p>Set low and high order component of XSD <code>dateTime</code> year field.</p> * * <p>Unset this field by invoking the setter with a parameter value of <code>null</code>.</p> * * @param year value constraints summarized in <a href="#datetimefield-year">year field of date/time field mapping table</a>. * * @throws IllegalArgumentException if <code>year</code> parameter is * outside value constraints for the field as specified in * <a href="#datetimefieldmapping">date/time field mapping table</a>. */ public abstract void setYear(java.math.BigInteger year);
/* * Creates an <code>X509IssuerSerial</code> from the specified X.500 issuer * distinguished name and serial number. * * @param issuerName the issuer's distinguished name in RFC 2253 String * format. Implementations MUST support the attribute type keywords * defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC and UID). * Implementations MAY support additional keywords. * @param serialNumber the serial number * @return an <code>X509IssuerSerial</code> * @throws NullPointerException if <code>issuerName</code> or * <code>serialNumber</code> are <code>null</code> * @throws IllegalArgumentException if the issuer name is not RFC 2253 * compliant or one of the attribute type keywords is not recognized. */ public abstract X509IssuerSerial newX509IssuerSerial (String issuerName, java.math.BigInteger serialNumber);