Guest User

Untitled

a guest
Jun 21st, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package org.eclipse.jgit.transport;
  2.  
  3. import java.net.URI;
  4.  
  5. /**
  6. * Implementors can provide credentials for use in connecting to Git
  7. * repositories.
  8. */
  9. public abstract class CredentialsProvider {
  10. /**
  11. * Get credentials for a given URI
  12. *
  13. * @param uri
  14. * the URI for which credentials are desired
  15. * @param promptTypes
  16. *
  17. * @return the credentials, or null if there are none.
  18. * @see UsernamePasswordCredentials
  19. */
  20. public abstract Credentials getCredentials(URIish uri);
  21.  
  22. protected abstract Object get(PromptType p, uri);
  23. }
  24.  
  25. abstract class Credentials {
  26. private URIish uri;
  27. public Credentials(URIish uri) {
  28. this.uri = uri;
  29. }
  30. protected abstract Object get(PromptType t);
  31. }
  32.  
  33. class EclipseCredentialsProvider extends Credentials {
  34. class EclipseCredentials extends Credentials {
  35.  
  36. }
  37.  
  38. public EclipseCredentials getCredentials(URIish uri) {
  39. return new EclipseCredentials(uri);
  40. }
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47. Object get(PromptType t) {
  48.  
  49. c = credentialsProvider.getCredentials(uri, "Username", "Password");
  50. username = c.get(0);
  51. passsword = c.get(1); }
  52.  
  53. c = credentialsProvider.getCredentials(uri, PromptType.USERNAME, PromptType.PASSWORD);
  54. username = c.get(0);
  55. passsword = c.get(1); }
  56.  
  57. c = credentialsProvider.getCredentials(uri);
  58. user = PromptType.USERNAME.get(c);
  59. password = PromptType.PASSWORD.get(c);
  60.  
  61. user = PromptType.USERNAME.get(credentialsProvider, uri);
  62. password = PromptType.PASSWORD.get(credentialsProvider, uri);
  63.  
  64. }
Add Comment
Please, Sign In to add comment