private BasicAuthenticationManager getAuthenticationManager() { if (username != null && password != null) { return BasicAuthenticationManager.newInstance(username, password.toCharArray()); } return null; }
/** * Creates an auth manager given a user credential - a username and * an ssh private key. * * @param userName a username * @param keyFile a private key file * @param passphrase a password to the private key * @param portNumber a port number over which an ssh tunnel is established * * @since 1.8.9 */ public static BasicAuthenticationManager newInstance(String userName, File keyFile, char[] passphrase, int portNumber) { return newInstance(new SVNAuthentication[] { SVNSSHAuthentication.newInstance(userName, keyFile, passphrase, portNumber, false, null, false), SVNUserNameAuthentication.newInstance(userName, false, null, false), }); }
@NotNull @Override public SvnTester create() throws Exception { return new SvnTesterExternal(url, BasicAuthenticationManager.newInstance(USER_NAME, PASSWORD.toCharArray())); }
/** * Creates an auth manager given a user credential - a username * and password. * * @param userName a username * @param password a password * * @since 1.8.9 */ public static BasicAuthenticationManager newInstance(String userName, char[] password) { return newInstance(new SVNAuthentication[] { SVNPasswordAuthentication.newInstance(userName, password, false, null, false), SVNSSHAuthentication.newInstance(userName, password, -1, false, null, false), SVNUserNameAuthentication.newInstance(userName, false, null, false), }); }
@NotNull public static SVNRepository openSvnRepository(@NotNull SVNURL url, @NotNull String userName, @NotNull String password) throws SVNException { final SVNRepository repo = SVNRepositoryFactory.create(url); repo.setAuthenticationManager(BasicAuthenticationManager.newInstance(userName, password.toCharArray())); return repo; }
protected SVNClientManager getClientManager(final SVNRepository repository) { // Gets the current transaction Transaction transaction = transactionService.get(); if (transaction == null) { throw new IllegalStateException("All SVN calls must be part of a SVN transaction"); } // Gets the client manager return transaction .getResource( SVNSession.class, repository.getId(), () -> { // Creates the client manager for SVN SVNClientManager clientManager = SVNClientManager.newInstance(); // Authentication (if needed) String svnUser = repository.getConfiguration().getUser(); String svnPassword = repository.getConfiguration().getPassword(); if (StringUtils.isNotBlank(svnUser) && StringUtils.isNotBlank(svnPassword)) { clientManager.setAuthenticationManager(BasicAuthenticationManager.newInstance(svnUser, svnPassword.toCharArray())); } // OK return new SVNSessionImpl(clientManager); } ) .getClientManager(); } }
@NotNull private SvnOperationFactory createOperationFactory(@NotNull String userName, @NotNull String password) { final SVNWCContext wcContext = new SVNWCContext(new DefaultSVNOptions(getTempDirectory(), true), null); wcContext.setSqliteTemporaryDbInMemory(true); wcContext.setSqliteJournalMode(SqlJetPagerJournalMode.MEMORY); final SvnOperationFactory factory = new SvnOperationFactory(wcContext); factory.setAuthenticationManager(BasicAuthenticationManager.newInstance(userName, password.toCharArray())); svnFactories.add(factory); return factory; }