<commit_before>// Copyright (C) 2009 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.ssh;

import static com.google.inject.Scopes.SINGLETON;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.RemotePeer;
import com.google.gerrit.server.ssh.commands.DefaultCommandModule;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.servlet.RequestScoped;
import com.google.inject.servlet.SessionScoped;

import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.server.CommandFactory;
import org.apache.sshd.server.PublickeyAuthenticator;
import org.apache.sshd.server.session.ServerSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.SocketAddress;

/** Configures standard dependencies for {@link SshDaemon}. */
public class SshDaemonModule extends AbstractModule {
  static final Logger log = LoggerFactory.getLogger(SshDaemonModule.class);

  @Override
  protected void configure() {
    bindScope(SessionScoped.class, SshScopes.SESSION);
    bindScope(RequestScoped.class, SshScopes.REQUEST);

    configureSessionScope();
    configureRequestScope();

    bind(SshInfo.class).to(SshDaemon.class).in(SINGLETON);
    bind(CommandFactory.class).toProvider(CommandFactoryProvider.class);
    bind(PublickeyAuthenticator.class).to(DatabasePubKeyAuth.class);

    install(new DefaultCommandModule());
  }

  private void configureSessionScope() {
    bind(ServerSession.class).toProvider(new Provider<ServerSession>() {
      @Override
      public ServerSession get() {
        return SshScopes.getContext().session;<commit_msg>Fix SSH daemon in web mode to actually have commands<commit_after>// Copyright (C) 2009 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.gerrit.server.ssh;

import static com.google.inject.Scopes.SINGLETON;

import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.RemotePeer;
import com.google.gerrit.server.ssh.commands.DefaultCommandModule;
import com.google.inject.AbstractModule;
import com.google.inject.Provider;
import com.google.inject.servlet.RequestScoped;
import com.google.inject.servlet.SessionScoped;

import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.server.CommandFactory;
import org.apache.sshd.server.PublickeyAuthenticator;
import org.apache.sshd.server.session.ServerSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.SocketAddress;

/** Configures standard dependencies for {@link SshDaemon}. */
public class SshDaemonModule extends AbstractModule {
  static final Logger log = LoggerFactory.getLogger(SshDaemonModule.class);

  @Override
  protected void configure() {
    bindScope(SessionScoped.class, SshScopes.SESSION);
    bindScope(RequestScoped.class, SshScopes.REQUEST);

    configureSessionScope();
    configureRequestScope();

    bind(SshInfo.class).to(SshDaemon.class).in(SINGLETON);
    bind(CommandFactoryProvider.class);
    bind(CommandFactory.class).toProvider(CommandFactoryProvider.class);
    bind(PublickeyAuthenticator.class).to(DatabasePubKeyAuth.class);

    install(new DefaultCommandModule());
  }

  private void configureSessionScope() {
    bind(ServerSession.class).toProvider(new Provider<ServerSession>() {
      @Override
      public ServerSession get() {
        return SshScopes.getContext().session;
{'fraction_non_alphanumeric': 0.10015174506828528, 'fraction_numerical': 0.004335573379579449, 'mean_word_length': 4.855329949238579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7320312', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1271, 'n_words': 337}