List of usage examples for org.eclipse.jgit.transport URIish toPrivateASCIIString
public String toPrivateASCIIString()
From source file:br.com.ingenieux.jenkins.plugins.codecommit.CodeCommitURLHelper.java
License:Apache License
private Iterable<RepositoryUsernameReference> fetchCodeCommitRepositoryNames(GitSCM scm) throws CredentialNotFoundException { AWSCredentialsProvider credentials = new DefaultAWSCredentialsProviderChain(); if (isNotBlank(credentialId)) { credentials = CredentialsFactory.getCredentials(credentialId); if (null == credentials) throw new CredentialNotFoundException( "CredentialId '" + credentialId + "' specified but not found."); }/*from w w w . ja v a 2s . c om*/ Set<RepositoryUsernameReference> results = new LinkedHashSet<RepositoryUsernameReference>(); for (RemoteConfig cfg : scm.getRepositories()) { for (URIish u : cfg.getURIs()) { final String repositoryUrl = u.toPrivateASCIIString(); final Matcher m = PATTERN_CODECOMMIT_REPO.matcher(repositoryUrl); if (m.matches()) { final String awsRegion = m.group(1); final String repositoryName = m.group(2); String usernamePassword = new CodeCommitRequestSigner(credentials, repositoryName, awsRegion, new Date()).getPushUrl(); int lastIndex = usernamePassword.lastIndexOf(':'); String username = usernamePassword.substring(0, lastIndex); String password = usernamePassword.substring(1 + lastIndex); results.add(new RepositoryUsernameReference(repositoryUrl, repositoryName, username, password)); } } } return results; }