List of usage examples for org.eclipse.jgit.lib Config getLong
public long getLong(String section, String name, long defaultValue)
From source file:com.google.gerrit.server.git.ProjectConfig.java
License:Apache License
public static final String validMaxObjectSizeLimit(String value) throws ConfigInvalidException { if (value == null) { return null; }//from www . j av a 2 s .c om value = value.trim(); if (value.isEmpty()) { return null; } Config cfg = new Config(); cfg.fromText("[s]\nn=" + value); try { long s = cfg.getLong("s", "n", 0); if (s < 0) { throw new ConfigInvalidException( String.format("Negative value '%s' not allowed as %s", value, KEY_MAX_OBJECT_SIZE_LIMIT)); } if (s == 0) { // return null for the default so that it is not persisted return null; } return value; } catch (IllegalArgumentException e) { throw new ConfigInvalidException(String.format("Value '%s' not parseable as a Long", value), e); } }
From source file:com.google.gerrit.server.git.TransferConfig.java
License:Apache License
@Inject TransferConfig(@GerritServerConfig final Config cfg) { timeout = (int) ConfigUtil.getTimeUnit(cfg, "transfer", null, "timeout", // 0, TimeUnit.SECONDS); maxObjectSizeLimit = cfg.getLong("receive", "maxObjectSizeLimit", 0); maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit"); packConfig = new PackConfig(); packConfig.setDeltaCompress(false);//from w ww. j a va2 s .co m packConfig.setThreads(1); packConfig.fromConfig(cfg); }
From source file:com.google.gerrit.sshd.SshDaemon.java
License:Apache License
@Inject SshDaemon(final CommandFactory commandFactory, final NoShell noShell, final PublickeyAuthenticator userAuth, final GerritGSSAuthenticator kerberosAuth, final KeyPairProvider hostKeyProvider, final IdGenerator idGenerator, @GerritServerConfig final Config cfg, final SshLog sshLog, @SshListenAddresses final List<SocketAddress> listen, @SshAdvertisedAddresses final List<String> advertised) { setPort(IANA_SSH_PORT /* never used */); this.cfg = cfg; this.listen = listen; this.advertised = advertised; keepAlive = cfg.getBoolean("sshd", "tcpkeepalive", true); getProperties().put(SERVER_IDENTIFICATION, "GerritCodeReview_" + Version.getVersion() // + " (" + super.getVersion() + ")"); getProperties().put(MAX_AUTH_REQUESTS, String.valueOf(cfg.getInt("sshd", "maxAuthTries", 6))); getProperties().put(AUTH_TIMEOUT, String.valueOf(MILLISECONDS .convert(ConfigUtil.getTimeUnit(cfg, "sshd", null, "loginGraceTime", 120, SECONDS), SECONDS))); long idleTimeoutSeconds = ConfigUtil.getTimeUnit(cfg, "sshd", null, "idleTimeout", 0, SECONDS); getProperties().put(IDLE_TIMEOUT, String.valueOf(SECONDS.toMillis(idleTimeoutSeconds))); long rekeyTimeLimit = ConfigUtil.getTimeUnit(cfg, "sshd", null, "rekeyTimeLimit", 3600, SECONDS); getProperties().put(REKEY_TIME_LIMIT, String.valueOf(SECONDS.toMillis(rekeyTimeLimit))); getProperties().put(REKEY_BYTES_LIMIT, String.valueOf(cfg.getLong("sshd", "rekeyBytesLimit", 1024 * 1024 * 1024 /* 1GB */))); final int maxConnectionsPerUser = cfg.getInt("sshd", "maxConnectionsPerUser", 64); if (0 < maxConnectionsPerUser) { getProperties().put(MAX_CONCURRENT_SESSIONS, String.valueOf(maxConnectionsPerUser)); }//from www . ja va 2 s. c o m final String kerberosKeytab = cfg.getString("sshd", null, "kerberosKeytab"); final String kerberosPrincipal = cfg.getString("sshd", null, "kerberosPrincipal"); final boolean enableCompression = cfg.getBoolean("sshd", "enableCompression", false); SshSessionBackend backend = cfg.getEnum("sshd", null, "backend", SshSessionBackend.MINA); System.setProperty(IoServiceFactoryFactory.class.getName(), backend == SshSessionBackend.MINA ? MinaServiceFactoryFactory.class.getName() : Nio2ServiceFactoryFactory.class.getName()); if (SecurityUtils.isBouncyCastleRegistered()) { initProviderBouncyCastle(cfg); } else { initProviderJce(); } initCiphers(cfg); initMacs(cfg); initSignatures(); initChannels(); initForwarding(); initFileSystemFactory(); initSubsystems(); initCompression(enableCompression); initUserAuth(userAuth, kerberosAuth, kerberosKeytab, kerberosPrincipal); setKeyPairProvider(hostKeyProvider); setCommandFactory(commandFactory); setShellFactory(noShell); setSessionFactory(new SessionFactory() { @Override protected AbstractSession createSession(final IoSession io) throws Exception { if (io instanceof MinaSession) { if (((MinaSession) io).getSession().getConfig() instanceof SocketSessionConfig) { ((SocketSessionConfig) ((MinaSession) io).getSession().getConfig()).setKeepAlive(keepAlive); } } GerritServerSession s = (GerritServerSession) super.createSession(io); int id = idGenerator.next(); SocketAddress peer = io.getRemoteAddress(); final SshSession sd = new SshSession(id, peer); s.setAttribute(SshSession.KEY, sd); // Log a session close without authentication as a failure. // s.addCloseSessionListener(new SshFutureListener<CloseFuture>() { @Override public void operationComplete(CloseFuture future) { if (sd.isAuthenticationError()) { sshLog.onAuthFail(sd); } } }); return s; } @Override protected AbstractSession doCreateSession(IoSession ioSession) throws Exception { return new GerritServerSession(server, ioSession); } }); setGlobalRequestHandlers(Arrays.<RequestHandler<ConnectionService>>asList(new KeepAliveHandler(), new NoMoreSessionsHandler(), new TcpipForwardHandler(), new CancelTcpipForwardHandler())); hostKeys = computeHostKeys(); }