Example usage for java.math BigInteger ONE

List of usage examples for java.math BigInteger ONE

Introduction

In this page you can find the example usage for java.math BigInteger ONE.

Prototype

BigInteger ONE

To view the source code for java.math BigInteger ONE.

Click Source Link

Document

The BigInteger constant one.

Usage

From source file:eu.dety.burp.joseph.attacks.bleichenbacher_pkcs1.BleichenbacherPkcs1DecryptionAttackExecutor.java

private BigInteger step3ComputeLowerBound(final BigInteger s, final BigInteger modulus,
        final BigInteger lowerIntervalBound) {
    BigInteger lowerBound = lowerIntervalBound.multiply(s);
    lowerBound = lowerBound.subtract(BigInteger.valueOf(3).multiply(this.bigB));
    lowerBound = lowerBound.add(BigInteger.ONE);
    lowerBound = lowerBound.divide(modulus);

    return lowerBound;
}

From source file:com.otterca.common.crypto.acceptance.X509CertificateBuilderAcceptanceTest.java

/**
 * Test builder when missing issuer./*from   w  ww .  jav  a 2s .  c  o  m*/
 * 
 * @throws Exception
 */
@Test(expectedExceptions = X509CertificateBuilderException.class)
public void testBuilderMissingIssuer() throws GeneralSecurityException {
    serial = serial.add(BigInteger.ONE);
    builder.setSerialNumber(serial);
    builder.setSubject(SUBJECT_NAME);
    builder.setNotBefore(notBefore.getTime());
    builder.setNotAfter(notAfter.getTime());
    builder.setPublicKey(keyPair.getPublic());
    builder.build(keyPair.getPrivate());
}

From source file:com.offbynull.peernetic.playground.chorddht.model.FingerTable.java

/**
 * Get the id of other nodes that should have this node in its finger table. For example, for a 16 node ring with base id 8, router
 * position 0 expects 7, router position 1 expects 6, router position 2 expects 4, and router position 3 expects 0. For more
 * information, see Chord research paper.
 * @param idx router position to get expected id for
 * @return expected id for a specific router position
 * @throws IllegalArgumentException if {@code idx < 0 || idx > table.size()} (size of table = bit size of base pointer's limit)
 *///from w w w  . jav a2  s  . c o  m
public Id getRouterId(int idx) {
    Validate.inclusiveBetween(0, table.size() - 1, idx);

    BigInteger data = BigInteger.ONE.shiftLeft(idx);
    byte[] offsetIdRaw = data.toByteArray();
    Id offsetId = new Id(offsetIdRaw, basePtr.getId().getLimitAsByteArray());
    Id routerId = Id.subtract(getBaseId(), offsetId);

    return routerId;
}

From source file:net.pms.util.Rational.java

/**
 * Returns an instance with the given {@code numerator} and
 * {@code denominator}.//w w w.j  ava  2s  . c o m
 *
 * @param numerator the numerator.
 * @param denominator the denominator.
 * @return An instance that represents the value of {@code numerator}/
 *         {@code denominator}.
 */
@Nullable
public static Rational valueOf(@Nullable BigInteger numerator, @Nullable BigInteger denominator) {
    if (numerator == null || denominator == null) {
        return null;
    }
    if (numerator.signum() == 0 && denominator.signum() == 0) {
        return NaN;
    }
    if (denominator.signum() == 0) {
        return numerator.signum() > 0 ? POSITIVE_INFINITY : NEGATIVE_INFINITY;
    }
    if (numerator.signum() == 0) {
        return ZERO;
    }
    if (numerator.equals(denominator)) {
        return ONE;
    }
    if (denominator.signum() < 0) {
        numerator = numerator.negate();
        denominator = denominator.negate();
    }

    BigInteger reducedNumerator;
    BigInteger reducedDenominator;
    BigInteger greatestCommonDivisor = calculateGreatestCommonDivisor(numerator, denominator);
    if (BigInteger.ONE.equals(greatestCommonDivisor)) {
        reducedNumerator = numerator;
        reducedDenominator = denominator;
    } else {
        reducedNumerator = numerator.divide(greatestCommonDivisor);
        reducedDenominator = denominator.divide(greatestCommonDivisor);
    }
    return new Rational(numerator, denominator, greatestCommonDivisor, reducedNumerator, reducedDenominator);
}

From source file:com.otterca.common.crypto.acceptance.X509CertificateBuilderAcceptanceTest.java

/**
 * Test builder when missing 'not before' date.
 * /*from ww  w  .  ja  va2  s. c  om*/
 * @throws Exception
 */
@Test(expectedExceptions = X509CertificateBuilderException.class)
public void testBuilderMissingNotBefore() throws GeneralSecurityException {
    serial = serial.add(BigInteger.ONE);
    builder.setSerialNumber(serial);
    builder.setSubject(SUBJECT_NAME);
    builder.setIssuer(SUBJECT_NAME);
    builder.setNotAfter(notAfter.getTime());
    builder.setPublicKey(keyPair.getPublic());
    builder.build(keyPair.getPrivate());
}

From source file:org.estatio.dom.lease.LeaseTerm.java

@Programmatic
protected final void initialize() {
    setStatus(LeaseTermStatus.NEW);//from   w w w .j a  va  2 s. c o m
    LeaseTerm previousTerm = getPrevious();
    BigInteger sequence = BigInteger.ONE;
    if (previousTerm != null) {
        sequence = previousTerm.getSequence().add(BigInteger.ONE);
        setFrequency(previousTerm.getFrequency());
    }
    setSequence(sequence);
    doInitialize();
}

From source file:de.fuberlin.wiwiss.r2r.Mapping.java

private String buildQueryWithContext(Collection<Mapping> contextMappings) {
    StringBuilder sb = new StringBuilder();
    //Prefixes and maxVarLength
    Integer maxvarLength = sourcePattern.getMaxVarLength();
    Set<String> prefixDependencies = new HashSet<String>();
    prefixDependencies.addAll(sourcePattern.getPrefixDefinitions());
    if (contextMappings != null)
        for (Mapping contextMapping : contextMappings) {
            prefixDependencies.addAll(contextMapping.sourcePattern.getPrefixDefinitions());
            if (contextMapping.sourcePattern.getMaxVarLength() > maxvarLength)
                maxvarLength = contextMapping.sourcePattern.getMaxVarLength();
        }/*  w w  w.  j  a v a  2 s  .c om*/

    sb.append(createPrefixPartOfQuery(contextMappings, prefixDependencies));

    sb.append("SELECT ");
    Set<String> varDependencies = computeQueryVariableDependencies();
    if (varDependencies.size() == 0)
        sb.append(" ?SUBJ");
    for (String var : varDependencies) {
        sb.append(" ?" + var);
    }
    sb.append("\nWHERE {");
    sb.append("{");
    sb.append(sourcePattern.getQueryBody());
    sb.append("}");
    if (contextMappings != null) {
        String rewriteVar = getVarnameOfLength(maxvarLength);
        StringGenerator sg = new EnumeratingURIGenerator(rewriteVar, BigInteger.ONE);
        for (Mapping contextMapping : contextMappings) {
            // rewrite source pattern to avoid variable collision
            String sp = SourcePattern.rewriteSourcePattern(contextMapping.sourcePattern.getQueryBody(), sg);
            sb.append("{");
            sb.append(sp);
            sb.append("}");
        }
    }
    sb.append(" }");
    return sb.toString();
}

From source file:com.otterca.common.crypto.acceptance.X509CertificateBuilderAcceptanceTest.java

/**
 * Test builder when missing 'not after' date.
 * //from  ww w  .  j  ava 2 s .  co  m
 * @throws Exception
 */
@Test(expectedExceptions = X509CertificateBuilderException.class)
public void testBuilderMissingNotAfter() throws GeneralSecurityException {
    serial = serial.add(BigInteger.ONE);
    builder.setSerialNumber(serial);
    builder.setSubject(SUBJECT_NAME);
    builder.setIssuer(SUBJECT_NAME);
    builder.setNotBefore(notBefore.getTime());
    builder.setPublicKey(keyPair.getPublic());
    builder.build(keyPair.getPrivate());
}

From source file:com.otterca.common.crypto.acceptance.X509CertificateBuilderAcceptanceTest.java

/**
 * Test builder when missing public key.
 * /*from   ww w. j a v  a 2s . c o m*/
 * @throws Exception
 */
@Test(expectedExceptions = X509CertificateBuilderException.class)
public void testBuilderMissingPublicKey() throws GeneralSecurityException {
    serial = serial.add(BigInteger.ONE);
    builder.setSerialNumber(serial);
    builder.setSubject(SUBJECT_NAME);
    builder.setIssuer(SUBJECT_NAME);
    builder.setNotBefore(notBefore.getTime());
    builder.setNotAfter(notAfter.getTime());
    builder.build(keyPair.getPrivate());
}

From source file:org.mule.module.extension.internal.capability.xml.schema.SchemaBuilder.java

private void generateCollectionElement(ExplicitGroup all, String name, String description, DataType type,
        boolean required) {
    name = hyphenize(name);//  w  w  w  .j  a v a  2 s.c  om

    BigInteger minOccurs = required ? BigInteger.ONE : BigInteger.ZERO;
    String collectionName = hyphenize(NameUtils.singularize(name));
    LocalComplexType collectionComplexType = generateCollectionComplexType(collectionName, description, type);

    TopLevelElement collectionElement = new TopLevelElement();
    collectionElement.setName(name);
    collectionElement.setMinOccurs(minOccurs);
    collectionElement.setMaxOccurs("1");
    collectionElement.setAnnotation(createDocAnnotation(description));
    all.getParticle().add(objectFactory.createElement(collectionElement));

    collectionElement.setComplexType(collectionComplexType);
}