コード例 #1
0
  public SvnAuthenticationManager getPassiveAuthenticationManager(Project project) {
    if (myPassiveAuthManager == null) {
      myPassiveAuthManager =
          new SvnAuthenticationManager(project, new File(getConfigurationDirectory()));
      myPassiveAuthManager.setAuthenticationProvider(
          new ISVNAuthenticationProvider() {
            @Override
            public SVNAuthentication requestClientAuthentication(
                String kind,
                SVNURL url,
                String realm,
                SVNErrorMessage errorMessage,
                SVNAuthentication previousAuth,
                boolean authMayBeStored) {
              return null;
            }

            @Override
            public int acceptServerAuthentication(
                SVNURL url, String realm, Object certificate, boolean resultMayBeStored) {
              return REJECTED;
            }
          });
      myPassiveAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
    }
    return myPassiveAuthManager;
  }
コード例 #2
0
 public SvnAuthenticationManager getInteractiveManager(final SvnVcs svnVcs) {
   if (myInteractiveManager == null) {
     myInteractiveManager =
         new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
     myInteractiveManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
     myInteractiveProvider =
         new SvnInteractiveAuthenticationProvider(svnVcs, myInteractiveManager);
     myInteractiveManager.setAuthenticationProvider(myInteractiveProvider);
   }
   return myInteractiveManager;
 }
コード例 #3
0
  public static SvnAuthenticationManager createForTmpDir(
      final Project project,
      final File dir,
      @Nullable final SvnInteractiveAuthenticationProvider provider) {
    final SvnVcs vcs = SvnVcs.getInstance(project);

    final SvnAuthenticationManager interactive = new SvnAuthenticationManager(project, dir);
    interactive.setRuntimeStorage(RUNTIME_AUTH_CACHE);
    final SvnInteractiveAuthenticationProvider interactiveProvider =
        provider == null ? new SvnInteractiveAuthenticationProvider(vcs, interactive) : provider;
    interactive.setAuthenticationProvider(interactiveProvider);

    return interactive;
  }
コード例 #4
0
  public static boolean putProxyCredentialsIntoServerFile(
      @NotNull final File configDir,
      @NotNull final String host,
      @NotNull final PasswordAuthentication authentication) {
    final IdeaSVNConfigFile configFile =
        new IdeaSVNConfigFile(new File(configDir, SERVERS_FILE_NAME));
    configFile.updateGroups();

    String groupName = SvnAuthenticationManager.getGroupForHost(host, configFile);
    // no proxy defined in group -> no sense in password
    if (StringUtil.isEmptyOrSpaces(groupName)) return false;
    final Map<String, String> properties = configFile.getAllGroups().get(groupName).getProperties();
    if (StringUtil.isEmptyOrSpaces(properties.get(SvnAuthenticationManager.HTTP_PROXY_HOST)))
      return false;
    if (StringUtil.isEmptyOrSpaces(properties.get(SvnAuthenticationManager.HTTP_PROXY_PORT)))
      return false;

    configFile.setValue(
        groupName, SvnAuthenticationManager.HTTP_PROXY_USERNAME, authentication.getUserName());
    configFile.setValue(
        groupName,
        SvnAuthenticationManager.HTTP_PROXY_PASSWORD,
        String.valueOf(authentication.getPassword()));
    configFile.save();
    return true;
  }
コード例 #5
0
 public SvnAuthenticationManager getAuthenticationManager(final SvnVcs svnVcs) {
   if (myAuthManager == null) {
     // reloaded when configuration directory changes
     myAuthManager =
         new SvnAuthenticationManager(svnVcs.getProject(), new File(getConfigurationDirectory()));
     Disposer.register(
         svnVcs.getProject(),
         new Disposable() {
           @Override
           public void dispose() {
             myAuthManager = null;
           }
         });
     getInteractiveManager(svnVcs);
     // to init
     myAuthManager.setAuthenticationProvider(
         new SvnAuthenticationProvider(svnVcs, myInteractiveProvider, RUNTIME_AUTH_CACHE));
     myAuthManager.setRuntimeStorage(RUNTIME_AUTH_CACHE);
   }
   return myAuthManager;
 }
コード例 #6
0
  public static void putProxyIntoServersFile(
      final File configDir, final String host, final Proxy proxyInfo) {
    final IdeaSVNConfigFile configFile =
        new IdeaSVNConfigFile(new File(configDir, SERVERS_FILE_NAME));
    configFile.updateGroups();

    String groupName = SvnAuthenticationManager.getGroupForHost(host, configFile);

    if (StringUtil.isEmptyOrSpaces(groupName)) {
      groupName = host;
      final Map<String, ProxyGroup> groups = configFile.getAllGroups();
      while (StringUtil.isEmptyOrSpaces(groupName) || groups.containsKey(groupName)) {
        groupName += "1";
      }
    }

    final HashMap<String, String> map = new HashMap<String, String>();
    final InetSocketAddress address = ((InetSocketAddress) proxyInfo.address());
    map.put(SvnAuthenticationManager.HTTP_PROXY_HOST, address.getHostName());
    map.put(SvnAuthenticationManager.HTTP_PROXY_PORT, String.valueOf(address.getPort()));
    configFile.addGroup(groupName, host + "*", map);
    configFile.save();
  }