List of usage examples for java.math BigInteger valueOf
private static BigInteger valueOf(int val[])
From source file:eu.dety.burp.joseph.attacks.bleichenbacher_pkcs1.BleichenbacherPkcs1DecryptionAttackExecutor.java
@Override // Fire prepared request and return responses as IHttpRequestResponse protected Integer doInBackground() throws Exception { int i = 0;//from w w w .j a va2 s . c om boolean solutionFound = false; this.c0 = BigInteger.ZERO; this.si = BigInteger.ZERO; this.m = null; this.blockSize = this.pubKey.getModulus().bitLength() / 8; this.httpService = this.requestResponse.getHttpService(); // b computation int tmp = this.pubKey.getModulus().bitLength(); while (tmp % 8 != 0) { tmp++; } tmp = ((tmp / 8) - 2) * 8; this.bigB = BigInteger.valueOf(2).pow(tmp); loggerInstance.log(getClass(), "B computed: " + this.bigB.toString(16), Logger.LogLevel.INFO); loggerInstance.log(getClass(), "Blocksize: " + blockSize + " bytes", Logger.LogLevel.INFO); String[] components = Decoder.getComponents(this.parameter.getJoseValue()); encryptedKey = Base64.decodeBase64(components[1]); loggerInstance.log(getClass(), "Step 1: Blinding", Logger.LogLevel.INFO); if (this.msgIsPkcs) { loggerInstance.log(getClass(), "Step skipped --> " + "Message is considered as PKCS compliant.", Logger.LogLevel.INFO); this.s0 = BigInteger.ONE; this.c0 = new BigInteger(1, this.encryptedKey); this.m = new Interval[] { new Interval(BigInteger.valueOf(2).multiply(this.bigB), (BigInteger.valueOf(3).multiply(this.bigB)).subtract(BigInteger.ONE)) }; } else { stepOne(); } i++; while (!solutionFound) { // Check if user has cancelled the worker if (isCancelled()) { loggerInstance.log(getClass(), "Decryption Attack Executor Worker cancelled by user", Logger.LogLevel.INFO); return 0; } loggerInstance.log(getClass(), "Step 2: Searching for PKCS conforming messages.", Logger.LogLevel.INFO); try { stepTwo(i); } catch (Exception e) { loggerInstance.log(getClass(), "Error in stepTwo: " + e.getMessage(), Logger.LogLevel.INFO); } loggerInstance.log(getClass(), "Step 3: Narrowing the set of soultions.", Logger.LogLevel.INFO); stepThree(i); loggerInstance.log(getClass(), "Step 4: Computing the solution.", Logger.LogLevel.INFO); solutionFound = stepFour(); i++; } return 1; }
From source file:de.tudarmstadt.ukp.dkpro.core.decompounding.web1t.Finder.java
public BigInteger freq(String aUnigram) { BigInteger f = (BigInteger) unigramCache.get(aUnigram); if (f != null) { return f; }/*w w w .j a va 2 s. c om*/ // System.out.printf("Frequency for [%s]... ", aUnigram); try { f = BigInteger.valueOf(web1tSearcher.getFrequency(aUnigram)); // System.out.printf("%d%n", f.longValue()); unigramCache.put(aUnigram, f); return f; } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:io.syndesis.rest.v1.handler.integration.IntegrationHandler.java
@Override public Integration get(String id) { Integration integration = Getter.super.get(id); if (Status.Deleted.equals(integration.getCurrentStatus().get()) || Status.Deleted.equals(integration.getDesiredStatus().get())) { //Not sure if we need to do that for both current and desired status, //but If we don't do include the desired state, IntegrationITCase is not going to pass anytime soon. Why? //Cause that test, is using NoopHandlerProvider, so that means no controllers. throw new EntityNotFoundException( String.format("Integration %s has been deleted", integration.getId())); }/*from w w w . j a va 2 s . c om*/ //fudging the timesUsed for now Optional<Status> currentStatus = integration.getCurrentStatus(); if (currentStatus.isPresent() && currentStatus.get() == Integration.Status.Activated) { return new Integration.Builder().createFrom(integration) .timesUsed(BigInteger.valueOf(new Date().getTime() / 1000000)).build(); } return integration; }
From source file:com.projity.server.data.mspdi.TimephasedGetter.java
private TimephasedGetter(ObjectFactory factory, TimephasedConsumer consumer, AssignmentFieldFunctor functor, int type, long id) { this.factory = factory; this.consumer = consumer; this.functor = functor; this.type = BigInteger.valueOf(type); this.id = BigInteger.valueOf(id); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsUserWriterTest.java
/** * Build the items to write.//from w ww . j a v a 2s . com * * @return items to write */ private List<AccountData> buildItems() { final List<AccountData> items = new ArrayList<AccountData>(); final AccountData item1 = new AccountData(); item1.setId(BigInteger.valueOf(1)); item1.setName("new_user_1"); final AccountData item2 = new AccountData(); item2.setId(BigInteger.valueOf(2)); item2.setName("new_user_2"); items.add(item1); items.add(item2); return items; }
From source file:net.ripe.ipresource.IpRange.java
public List<IpRange> splitToPrefixes() { BigInteger rangeEnd = getEnd().getValue(); BigInteger currentRangeStart = getStart().getValue(); int startingPrefixLength = getType().getBitSize(); List<IpRange> prefixes = new LinkedList<IpRange>(); while (currentRangeStart.compareTo(rangeEnd) <= 0) { int maximumPrefixLength = getMaximumLengthOfPrefixStartingAtIpAddressValue(currentRangeStart, startingPrefixLength);//from w ww . ja va2s . c om BigInteger maximumSizeOfPrefix = rangeEnd.subtract(currentRangeStart).add(BigInteger.ONE); BigInteger currentSizeOfPrefix = BigInteger.valueOf(2).pow(maximumPrefixLength); while ((currentSizeOfPrefix.compareTo(maximumSizeOfPrefix) > 0) && (maximumPrefixLength > 0)) { maximumPrefixLength--; currentSizeOfPrefix = BigInteger.valueOf(2).pow(maximumPrefixLength); } BigInteger currentRangeEnd = currentRangeStart .add(BigInteger.valueOf(2).pow(maximumPrefixLength).subtract(BigInteger.ONE)); IpRange prefix = (IpRange) IpResourceRange.assemble(currentRangeStart, currentRangeEnd, getType()); prefixes.add(prefix); currentRangeStart = currentRangeEnd.add(BigInteger.ONE); } return prefixes; }
From source file:energy.usef.dso.service.business.DsoPlanboardValidatorServiceTest.java
@Test public void testInValidPTU() throws BusinessValidationException, IOException { Prognosis prognosis = buildPrognosisMessage(); prognosis.getPTU().get(0).setDuration(BigInteger.valueOf(2)); try {/*from w w w . j a v a 2s. c om*/ service.validatePtus(prognosis.getPTU()); } catch (BusinessValidationException e) { Assert.assertEquals(DsoBusinessError.PTUS_INCOMPLETE, e.getBusinessError()); return; } fail("expected exception"); }
From source file:net.sf.jasperreports.engine.data.JRAbstractTextDataSource.java
protected Object convertNumber(Number number, Class<?> valueClass) throws JRException { Number value = null;//from www . ja v a 2 s . com if (valueClass.equals(Byte.class)) { value = number.byteValue(); } else if (valueClass.equals(Short.class)) { value = number.shortValue(); } else if (valueClass.equals(Integer.class)) { value = number.intValue(); } else if (valueClass.equals(Long.class)) { value = number.longValue(); } else if (valueClass.equals(Float.class)) { value = number.floatValue(); } else if (valueClass.equals(Double.class)) { value = number.doubleValue(); } else if (valueClass.equals(BigInteger.class)) { value = BigInteger.valueOf(number.longValue()); } else if (valueClass.equals(BigDecimal.class)) { value = new BigDecimal(Double.toString(number.doubleValue())); } else { throw new JRException(EXCEPTION_MESSAGE_KEY_UNKNOWN_NUMBER_TYPE, new Object[] { valueClass.getName() }); } return value; }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) private static void generateNewKeyOld(Context context) { try {/*from ww w .ja va 2 s. c o m*/ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, KEY_PROVIDER); Calendar instance = Calendar.getInstance(); Date start = instance.getTime(); instance.add(Calendar.YEAR, 1); Date end = instance.getTime(); keyPairGenerator.initialize(new KeyPairGeneratorSpec.Builder(context).setAlias(KEY_ALIAS) .setSubject(new X500Principal("CN=" + KEY_ALIAS)).setSerialNumber(BigInteger.valueOf(20151021)) .setStartDate(start).setEndDate(end).build()); keyPairGenerator.generateKeyPair(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (NoSuchProviderException e) { e.printStackTrace(); } catch (InvalidAlgorithmParameterException e) { e.printStackTrace(); } }
From source file:gov.nih.nci.cabig.caaers.api.BlankFormGenerator.java
public String serialize(Study study, Epoch epoch) throws Exception { jaxbContext = JAXBContext.newInstance("gov.nih.nci.cabig.caaers.integration.schema.study"); marshaller = jaxbContext.createMarshaller(); StringWriter sw = new StringWriter(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); studies = new Studies(); List<gov.nih.nci.cabig.caaers.integration.schema.study.Study> list = new ArrayList(); gov.nih.nci.cabig.caaers.integration.schema.study.Study wsStudy = new gov.nih.nci.cabig.caaers.integration.schema.study.Study(); wsStudy.setShortTitle(study.getShortTitle()); wsStudy.setLongTitle(study.getLongTitle()); wsStudy.setId(BigInteger.valueOf(study.getId())); gov.nih.nci.cabig.caaers.integration.schema.study.Study.Identifiers studyIdentifiers = new gov.nih.nci.cabig.caaers.integration.schema.study.Study.Identifiers(); SystemAssignedIdentifierType i = new SystemAssignedIdentifierType(); i.setPrimaryIndicator(true);//from www .j a v a 2s.co m i.setValue(study.getPrimaryIdentifierValue()); List<SystemAssignedIdentifierType> iSystemAssigned = new ArrayList<SystemAssignedIdentifierType>(); iSystemAssigned.add(i); studyIdentifiers.setSystemAssignedIdentifier(iSystemAssigned); wsStudy.setIdentifiers(studyIdentifiers); EvaluationPeriodType ept = new EvaluationPeriodType(); EvaluationPeriodType.SolicitedAdverseEvents wsSAE = new EvaluationPeriodType.SolicitedAdverseEvents(); List<SolicitedAdverseEventType> wsSAET = new ArrayList<SolicitedAdverseEventType>(); if (epoch != null) { ept.setName(epoch.getName()); ept.setDescriptionText(epoch.getDescriptionText()); ept.setSolicitedAdverseEvents(new EvaluationPeriodType.SolicitedAdverseEvents()); for (SolicitedAdverseEvent domainSAE : epoch.getArms().get(0).getSolicitedAdverseEvents()) { SolicitedAdverseEventType saet = new SolicitedAdverseEventType(); if (domainSAE.getCtcterm() != null) saet.setName(domainSAE.getCtcterm().getTerm()); if (domainSAE.getLowLevelTerm() != null) saet.setName(domainSAE.getLowLevelTerm().getMeddraTerm()); wsSAET.add(saet); } } wsSAE.setSolicitedAdverseEvent(wsSAET); ept.setSolicitedAdverseEvents(wsSAE); gov.nih.nci.cabig.caaers.integration.schema.study.Study.EvaluationPeriods eps = new gov.nih.nci.cabig.caaers.integration.schema.study.Study.EvaluationPeriods(); List<EvaluationPeriodType> eptl = new ArrayList<EvaluationPeriodType>(); eptl.add(ept); eps.setEvaluationPeriod(eptl); wsStudy.setEvaluationPeriods(eps); list.add(wsStudy); studies.setStudy(list); marshaller.marshal(studies, sw); // marshaller.marshal(studies, new FileOutputStream(XMLFile)); return sw.toString(); }