当前位置: 首页>>代码示例>>Java>>正文


Java CredentialItem类代码示例

本文整理汇总了Java中org.eclipse.jgit.transport.CredentialItem的典型用法代码示例。如果您正苦于以下问题:Java CredentialItem类的具体用法?Java CredentialItem怎么用?Java CredentialItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CredentialItem类属于org.eclipse.jgit.transport包,在下文中一共展示了CredentialItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUsernamePassword

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
public UsernamePassword getUsernamePassword(URIish uri) {
  addDefaultCredentials(credentials);

  String username = uri.getUser();
  String password = uri.getPass();

  CredentialItem.Username u = new CredentialItem.Username();
  CredentialItem.Password p = new CredentialItem.Password();

  if (supports(u, p) && get(uri, u, p)) {
    username = u.getValue();
    char[] v = p.getValue();
    password = (v == null) ? null : new String(p.getValue());
    p.clear();
  }

  return new UsernamePassword(username, password);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:19,代码来源:UsernamePasswordCredentialsProvider.java

示例2: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
    for (CredentialItem i : items) {
        if (i instanceof Identity) {
            ((Identity) i).setValue(identityFile);
            continue;
        }
        if (i instanceof KnownHosts) {
            ((KnownHosts) i).setValue(knownHostsFile);
            continue;
        }
        throw new UnsupportedCredentialItem(uri, i.getClass().getName()
                + ":" + i.getPromptText()); //$NON-NLS-1$
    }
    return true;
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:17,代码来源:PrivateKeyCredentialsProvider.java

示例3: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish urIish, CredentialItem... credentialItems) throws UnsupportedCredentialItem {
    if (userCredentials != null) {
        Iterator<String> userCredentialsIterator = userCredentials.iterator();
        for(CredentialItem item : credentialItems) {
            String nextValue = userCredentialsIterator.next();
            if (item instanceof CredentialItem.Username) {
                ((CredentialItem.Username)item).setValue(nextValue);
            } else if (item instanceof CredentialItem.Password) {
                ((CredentialItem.Password)item).setValue(nextValue.toCharArray());
            } else if (item instanceof CredentialItem.StringType) {
                ((CredentialItem.StringType)item).setValue(nextValue);
            } else {
                System.out.println(item);
                System.out.println(item.getPromptText());
                throw new UnsupportedCredentialItem(urIish, "Case not covered in ElegitCredentialsProvider");
            }
        }
    }
    return true;
}
 
开发者ID:dmusican,项目名称:Elegit,代码行数:22,代码来源:ElegitCredentialsProvider.java

示例4: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(final URIish uri,
                   final CredentialItem... items) throws UnsupportedCredentialItem {
    try {
        return super.get(uri,
                         items);
    } catch (UnsupportedCredentialItem e) {
        for (CredentialItem i : items) {
            if (i instanceof CredentialItem.YesNoType) {
                ((CredentialItem.YesNoType) i).setValue(true);
                return true;
            } else {
                continue;
            }
        }
    }
    return false;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:UsernamePasswordCredentialsProvider.java

示例5: supports

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
 * We support username and password credential items only.
 * @see org.eclipse.jgit.transport.CredentialsProvider#supports(org.eclipse.jgit.transport.CredentialItem[])
 */
@Override
public boolean supports(CredentialItem... items) {
	for (CredentialItem i : items) {
		if (i instanceof CredentialItem.Username) {
			continue;
		}
		else if (i instanceof CredentialItem.Password) {
			continue;
		}
		else {
			return false;
		}
	}
	return true;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:20,代码来源:AwsCodeCommitCredentialProvider.java

示例6: passphraseShouldSetCredentials

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Test
public void passphraseShouldSetCredentials() throws Exception {
	final String passphrase = "mypassphrase";
	Git mockGit = mock(Git.class);
	MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);

	JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment);
	envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
	envRepository.setUri("git+ssh://[email protected]/somegitrepo");
	envRepository.setBasedir(new File("./mybasedir"));
	envRepository.setPassphrase(passphrase);
	envRepository.setCloneOnStart(true);
	envRepository.afterPropertiesSet();

	assertTrue(mockCloneCommand.hasPassphraseCredentialsProvider());

	CredentialsProvider provider = mockCloneCommand.getCredentialsProvider();
	assertFalse(provider.isInteractive());

	CredentialItem.StringType stringCredential = new CredentialItem.StringType(PassphraseCredentialsProvider.PROMPT,
			true);

	assertTrue(provider.supports(stringCredential));
	provider.get(new URIish(), stringCredential);
	assertEquals(stringCredential.getValue(), passphrase);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:27,代码来源:JGitEnvironmentRepositoryTests.java

示例7: testReturnsCredentials

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Test
public void testReturnsCredentials() throws URISyntaxException {
	CredentialItem[] credentialItems = makeCredentialItems();
	assertTrue(provider.get(new URIish(AWS_REPO), credentialItems));
	
	String theUsername = ((CredentialItem.Username) credentialItems[0]).getValue();
	char[] thePassword = ((CredentialItem.Password) credentialItems[1]).getValue();
	
	assertEquals(USER, theUsername);
	assertNotNull(thePassword);
	
	// The password will always begin with a timestamp like
	// 20161113T121314Z
	assertTrue(thePassword.length > 16);
	assertEquals('T', thePassword[8]);
	assertEquals('Z', thePassword[15]);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:18,代码来源:AwsCodeCommitCredentialsProviderTests.java

示例8: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public boolean get(final URIish uriish,
    final CredentialItem... items) {

    for (final CredentialItem item : items) {
        if (item instanceof CredentialItem.StringType) {
            ((CredentialItem.StringType) item).setValue(passphrase);
        }
        // This will automatically say "yes" to prompts
        // TODO make this explicit to just accept host
        // TODO make this configurable
        if (item instanceof CredentialItem.YesNoType) {
            ((CredentialItem.YesNoType) item).setValue(true);
        }
    }
    return true;
}
 
开发者ID:trajano,项目名称:wagon-git,代码行数:21,代码来源:PassphraseCredentialsProvider.java

示例9: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items)
        throws UnsupportedCredentialItem {
    for (CredentialItem item : items) {
        if (item instanceof CredentialItem.Username) {
            ((CredentialItem.Username) item).setValue(username);
        } else if (item instanceof CredentialItem.Password) {
            ((CredentialItem.Password) item).setValue(password.toCharArray());
        } else if (item instanceof CredentialItem.StringType) {
            ((CredentialItem.StringType) item).setValue(password);
        } else if (item instanceof CredentialItem.InformationalMessage) {
            throw new UnsupportedCredentialItem(uri, "Not supported");
        } else if (item instanceof CredentialItem.YesNoType) {
            // TODO handle strict host key checking here
            throw new UnsupportedCredentialItem(uri, "Not supported");
        } else {
            throw new UnsupportedCredentialItem(uri, "Not supported");
        }
    }
    return true;
}
 
开发者ID:hdweiss,项目名称:mOrgAnd,代码行数:22,代码来源:JGitCredentialsProvider.java

示例10: supports

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public synchronized boolean supports(CredentialItem... credentialItems) {
    items:
    for (CredentialItem item : credentialItems) {
        if (supports(defaultCredentials, item)) {
            continue;
        }
        for (StandardCredentials c : specificCredentials.values()) {
            if (supports(c, item)) {
                continue items;
            }
        }
        return false;
    }
    return true;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:18,代码来源:SmartCredentialsProvider.java

示例11: supports

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * If username/password is given, use it for HTTP auth.
 */
@Override
public boolean supports(CredentialItem... items) {
    if (!(cred instanceof StandardUsernamePasswordCredentials))
        return false;

    for (CredentialItem i : items) {
        if (i instanceof CredentialItem.Username)
            continue;

        else if (i instanceof CredentialItem.Password)
            continue;

        else
            return false;
    }
    return true;
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:23,代码来源:CredentialsProviderImpl.java

示例12: setUp

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Before
public void setUp() {
    listener = StreamTaskListener.fromStdout();
    provider = new SmartCredentialsProvider(listener);
    username = new CredentialItem.Username();
    password = new CredentialItem.Password();

    maskedUsername = new StandardUsernameCredentialsCredentialItem(MASKED_USER_NAME_PROMPT, true);
    unmaskedUsername = new StandardUsernameCredentialsCredentialItem(UNMASKED_USER_NAME_PROMPT, false);

    maskedStringType = new CredentialItem.StringType(MASKED_STRING_TYPE_PROMPT, true);
    unmaskedStringType = new CredentialItem.StringType(UNMASKED_STRING_TYPE_PROMPT, false);
    specialStringType = new CredentialItem.StringType(SPECIAL_STRING_TYPE_PROMPT, false);

    assertNull(username.getValue());
    assertNull(password.getValue());
    assertNull(maskedUsername.getValue());
    assertNull(unmaskedUsername.getValue());
    assertNull(maskedStringType.getValue());
    assertNull(unmaskedStringType.getValue());
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:22,代码来源:SmartCredentialsProviderTest.java

示例13: get

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean get(URIish uri, CredentialItem... items) throws UnsupportedCredentialItem {
	for(CredentialItem item : items){
		if(item instanceof CredentialItem.YesNoType){
			((CredentialItem.YesNoType) item).setValue(true);
			return true;
		}
	}
	return false;
}
 
开发者ID:coding-dream,项目名称:Notebook,代码行数:11,代码来源:AllowHostsCredentialsProvider.java

示例14: supports

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean supports(CredentialItem... items) {
	for(CredentialItem item : items){
		if(item instanceof CredentialItem.YesNoType){
			return true;
		}
	}
	return false;
}
 
开发者ID:coding-dream,项目名称:Notebook,代码行数:10,代码来源:AllowHostsCredentialsProvider.java

示例15: supports

import org.eclipse.jgit.transport.CredentialItem; //导入依赖的package包/类
@Override
public boolean supports (CredentialItem... items) {
    for (CredentialItem i : items) {
        if (!(i instanceof CredentialItem.Username
                || i instanceof CredentialItem.Password)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TransportCommand.java


注:本文中的org.eclipse.jgit.transport.CredentialItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。