@Override public void reset(URIish uri) { if (delegate != null) { delegate.reset(uri); } }
@Override public void configure(Transport transport) { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host hc, Session session) { session.setConfig("StrictHostKeyChecking", sshUriProperties.isStrictHostKeyChecking() ? "yes" : "no"); } }); } }
protected static boolean isSshUri(Object uri) { if(uri != null) { try { URIish urIish = new URIish(uri.toString()); String scheme = urIish.getScheme(); if(scheme == null && hasText(urIish.getHost()) && hasText(urIish.getUser())) { //JGit returns null if using SCP URI but user and host will be populated return true; } return scheme != null && !scheme.matches("^(http|https)$"); } catch (URISyntaxException e) { return false; } } return false; }
public static ArrayMemory valueOf(RemoteRefUpdate value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("message").assign(value.getMessage()); memory.refOfIndex("remoteName").assign(value.getRemoteName()); memory.refOfIndex("srcRef").assign(value.getSrcRef()); memory.refOfIndex("expectedOldObjectId").assign(valueOf(value.getExpectedOldObjectId())); memory.refOfIndex("newObjectId").assign(valueOf(value.getNewObjectId())); memory.refOfIndex("delete").assign(value.isDelete()); memory.refOfIndex("fastForward").assign(value.isFastForward()); memory.refOfIndex("forceUpdate").assign(value.isForceUpdate()); return memory; }
public static ArrayMemory valueOf(RemoteConfig value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("name").assign(value.getName()); memory.refOfIndex("receivePack").assign(value.getReceivePack()); memory.refOfIndex("uploadPack").assign(value.getUploadPack()); memory.refOfIndex("mirror").assign(value.isMirror()); memory.refOfIndex("timeout").assign(value.getTimeout()); memory.refOfIndex("tagOpt").assign(value.getTagOpt().name()); ArrayMemory uris = ArrayMemory.createListed(value.getURIs().size()); for (URIish urIish : value.getURIs()) { uris.add(urIish.toPrivateString()); } memory.refOfIndex("uris").assign(uris); return memory; }
@Signature public void setCredentials(String userName, String password) { credentialsProvider = new UsernamePasswordCredentialsProvider(userName, password); }
private URIish retrieveUrIish(PushHook hook) { try { if (hook.getRepository() != null) { return new URIish(hook.getRepository().getUrl()); } } catch (URISyntaxException e) { LOGGER.log(Level.WARNING, "could not parse URL"); } return null; } }
/** * Ask for the credential items to be populated with the passphrase. * * @param uri * the URI of the remote resource that needs authentication. * @param items * the items the application requires to complete authentication. * @return {@code true} if the request was successful and values were * supplied; {@code false} if the user canceled the request and did * not supply all requested values. * @throws UnsupportedCredentialItem * if one of the items supplied is not supported. */ @Override public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem { for (final CredentialItem item : items) { if (item instanceof CredentialItem.StringType && item.getPromptText().startsWith(PROMPT)) { ((CredentialItem.StringType) item).setValue(passphrase); continue; } throw new UnsupportedCredentialItem(uri, item.getClass().getName() + ":" + item.getPromptText()); } return true; } }
public static ArrayMemory valueOf(OperationResult value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("advertisedRefs").assign(valueOfRefs(value.getAdvertisedRefs())); memory.refOfIndex("messages").assign(value.getMessages()); memory.refOfIndex("peerUserAgent").assign(value.getPeerUserAgent()); memory.refOfIndex("uri").assign(value.getURI().toString()); return memory; }
private TransportConfigCallback buildTransportConfigCallback() { if (this.providerSessionFactoryEither instanceof Either.Left) return null; SshSessionFactory sshSessionFactory = ((Either.Right<CredentialsProvider, SshSessionFactory>) this.providerSessionFactoryEither).getRight(); return transport -> { SshTransport sshTransport = (SshTransport) transport; sshTransport.setSshSessionFactory(sshSessionFactory); }; } }
private URIish getFirstRepoURL(List<RemoteConfig> repositories) { if (!repositories.isEmpty()) { List<URIish> uris = repositories.get(repositories.size() - 1).getURIs(); if (!uris.isEmpty()) { return uris.get(uris.size() - 1); } } throw new IllegalStateException(Messages.GitLabPushTrigger_NoSourceRepository()); }
public static ArrayMemory valueOf(PushResult value) { ArrayMemory memory = valueOf((OperationResult) value); memory.refOfIndex("remoteUpdates").assign(valueOfRemoteRefUpdates(value.getRemoteUpdates())); return memory; }
@Override public boolean supports(CredentialItem... items) { List<CredentialItem> unprocessedItems = new ArrayList<>(); for (CredentialItem item : items) { if (item instanceof CredentialItem.InformationalMessage && item.getPromptText() != null && item.getPromptText() .contains(JGitText.get().sslFailureTrustExplanation)) continue; if (item instanceof CredentialItem.YesNoType && item.getPromptText() != null && (item.getPromptText().equals(JGitText.get().sslTrustNow) || item.getPromptText() .startsWith(stripFormattingPlaceholders( JGitText.get().sslTrustForRepo)) || item.getPromptText() .equals(JGitText.get().sslTrustAlways))) continue; unprocessedItems.add(item); } return unprocessedItems.isEmpty() || (delegate != null && delegate.supports(unprocessedItems.toArray(new CredentialItem[0]))); }
/** * {@inheritDoc} * @return */ @Override public boolean supports(CredentialItem... items) { for (final CredentialItem item : items) { if (item instanceof CredentialItem.StringType && item.getPromptText().startsWith(PROMPT)) { continue; } else { return false; } } return true; }
@Override public boolean isInteractive() { return (delegate != null) && delegate.isInteractive(); }
protected URIish retrieveUrIish(WebHook hook) { try { if (hook.getRepository() != null) { return new URIish(hook.getRepository().getUrl()); } } catch (URISyntaxException e) { LOGGER.log(Level.WARNING, "could not parse URL"); } return null; }
@Override public void configure(Transport transport) { if (transport instanceof SshTransport) { SshTransport sshTransport = (SshTransport) transport; sshTransport.setSshSessionFactory( new PropertyBasedSshSessionFactory( new SshUriPropertyProcessor(sshUriProperties).getSshKeysByHostname(), new JSch())); } } }
private URIish getFirstRepoURL(List<RemoteConfig> repositories) { if (!repositories.isEmpty()) { List<URIish> uris = repositories.get(repositories.size() - 1).getURIs(); if (!uris.isEmpty()) { return uris.get(uris.size() - 1); } } throw new IllegalStateException(Messages.GitLabPushTrigger_NoSourceRepository()); }
private void initialize() { if (!this.initialized) { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", isStrictHostKeyChecking() ? "yes" : "no"); } }); this.initialized = true; } }