List of usage examples for org.eclipse.jgit.transport URIish getPass
public String getPass()
From source file:com.google.gerrit.server.git.SecureCredentialsProvider.java
License:Apache License
@Override public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { String username = uri.getUser(); if (username == null) { username = cfgUser;// w w w . j ava 2 s .co m } if (username == null) { return false; } String password = uri.getPass(); if (password == null) { password = cfgPass; } if (password == null) { return false; } for (CredentialItem i : items) { if (i instanceof CredentialItem.Username) { ((CredentialItem.Username) i).setValue(username); } else if (i instanceof CredentialItem.Password) { ((CredentialItem.Password) i).setValue(password.toCharArray()); } else { throw new UnsupportedCredentialItem(uri, i.getPromptText()); } } return true; }
From source file:com.madgag.agit.GUICredentialsProvider.java
License:Open Source License
private void handle(URIish uri, CredentialItem.CharArrayType ci) { if (ci instanceof CredentialItem.Password && uri.getPass() != null) { ci.setValue(uri.getPass().toCharArray()); } else {//from w ww. j a v a 2s . c om ci.setValue(blockingPrompt.request(prompt(String.class, uiNotificationFor(ci))).toCharArray()); } }
From source file:it.com.atlassian.labs.speakeasy.util.jgit.HttpAuthMethod.java
License:Eclipse Distribution License
/** * Update this method with the credentials from the URIish. * * @param uri//from w ww. jav a 2s. c o m * the URI used to create the connection. * @param credentialsProvider * the credentials provider, or null. If provided, * {@link URIish#getPass() credentials in the URI} are ignored. * * @return true if the authentication method is able to provide * authorization for the given URI */ boolean authorize(URIish uri, CredentialsProvider credentialsProvider) { String username; String password; if (credentialsProvider != null) { CredentialItem.Username u = new CredentialItem.Username(); CredentialItem.Password p = new CredentialItem.Password(); if (credentialsProvider.supports(u, p) && credentialsProvider.get(uri, u, p)) { username = u.getValue(); password = new String(p.getValue()); p.clear(); } else return false; } else { username = uri.getUser(); password = uri.getPass(); } if (username != null) { authorize(username, password); return true; } return false; }
From source file:jetbrains.buildServer.buildTriggers.vcs.git.tests.AuthSettingsTest.java
License:Apache License
@TestFor(issues = "TW-25087") public void auth_uri_for_anonymous_protocol_should_not_have_user_and_password() throws Exception { VcsRoot root = vcsRoot().withFetchUrl("git://some.org/repo.git") .withAuthMethod(AuthenticationMethod.PASSWORD).withUsername("user").withPassword("pwd").build(); AuthSettings authSettings = new AuthSettings(root); URIish authURI = authSettings.createAuthURI("git://some.org/repo.git"); assertNull(authURI.getUser());//from w w w .jav a 2 s . co m assertNull(authURI.getPass()); }
From source file:org.apache.sshd.git.transport.GitSshdSession.java
License:Apache License
public GitSshdSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws IOException, InterruptedException { String user = uri.getUser();// ww w .j a v a 2 s . co m final String pass = uri.getPass(); String host = uri.getHost(); int port = uri.getPort(); char[] pass2 = null; if (!credentialsProvider.isInteractive()) { CredentialItem.Username usrItem = new CredentialItem.Username(); CredentialItem.Password pwdItem = new CredentialItem.Password(); if (credentialsProvider.get(uri, usrItem, pwdItem)) { if (user == null) { user = usrItem.getValue(); } else if (user.equals(usrItem.getValue())) { pass2 = pwdItem.getValue(); } } } client = createClient(); client.start(); session = client.connect(user, host, port).verify( PropertyResolverUtils.getLongProperty(client, CONNECT_TIMEOUT_PROP, DEFAULT_CONNECT_TIMEOUT)) .getSession(); if (log.isDebugEnabled()) { log.debug("Connected to {}:{}", host, port); } if (pass != null) { session.addPasswordIdentity(pass); } if (pass2 != null) { session.addPasswordIdentity(new String(pass2)); } session.auth() .verify(PropertyResolverUtils.getLongProperty(session, AUTH_TIMEOUT_PROP, DEFAULT_AUTH_TIMEOUT)); if (log.isDebugEnabled()) { log.debug("Authenticated: {}", session); } }
From source file:org.eclipse.egit.ui.internal.components.RepositorySelectionPage.java
License:Open Source License
private void updateFields(final String text) { try {// w w w . j a v a 2s .com eventDepth++; if (eventDepth != 1) return; final URIish u = new URIish(text); safeSet(hostText, u.getHost()); safeSet(pathText, u.getPath()); safeSet(userText, u.getUser()); safeSet(passText, u.getPass()); if (u.getPort() > 0) portText.setText(Integer.toString(u.getPort())); else portText.setText(""); //$NON-NLS-1$ if (u.getScheme() != null) { scheme.select(scheme.indexOf(u.getScheme())); scheme.notifyListeners(SWT.Selection, new Event()); } updateAuthGroup(); uri = u; } catch (URISyntaxException err) { // leave uriText as it is, but clean up underlying uri and // decomposed fields uri = new URIish(); hostText.setText(""); //$NON-NLS-1$ pathText.setText(""); //$NON-NLS-1$ userText.setText(""); //$NON-NLS-1$ passText.setText(""); //$NON-NLS-1$ portText.setText(""); //$NON-NLS-1$ scheme.select(-1); } finally { eventDepth--; } checkPage(); }
From source file:org.eclipse.n4js.utils.git.GitUtils.java
License:Open Source License
/** * Compare the two given git remote URIs. This method is a reimplementation of {@link URIish#equals(Object)} with * one difference. The scheme of the URIs is only considered if both URIs have a non-null and non-empty scheme part. * * @param lhs/*from w w w.j a v a2 s . c o m*/ * the left hand side * @param rhs * the right hand side * @return <code>true</code> if the two URIs are to be considered equal and <code>false</code> otherwise */ private static boolean equals(URIish lhs, URIish rhs) { // We only consider the scheme if both URIs have one if (!StringUtils.isEmptyOrNull(lhs.getScheme()) && !StringUtils.isEmptyOrNull(rhs.getScheme())) { if (!Objects.equals(lhs.getScheme(), rhs.getScheme())) return false; } if (!equals(lhs.getUser(), rhs.getUser())) return false; if (!equals(lhs.getPass(), rhs.getPass())) return false; if (!equals(lhs.getHost(), rhs.getHost())) return false; if (lhs.getPort() != rhs.getPort()) return false; if (!pathEquals(lhs.getPath(), rhs.getPath())) return false; return true; }
From source file:org.eclipse.orion.server.filesystem.git.GitFileStore.java
License:Open Source License
private boolean canInit() { try {// w ww. j ava 2 s .co m // org.eclipse.jgit.transport.TransportLocal.canHandle(URIish, FS) URIish uri = Utils.toURIish(getUrl()); if (uri.getHost() != null || uri.getPort() > 0 || uri.getUser() != null || uri.getPass() != null || uri.getPath() == null) return false; if ("file".equals(uri.getScheme()) || uri.getScheme() == null) return true; } catch (URISyntaxException e) { LogHelper.log(new Status(IStatus.ERROR, Activator.PI_GIT, 1, "Cannot init" + this + ". The URL cannot be parsed as a URI reference", e)); } return false; }
From source file:org.eclipse.orion.server.git.GitSshSessionFactory.java
License:Open Source License
@Override public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException { int port = uri.getPort(); String user = uri.getUser();//from w ww .j a va2s .c o m String pass = uri.getPass(); if (credentialsProvider instanceof GitCredentialsProvider) { if (port <= 0) port = SSH_PORT; GitCredentialsProvider cp = (GitCredentialsProvider) credentialsProvider; if (user == null) { CredentialItem.Username u = new CredentialItem.Username(); if (cp.supports(u) && cp.get(cp.getUri(), u)) { user = u.getValue(); } } if (pass == null) { CredentialItem.Password p = new CredentialItem.Password(); if (cp.supports(p) && cp.get(cp.getUri(), p)) { pass = new String(p.getValue()); } } try { final SessionHandler session = new SessionHandler(user, uri.getHost(), port, cp.getKnownHosts(), cp.getPrivateKey(), cp.getPublicKey(), cp.getPassphrase()); if (pass != null) session.setPassword(pass); if (credentialsProvider != null && !credentialsProvider.isInteractive()) { session.setUserInfo(new CredentialsProviderUserInfo(session.getSession(), credentialsProvider)); } session.connect(tms); return new JschSession(session.getSession(), uri); } catch (JSchException e) { throw new TransportException(uri, e.getMessage(), e); } } return null; }
From source file:org.eclipse.orion.server.tests.servlets.git.GitTest.java
License:Open Source License
protected void assertRepositoryInfo(URIish uri, JSONObject result) throws JSONException { assertEquals(uri.toString(), result.getJSONObject("ErrorData").get("Url")); if (uri.getUser() != null) assertEquals(uri.getUser(), result.getJSONObject("ErrorData").get("User")); if (uri.getHost() != null) assertEquals(uri.getHost(), result.getJSONObject("ErrorData").get("Host")); if (uri.getHumanishName() != null) assertEquals(uri.getHumanishName(), result.getJSONObject("ErrorData").get("HumanishName")); if (uri.getPass() != null) assertEquals(uri.getPass(), result.getJSONObject("ErrorData").get("Password")); if (uri.getPort() > 0) assertEquals(uri.getPort(), result.getJSONObject("ErrorData").get("Port")); if (uri.getScheme() != null) assertEquals(uri.getScheme(), result.getJSONObject("ErrorData").get("Scheme")); }