Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1.         private String retrieveRealmFor(String scmURL){
  2.             final String[] realms = new String[]{ null };
  3.            
  4.             SVNRepository repository;
  5.             try {
  6.                 repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(scmURL));
  7.                 repository.setTunnelProvider(SVNWCUtil.createDefaultOptions(true));
  8.                 repository.setAuthenticationManager(new DefaultSVNAuthenticationManager(SVNWCUtil.getDefaultConfigurationDirectory(), true, "", "", null, "") {
  9.                     @Override
  10.                     public SVNAuthentication getFirstAuthentication(String kind, String realm, SVNURL url) throws SVNException {
  11.                         realms[0] = realm;
  12.                         return super.getFirstAuthentication(kind, realm, url);
  13.                     }
  14.                     @Override
  15.                     public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException {
  16.                         realms[0] = realm;
  17.                         return super.getNextAuthentication(kind, realm, url);
  18.                     }
  19.  
  20.                     @Override
  21.                     public void acknowledgeAuthentication(boolean accepted, String kind, String realm, SVNErrorMessage errorMessage, SVNAuthentication authentication) throws SVNException {
  22.                         realms[0] = realm;
  23.                         super.acknowledgeAuthentication(accepted, kind, realm, errorMessage, authentication);
  24.                     }
  25.                 });
  26.                 repository.testConnection();
  27.                
  28.             } catch (SVNException e) {
  29.                 // If a problem happens, don't do anything, it implies realm doesn't exist in current cache
  30.             }
  31.  
  32.             return realms[0];
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement