use of net.i2p.util.Log in project i2p.i2p by i2p.
the class FreeListBlock method flbck.
/**
* Recursive.
* @since 0.9.7
*/
public boolean flbck(boolean fix) throws IOException {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
log.info(toString());
if (nextPage > 0)
(new FreeListBlock(file, nextPage)).flbck(fix);
return true;
}
use of net.i2p.util.Log in project i2p.i2p by i2p.
the class FreeListBlock method addPage.
/**
* Adds free page and writes new len to disk
* @throws IllegalStateException if full
*/
public void addPage(int freePage) throws IOException {
if (len >= MAX_SIZE)
throw new IllegalStateException("full");
if (getMagic(freePage) == MAGIC_FREE) {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
log.error("Double free page " + freePage, new Exception());
return;
}
branches[len++] = freePage;
markFree(freePage);
writeFreePage();
}
use of net.i2p.util.Log in project i2p.i2p by i2p.
the class KeyGenerator method generateSigningKeys.
/**
* Generic signature type, supports DSA, RSA, ECDSA, EdDSA
* @since 0.9.9
*/
public SimpleDataStructure[] generateSigningKeys(SigType type) throws GeneralSecurityException {
if (type == SigType.DSA_SHA1)
return generateSigningKeys();
KeyPair kp;
if (type.getBaseAlgorithm() == SigAlgo.EdDSA) {
net.i2p.crypto.eddsa.KeyPairGenerator kpg = new net.i2p.crypto.eddsa.KeyPairGenerator();
kpg.initialize(type.getParams(), _context.random());
kp = kpg.generateKeyPair();
} else {
KeyPairGenerator kpg = KeyPairGenerator.getInstance(type.getBaseAlgorithm().getName());
try {
kpg.initialize(type.getParams(), _context.random());
kp = kpg.generateKeyPair();
} catch (ProviderException pe) {
// java.security.ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DOMAIN_PARAMS_INVALID
// This is a RuntimeException, thx Sun
// Fails for P-192 only, on Ubuntu
Log log = _context.logManager().getLog(KeyGenerator.class);
String pname = kpg.getProvider().getName();
if ("BC".equals(pname)) {
if (log.shouldLog(Log.WARN))
log.warn("BC KPG failed for " + type, pe);
throw new GeneralSecurityException("BC KPG for " + type, pe);
}
if (!ECConstants.isBCAvailable())
throw new GeneralSecurityException(pname + " KPG failed for " + type, pe);
if (log.shouldLog(Log.WARN))
log.warn(pname + " KPG failed for " + type + ", trying BC");
try {
kpg = KeyPairGenerator.getInstance(type.getBaseAlgorithm().getName(), "BC");
kpg.initialize(type.getParams(), _context.random());
kp = kpg.generateKeyPair();
} catch (ProviderException pe2) {
if (log.shouldLog(Log.WARN))
log.warn("BC KPG failed for " + type + " also", pe2);
// throw original exception
throw new GeneralSecurityException(pname + " KPG for " + type, pe);
} catch (GeneralSecurityException gse) {
if (log.shouldLog(Log.WARN))
log.warn("BC KPG failed for " + type + " also", gse);
// throw original exception
throw new GeneralSecurityException(pname + " KPG for " + type, pe);
}
}
}
java.security.PublicKey pubkey = kp.getPublic();
java.security.PrivateKey privkey = kp.getPrivate();
SimpleDataStructure[] keys = new SimpleDataStructure[2];
keys[0] = SigUtil.fromJavaKey(pubkey, type);
keys[1] = SigUtil.fromJavaKey(privkey, type);
return keys;
}
use of net.i2p.util.Log in project i2p.i2p by i2p.
the class CertUtil method log.
// private static void error(I2PAppContext ctx, String msg, Throwable t) {
// log(ctx, Log.ERROR, msg, t);
// }
private static void log(I2PAppContext ctx, int level, String msg, Throwable t) {
Log l = ctx.logManager().getLog(CertUtil.class);
l.log(level, msg, t);
}
use of net.i2p.util.Log in project i2p.i2p by i2p.
the class RouterClock method setNow.
/**
* @param stratum used to determine whether we should ignore
* @since 0.7.12
*/
@Override
public void setNow(long realTime, int stratum) {
if (realTime < BuildTime.getEarliestTime() || realTime > BuildTime.getLatestTime()) {
Log log = getLog();
String msg = "Invalid time received: " + new Date(realTime);
if (log.shouldWarn())
log.warn(msg, new Exception());
else
log.logAlways(Log.WARN, msg);
return;
}
long diff = realTime - System.currentTimeMillis();
setOffset(diff, stratum);
}
Aggregations