List of usage examples for java.math BigInteger toString
public String toString()
From source file:com.bazaarvoice.jackson.rison.RisonGenerator.java
@Override public void writeNumber(BigInteger value) throws IOException, JsonGenerationException { _verifyValueWrite("write number"); if (value == null) { _writeNull();/*www .j a v a 2 s. c o m*/ } else if (_cfgNumbersAsStrings) { _writeQuotedRaw(value); } else { _writeRaw(value.toString()); } }
From source file:org.opendaylight.vpnservice.itm.confighelpers.ItmExternalTunnelAddWorker.java
private static boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gWIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Integer monitorInterval, IdManagerService idManagerService, DataBroker dataBroker, List<ListenableFuture<Void>> futures, WriteTransaction t) {/*from www . jav a 2s. c o m*/ IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); IpAddress gwyIpAddress = (srcSubnet.equals(dstSubnet)) ? gatewayIpObj : gWIp; String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId); String tunTypeStr = tunType.getName(); String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, srcIp.getIpv4Address().getValue(), dstIp.getIpv4Address().getValue(), tunTypeStr); logger.debug( " Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress); Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorInterval); InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class) .child(Interface.class, new InterfaceKey(tunnelIfName)).build(); logger.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf); t.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true); ItmUtils.itmCache.addInterface(extTunnelIf); InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child( ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType)); ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName); t.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true); ItmUtils.itmCache.addExternalTunnel(tnl); return true; }
From source file:com.mastercard.mcbp.utils.crypto.CryptoServiceImpl.java
/** * {@inheritDoc}//w w w.j av a2 s . c o m */ @Override public final int initRsaPrivateKey(final ByteArray primeP, final ByteArray primeQ, final ByteArray primeExponentP, final ByteArray primeExponentQ, final ByteArray crtCoefficient) throws McbpCryptoException { try { final BigInteger p = new BigInteger(primeP.toHexString(), 16); final BigInteger q = new BigInteger(primeQ.toHexString(), 16); final BigInteger dp = new BigInteger(primeExponentP.toHexString(), 16); final BigInteger dq = new BigInteger(primeExponentQ.toHexString(), 16); final BigInteger a = new BigInteger(crtCoefficient.toHexString(), 16); final BigInteger n = p.multiply(q); final BigInteger e = dp.modInverse(p.subtract(BigInteger.ONE)); final BigInteger d = e.modInverse(p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE)) .divide((p.subtract(BigInteger.ONE)).gcd(q.subtract(BigInteger.ONE)))); final RSAPrivateKey rsaKey = (RSAPrivateKey) KeyFactory.getInstance("RSA") .generatePrivate(new RSAPrivateCrtKeySpec(n, e, d, p, q, dp, dq, a)); initRsaPrivate(rsaKey); return n.bitLength() / 8; } catch (final NoSuchAlgorithmException | InvalidKeySpecException e) { throw new McbpCryptoException(e.toString()); } }
From source file:org.apache.pig.data.BinInterSedes.java
private void writeBigInteger(DataOutput out, BigInteger bi) throws IOException { writeDatum(out, bi.toString()); }
From source file:com.facebook.infrastructure.service.StorageService.java
public String getAppropriateToken(int count) { BigInteger token = BootstrapAndLbHelper.getTokenBasedOnPrimaryCount(count); return token.toString(); }
From source file:com.facebook.infrastructure.service.StorageService.java
public String getToken(EndPoint ep) { EndPoint ep2 = new EndPoint(ep.getHost(), DatabaseDescriptor.getStoragePort()); BigInteger token = tokenMetadata_.getToken(ep2); return (token == null) ? BigInteger.ZERO.toString() : token.toString(); }
From source file:com.spotify.reaper.cassandra.JmxProxy.java
public int triggerRepairPost2dot2(boolean fullRepair, RepairParallelism repairParallelism, String keyspace, Collection<String> columnFamilies, BigInteger beginToken, BigInteger endToken, String cassandraVersion) { Map<String, String> options = new HashMap<>(); options.put(RepairOption.PARALLELISM_KEY, repairParallelism.getName()); //options.put(RepairOption.PRIMARY_RANGE_KEY, Boolean.toString(primaryRange)); options.put(RepairOption.INCREMENTAL_KEY, Boolean.toString(!fullRepair)); options.put(RepairOption.JOB_THREADS_KEY, Integer.toString(1)); options.put(RepairOption.TRACE_KEY, Boolean.toString(Boolean.FALSE)); options.put(RepairOption.COLUMNFAMILIES_KEY, StringUtils.join(columnFamilies, ",")); //options.put(RepairOption.PULL_REPAIR_KEY, Boolean.FALSE); options.put(RepairOption.RANGES_KEY, beginToken.toString() + ":" + endToken.toString()); //options.put(RepairOption.DATACENTERS_KEY, StringUtils.join(specificDataCenters, ",")); //options.put(RepairOption.HOSTS_KEY, StringUtils.join(specificHosts, ",")); return ((StorageServiceMBean) ssProxy).repairAsync(keyspace, options); }
From source file:info.savestate.saveybot.JSONFileManipulator.java
public String saveSlot(String slotString, String username, String message) { BigInteger slot; try {// w w w.ja v a 2 s . c o m slot = new BigInteger(slotString); } catch (Exception e) { return "lmao bye af thats not a real number"; } JSONArray json = getJSON(); int replaceIndex = -1; for (int i = 0; i < json.length(); i++) { JSONObject o = json.getJSONObject(i); if (o == null) continue; BigInteger current = new BigInteger(o.getString("slot")); if (current.equals(slot)) { if (!o.getString("name").equals(username)) { return "waohwo!!! " + o.getString("name") + " owns this savestate you dong !!"; } else { replaceIndex = i; break; } } } JSONObject o = new JSONObject(); o.put("name", username); o.put("slot", slot.toString()); o.put("message", message); if (replaceIndex != -1) { json.remove(replaceIndex); json.put(replaceIndex, o); } else json.put(o); writeJSON(json); return "ur savestate was sav'd to slot " + slot.toString() + "! ^O^"; }
From source file:org.opendaylight.genius.itm.confighelpers.ItmExternalTunnelAddWorker.java
private static boolean wireUp(BigInteger dpnId, String portname, Integer vlanId, IpAddress srcIp, Boolean remoteIpFlow, String dstNodeId, IpAddress dstIp, IpPrefix srcSubnet, IpAddress gwIp, IpPrefix dstSubnet, Class<? extends TunnelTypeBase> tunType, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval, IdManagerService idManagerService, DataBroker dataBroker, List<ListenableFuture<Void>> futures, WriteTransaction transaction) {//from w w w .j a v a2 s . c o m IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); IpAddress gwyIpAddress = srcSubnet.equals(dstSubnet) ? gatewayIpObj : gwIp; String parentIf = ItmUtils.getInterfaceName(dpnId, portname, vlanId); String tunTypeStr = tunType.getName(); String tunnelIfName = ItmUtils.getTrunkInterfaceName(idManagerService, parentIf, new String(srcIp.getValue()), new String(dstIp.getValue()), tunTypeStr); LOG.debug( " Creating ExternalTrunk Interface with parameters Name - {}, parent I/f name - {}, " + "source IP - {}, destination IP - {} gateway IP - {}", tunnelIfName, parentIf, srcIp, dstIp, gwyIpAddress); Interface extTunnelIf = ItmUtils.buildTunnelInterface(dpnId, tunnelIfName, String.format("%s %s", tunType.getName(), "Trunk Interface"), true, tunType, srcIp, dstIp, gwyIpAddress, vlanId, false, monitorEnabled, monitorProtocol, monitorInterval, remoteIpFlow); InstanceIdentifier<Interface> ifIID = InstanceIdentifier.builder(Interfaces.class) .child(Interface.class, new InterfaceKey(tunnelIfName)).build(); LOG.trace(" Writing Trunk Interface to Config DS {}, {} ", ifIID, extTunnelIf); transaction.merge(LogicalDatastoreType.CONFIGURATION, ifIID, extTunnelIf, true); ItmUtils.itmCache.addInterface(extTunnelIf); InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child( ExternalTunnel.class, new ExternalTunnelKey(getExternalTunnelKey(dstNodeId), dpnId.toString(), tunType)); ExternalTunnel tnl = ItmUtils.buildExternalTunnel(dpnId.toString(), getExternalTunnelKey(dstNodeId), tunType, tunnelIfName); transaction.merge(LogicalDatastoreType.CONFIGURATION, path, tnl, true); ItmUtils.itmCache.addExternalTunnel(tnl); return true; }
From source file:be.fedict.trust.service.bean.ValidationServiceBean.java
public Date validate(BigInteger serialNumber, byte[] issuerNameHash, byte[] issuerKeyHash) { LOG.debug("validate"); Date unknownRevocationDate = new Date(); CertificateAuthorityEntity certificateAuthority = this.certificateAuthorityLookupBean.lookup(issuerNameHash, issuerKeyHash);//from w w w . j av a 2s .c o m if (null == certificateAuthority) { LOG.error("no certificate authority found"); return unknownRevocationDate; } String caName = certificateAuthority.getName(); LOG.debug("CA: " + caName); Date thisUpdate = certificateAuthority.getThisUpdate(); Date nextUpdate = certificateAuthority.getNextUpdate(); Date validationDate = new Date(); if (Status.ACTIVE != certificateAuthority.getStatus()) { LOG.debug("CRL cache not active for CA: " + caName); return unknownRevocationDate; } if (null == thisUpdate || validationDate.before(thisUpdate)) { LOG.debug("validation date before this update: " + caName); return unknownRevocationDate; } if (null == nextUpdate || validationDate.after(nextUpdate)) { LOG.debug("validation date after next update: " + caName); return unknownRevocationDate; } RevokedCertificateEntity revokedCertificate = this.entityManager.find(RevokedCertificateEntity.class, new RevokedCertificatePK(caName, serialNumber.toString())); if (null == revokedCertificate) { return null; } LOG.debug("revoked certificate: " + caName + " " + serialNumber); return revokedCertificate.getRevocationDate(); }