/** only for testing with main() */ private Blocklist() { _context = null; _log = new Log(Blocklist.class); _blocklistFeedFile = new File(BLOCKLIST_FEED_FILE); }
/** * Usage: NtpClient [-6] [servers...] * default pool.ntp.org */ public static void main(String[] args) throws IOException { boolean ipv6 = false; if (args.length > 0 && args[0].equals("-6")) { ipv6 = true; if (args.length == 1) args = new String[0]; else args = Arrays.copyOfRange(args, 1, args.length); } if (args.length <= 0) { args = new String[] { "pool.ntp.org" }; } System.out.println("Querying " + Arrays.toString(args)); Log log = new Log(NtpClient.class); try { long[] rv = currentTimeAndStratum(args, DEFAULT_TIMEOUT, ipv6, log); System.out.println("Current time: " + new java.util.Date(rv[0]) + " (stratum " + rv[1] + ") offset " + (rv[0] - System.currentTimeMillis()) + "ms"); } catch (IllegalArgumentException iae) { System.out.println("Failed: " + iae.getMessage()); } }
public Log getLog(Class<?> cls, String name) { String scope = Log.getScope(name, cls); boolean isNew = false; Log rv = _logs.get(scope); if (rv == null) { rv = new Log(this, cls, name); Log old = _logs.putIfAbsent(scope, rv); isNew = old == null; if (!isNew) rv = old; } if (isNew) updateLimit(rv); return rv; }
/** * Merge and compress CSV files to I2P compressed format * * GeoIPv6 infile1.csv[.gz] [infile2.csv[.gz]...] outfile.dat.gz * * Used to create the file for distribution, do not comment out */ public static void main(String args[]) { if (args.length < 2) { System.err.println("Usage: GeoIPv6 infile1.csv [infile2.csv...] outfile.dat.gz"); System.exit(1); } List<File> infiles = new ArrayList<File>(); for (int i = 0; i < args.length - 1; i++) { infiles.add(new File(args[i])); } File outfile = new File(args[args.length - 1]); boolean success = compressGeoIPv6CSVFiles(infiles, outfile); if (!success) { System.err.println("Failed"); System.exit(1); } // readback for testing readGeoIPFile(outfile, new Long[] { Long.MAX_VALUE }, Collections.<String, String> emptyMap(), new Log(GeoIPv6.class)); } }
@Override public final void run() { try { this.ss = new InternalServerSocket(this.port); this.open = true; while (this.open) { Socket s = this.ss.accept(); this.client.manageConnection(s); } } catch (IOException ex) { if (this.open) { Log log = new Log(InternalSocketRunner.class); log.error("Error listening for internal connections on port " + this.port, ex); stopRunning(); } } }
/** Returns the MIME type of the picture, for example <code>image/jpeg</code>. */ public static String getPictureType(byte[] picture) { ByteArrayInputStream stream = new ByteArrayInputStream(picture); try { return URLConnection.guessContentTypeFromStream(stream); } catch (IOException e) { new Log(Util.class).error("Can't read from ByteArrayInputStream", e); return null; } }
/** * Opens an <code>InputStream</code> and reads one line at a time. * Returns the lines as a <code>List</code> of <code>String</code>s. * or an empty <code>List</code> if an error occurred. * @param inputStream * @see #readLines(URL) */ public static List<String> readLines(InputStream inputStream) throws IOException { Log log = new Log(Util.class); BufferedReader inputBuffer = new BufferedReader(new InputStreamReader(inputStream)); List<String> lines = new ArrayList<String>(); while (true) { String line = null; line = inputBuffer.readLine(); if (line == null) break; lines.add(line); } log.info(lines.size() + " lines read."); return lines; }
protected static Class<? extends I2PBotePacket> decodePacketTypeCode(char packetTypeCode) { for (Class<? extends I2PBotePacket> packetType: ALL_PACKET_TYPES) if (packetType.getAnnotation(TypeCode.class).value() == packetTypeCode) return packetType; Log log = new Log(I2PBotePacket.class); log.debug("Invalid type code for I2PBotePacket: <" + packetTypeCode + ">"); return null; }
public static String getReplyAddress(Email email, Identities identities) throws PasswordException { try { return email.getReplyAddress(identities); } catch (PasswordException e) { throw e; } catch (Exception e) { new Log(GeneralHelper.class).error("Can't get address to reply to.", e); return null; } }
public static void modifyIdentity(String key, String publicName, String description, String pictureBase64, String emailAddress, Properties config, boolean setDefault) throws GeneralSecurityException, PasswordException, IOException { try { createOrModifyIdentity(false, -1, null, key, publicName, description, pictureBase64, emailAddress, config, setDefault); } catch (IllegalDestinationParametersException e) { Log log = new Log(GeneralHelper.class); log.error("This shouldn't happen because no identity is being created here.", e); } }
/** * Encrypts the array {@link FileEncryptionConstants#PASSWORD_FILE_PLAIN_TEXT} with a * password and writes the encrypted data to a file. * @param passwordFile * @param password * @param newKey * @throws IOException */ public static void writePasswordFile(File passwordFile, byte[] password, DerivedKey newKey) throws IOException { if (password==null || password.length==0) { if (!passwordFile.delete()) new Log(FileEncryptionUtil.class).error("Can't delete file: " + passwordFile.getAbsolutePath()); return; } EncryptedOutputStream outputStream = null; try { outputStream = new EncryptedOutputStream(new FileOutputStream(passwordFile), newKey); outputStream.write(PASSWORD_FILE_PLAIN_TEXT); } catch (IOException e) { new Log(FileEncryptionUtil.class).error("Can't write password file <" + passwordFile.getAbsolutePath() + ">", e); throw e; } finally { if (outputStream != null) outputStream.close(); } }
Log log = new Log(CommunicationPacket.class); log.error("Packet data is null"); return null; Log log = new Log(CommunicationPacket.class); log.error("Packet is too short to be a CommunicationPacket"); return null; Class<? extends I2PBotePacket> packetType = decodePacketTypeCode(packetTypeCode); if (packetType==null || !CommunicationPacket.class.isAssignableFrom(packetType)) { Log log = new Log(CommunicationPacket.class); log.error("Type code is not a CommunicationPacket type code: <" + packetTypeCode + ">"); return null;
/** * Opens a <code>File</code> and reads one line at a time. * Returns the lines as a <code>List</code> of <code>String</code>s, * or an empty <code>List</code> if an error occurred. * @param file * @see #readLines(URL) */ public static List<String> readLines(File file) { Log log = new Log(Util.class); log.info("Reading file: <" + file.getAbsolutePath() + ">"); InputStream stream = null; try { stream = new FileInputStream(file); return readLines(stream); } catch (IOException e) { log.error("Error reading file.", e); return Collections.emptyList(); } finally { if (stream != null) try { stream.close(); } catch (IOException e) { log.error("Can't close input stream.", e); } } }
Log log = new Log(I2PBotePacket.class); log.error("Can't close stream.", e);
/** * Opens a <code>URL</code> and reads one line at a time. * Returns the lines as a <code>List</code> of <code>String</code>s, * or an empty <code>List</code> if an error occurred. * @param url * @see #readLines(File) */ public static List<String> readLines(URL url) { Log log = new Log(Util.class); log.info("Reading URL: <" + url + ">"); InputStream stream = null; try { stream = url.openStream(); return readLines(stream); } catch (IOException e) { log.error("Error reading URL.", e); return Collections.emptyList(); } finally { if (stream != null) try { stream.close(); } catch (IOException e) { log.error("Can't close input stream.", e); } } }
private static void init() { instances = Collections.synchronizedList(new ArrayList<CryptoImplementation>()); Log log = new Log(CryptoFactory.class); try { instances.add(new ElGamal2048_DSA1024()); } catch (GeneralSecurityException e) { log.error("Error creating ElGamal2048_DSA1024.", e); } try { instances.add(new ECDH256_ECDSA256()); instances.add(new ECDH521_ECDSA521()); } catch (GeneralSecurityException e) { log.error("Error creating ECDH256_ECDSA256 or ECDH521_ECDSA521.", e); } try { instances.add(new NTRUEncrypt1087_GMSS512()); } catch (GeneralSecurityException e) { log.error("Error creating NTRUEncrypt1087_GMSS512.", e); } } }
List<Destination> relayPeers = peerManager.getRandomPeers(numHops); Log log = new Log(RelayRequest.class); if (log.shouldLog(Log.DEBUG)) { StringBuilder debugMsg = new StringBuilder("Creating relay chain: [");
destination = new EmailDestination(destinationString); } catch (GeneralSecurityException e) { Log log = new Log(GeneralHelper.class); log.error("Can't save contact to address book.", e); return e.getLocalizedMessage();
Log log = new Log(GeneralHelper.class); Identities identities = I2PBote.getInstance().getIdentities(); EmailIdentity identity;