本文整理汇总了Java中org.apache.sshd.common.keyprovider.KeyPairProvider类的典型用法代码示例。如果您正苦于以下问题:Java KeyPairProvider类的具体用法?Java KeyPairProvider怎么用?Java KeyPairProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyPairProvider类属于org.apache.sshd.common.keyprovider包,在下文中一共展示了KeyPairProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: DatabasePubKeyAuth
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Inject
DatabasePubKeyAuth(
SshKeyCacheImpl skc,
SshLog l,
IdentifiedUser.GenericFactory uf,
PeerDaemonUser.Factory pf,
SitePaths site,
KeyPairProvider hostKeyProvider,
@GerritServerConfig Config cfg,
SshScope s) {
sshKeyCache = skc;
sshLog = l;
userFactory = uf;
peerFactory = pf;
config = cfg;
sshScope = s;
myHostKeys = myHostKeys(hostKeyProvider);
peerKeyCache = new PeerKeyCache(site.peer_keys);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:DatabasePubKeyAuth.java
示例2: createTestHostKeyProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public static KeyPairProvider createTestHostKeyProvider(Class<?> anchor) {
KeyPairProvider provider = KEYPAIR_PROVIDER_HOLDER.get();
if (provider != null) {
return provider;
}
File targetFolder = ValidateUtils.checkNotNull(detectTargetFolder(anchor), "Failed to detect target folder");
File file = new File(targetFolder, "hostkey." + DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM.toLowerCase());
provider = createTestHostKeyProvider(file);
KeyPairProvider prev = KEYPAIR_PROVIDER_HOLDER.getAndSet(provider);
if (prev != null) { // check if somebody else beat us to it
return prev;
} else {
return provider;
}
}
开发者ID:termd,项目名称:termd,代码行数:18,代码来源:Utils.java
示例3: myHostKeys
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
private static Set<PublicKey> myHostKeys(KeyPairProvider p) {
final Set<PublicKey> keys = new HashSet<>(6);
addPublicKey(keys, p, KeyPairProvider.SSH_ED25519);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP256);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP384);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP521);
addPublicKey(keys, p, KeyPairProvider.SSH_RSA);
addPublicKey(keys, p, KeyPairProvider.SSH_DSS);
return keys;
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:DatabasePubKeyAuth.java
示例4: addPublicKey
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
private static void addPublicKey(
final Collection<PublicKey> out, KeyPairProvider p, String type) {
final KeyPair pair = p.loadKey(type);
if (pair != null && pair.getPublic() != null) {
out.add(pair.getPublic());
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:DatabasePubKeyAuth.java
示例5: myHostKeys
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
private List<PublicKey> myHostKeys() {
final KeyPairProvider p = getKeyPairProvider();
final List<PublicKey> keys = new ArrayList<>(6);
addPublicKey(keys, p, KeyPairProvider.SSH_ED25519);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP256);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP384);
addPublicKey(keys, p, KeyPairProvider.ECDSA_SHA2_NISTP521);
addPublicKey(keys, p, KeyPairProvider.SSH_RSA);
addPublicKey(keys, p, KeyPairProvider.SSH_DSS);
return keys;
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:SshDaemon.java
示例6: setupTestClient
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public static SshClient setupTestClient(Class<?> anchor) {
SshClient client = SshClient.setUpDefaultClient();
client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY);
client.setKeyPairProvider(KeyPairProvider.EMPTY_KEYPAIR_PROVIDER);
return client;
}
开发者ID:termd,项目名称:termd,代码行数:8,代码来源:Utils.java
示例7: testAuthKeyPassword
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Test
public void testAuthKeyPassword() throws Exception {
try (SshClient client = setupTestClient()) {
sshd.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE);
sshd.setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator.NONE);
client.start();
try (ClientSession s = client.connect(null, TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
Collection<ClientSession.ClientSessionEvent> result =
s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH),
TimeUnit.SECONDS.toMillis(11L));
assertFalse("Timeout while waiting for session", result.contains(ClientSession.ClientSessionEvent.TIMEOUT));
KeyPair pair = createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
try {
assertAuthenticationResult(UserAuthMethodFactory.PUBLIC_KEY, authPublicKey(s, getCurrentTestName(), pair), false);
} finally {
s.removePublicKeyIdentity(pair);
}
String password = getCurrentTestName();
try {
assertAuthenticationResult(UserAuthMethodFactory.PASSWORD, authPassword(s, getCurrentTestName(), password), true);
} finally {
s.removePasswordIdentity(password);
}
} finally {
client.stop();
}
}
}
开发者ID:termd,项目名称:termd,代码行数:33,代码来源:AuthenticationTest.java
示例8: getKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public KeyPairProvider getKeyPairProvider() {
return keyPairProvider;
}
开发者ID:aeshell,项目名称:aesh-readline,代码行数:4,代码来源:NettySshTtyBootstrap.java
示例9: setKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public NettySshTtyBootstrap setKeyPairProvider(KeyPairProvider keyPairProvider) {
this.keyPairProvider = keyPairProvider;
return this;
}
开发者ID:aeshell,项目名称:aesh-readline,代码行数:5,代码来源:NettySshTtyBootstrap.java
示例10: createHostKey
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Provides
@Singleton
KeyPairProvider createHostKey() {
return getHostKeys();
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:6,代码来源:InMemoryTestingDatabaseModule.java
示例11: configure
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Override
protected void configure() {
bind(KeyPairProvider.class).toProvider(HostKeyProvider.class).in(SINGLETON);
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:SshHostKeyModule.java
示例12: get
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Override
public KeyPairProvider get() {
Path objKey = site.ssh_key;
Path rsaKey = site.ssh_rsa;
Path dsaKey = site.ssh_dsa;
Path ecdsaKey_256 = site.ssh_ecdsa_256;
Path ecdsaKey_384 = site.ssh_ecdsa_384;
Path ecdsaKey_521 = site.ssh_ecdsa_521;
Path ed25519Key = site.ssh_ed25519;
final List<File> stdKeys = new ArrayList<>(6);
if (Files.exists(rsaKey)) {
stdKeys.add(rsaKey.toAbsolutePath().toFile());
}
if (Files.exists(dsaKey)) {
stdKeys.add(dsaKey.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_256)) {
stdKeys.add(ecdsaKey_256.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_384)) {
stdKeys.add(ecdsaKey_384.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_521)) {
stdKeys.add(ecdsaKey_521.toAbsolutePath().toFile());
}
if (Files.exists(ed25519Key)) {
stdKeys.add(ed25519Key.toAbsolutePath().toFile());
}
if (Files.exists(objKey)) {
if (stdKeys.isEmpty()) {
SimpleGeneratorHostKeyProvider p = new SimpleGeneratorHostKeyProvider();
p.setPath(objKey.toAbsolutePath());
return p;
}
// Both formats of host key exist, we don't know which format
// should be authoritative. Complain and abort.
//
stdKeys.add(objKey.toAbsolutePath().toFile());
throw new ProvisionException("Multiple host keys exist: " + stdKeys);
}
if (stdKeys.isEmpty()) {
throw new ProvisionException("No SSH keys under " + site.etc_dir);
}
FileKeyPairProvider kp = new FileKeyPairProvider();
kp.setFiles(stdKeys);
return kp;
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:50,代码来源:HostKeyProvider.java
示例13: toOpenSshPublicKey
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
/**
* Convert an RFC 4716 style key to an OpenSSH style key.
*
* @param keyStr the key string to convert.
* @return {@code keyStr} if conversion failed; otherwise the converted key, in OpenSSH key
* format.
*/
public static String toOpenSshPublicKey(String keyStr) {
try {
final StringBuilder strBuf = new StringBuilder();
final BufferedReader br = new BufferedReader(new StringReader(keyStr));
String line = br.readLine(); // BEGIN SSH2 line...
if (line == null || !line.equals("---- BEGIN SSH2 PUBLIC KEY ----")) {
return keyStr;
}
while ((line = br.readLine()) != null) {
if (line.indexOf(':') == -1) {
strBuf.append(line);
break;
}
}
while ((line = br.readLine()) != null) {
if (line.startsWith("---- ")) {
break;
}
strBuf.append(line);
}
final PublicKey key =
new ByteArrayBuffer(Base64.decodeBase64(Constants.encodeASCII(strBuf.toString())))
.getRawPublicKey();
if (key instanceof RSAPublicKey) {
strBuf.insert(0, KeyPairProvider.SSH_RSA + " ");
} else if (key instanceof DSAPublicKey) {
strBuf.insert(0, KeyPairProvider.SSH_DSS + " ");
} else {
return keyStr;
}
strBuf.append(' ');
strBuf.append("converted-key");
return strBuf.toString();
} catch (IOException e) {
return keyStr;
} catch (RuntimeException re) {
return keyStr;
}
}
开发者ID:gerrit-review,项目名称:gerrit,代码行数:53,代码来源:SshUtil.java
示例14: getKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public KeyPairProvider getKeyPairProvider() {
return keyPairProvider;
}
开发者ID:termd,项目名称:termd,代码行数:4,代码来源:NettySshTtyBootstrap.java
示例15: setKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public NettySshTtyBootstrap setKeyPairProvider(KeyPairProvider keyPairProvider) {
this.keyPairProvider = keyPairProvider;
return this;
}
开发者ID:termd,项目名称:termd,代码行数:5,代码来源:NettySshTtyBootstrap.java
示例16: createTestHostKeyProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
protected KeyPairProvider createTestHostKeyProvider() {
return Utils.createTestHostKeyProvider(getClass());
}
开发者ID:termd,项目名称:termd,代码行数:4,代码来源:BaseTestSupport.java
示例17: testMismatchedUserAuthPkOkData
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Test // see SSHD-624
public void testMismatchedUserAuthPkOkData() throws Exception {
final AtomicInteger challengeCounter = new AtomicInteger(0);
sshd.setUserAuthFactories(Collections.<NamedFactory<org.apache.sshd.server.auth.UserAuth>>singletonList(
new org.apache.sshd.server.auth.pubkey.UserAuthPublicKeyFactory() {
@Override
public org.apache.sshd.server.auth.pubkey.UserAuthPublicKey create() {
return new org.apache.sshd.server.auth.pubkey.UserAuthPublicKey() {
@Override
protected void sendPublicKeyResponse(ServerSession session, String username, String alg, PublicKey key,
byte[] keyBlob, int offset, int blobLen, Buffer buffer) throws Exception {
int count = challengeCounter.incrementAndGet();
outputDebugMessage("sendPublicKeyChallenge(%s)[%s]: count=%d", session, alg, count);
if (count == 1) {
// send wrong key type
super.sendPublicKeyResponse(session, username, KeyPairProvider.SSH_DSS, key, keyBlob, offset, blobLen, buffer);
} else if (count == 2) {
// send another key
KeyPair otherPair = org.apache.sshd.util.test.Utils.generateKeyPair(KeyUtils.RSA_ALGORITHM, 1024);
PublicKey otherKey = otherPair.getPublic();
Buffer buf = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_PK_OK, blobLen + alg.length() + Long.SIZE);
buf.putString(alg);
buf.putPublicKey(otherKey);
session.writePacket(buf);
} else {
super.sendPublicKeyResponse(session, username, alg, key, keyBlob, offset, blobLen, buffer);
}
}
};
}
}));
try (SshClient client = setupTestClient()) {
KeyPair clientIdentity = Utils.generateKeyPair(KeyUtils.RSA_ALGORITHM, 1024);
client.start();
try {
for (int index = 1; index <= 4; index++) {
try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
s.addPublicKeyIdentity(clientIdentity);
s.auth().verify(17L, TimeUnit.SECONDS);
assertEquals("Mismatched number of challenges", 3, challengeCounter.get());
break;
} catch (SshException e) { // expected
outputDebugMessage("%s on retry #%d: %s", e.getClass().getSimpleName(), index, e.getMessage());
Throwable t = e.getCause();
assertObjectInstanceOf("Unexpected failure cause at retry #" + index, InvalidKeySpecException.class, t);
}
}
} finally {
client.stop();
}
}
}
开发者ID:termd,项目名称:termd,代码行数:57,代码来源:AuthenticationTest.java
示例18: SinglePublicKeyAuthTest
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
public SinglePublicKeyAuthTest() {
SimpleGeneratorHostKeyProvider provider = new SimpleGeneratorHostKeyProvider();
provider.setAlgorithm(KeyUtils.RSA_ALGORITHM);
pairRsaBad = provider.loadKey(KeyPairProvider.SSH_RSA);
}
开发者ID:termd,项目名称:termd,代码行数:6,代码来源:SinglePublicKeyAuthTest.java
示例19: getKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Override
public KeyPairProvider getKeyPairProvider() {
throw new RuntimeException("Not implemented");
}
开发者ID:NLeSC,项目名称:Xenon,代码行数:5,代码来源:MockClientSession.java
示例20: setKeyPairProvider
import org.apache.sshd.common.keyprovider.KeyPairProvider; //导入依赖的package包/类
@Override
public void setKeyPairProvider(KeyPairProvider keyPairProvider) {
throw new RuntimeException("Not implemented");
}
开发者ID:NLeSC,项目名称:Xenon,代码行数:6,代码来源:MockClientSession.java
注:本文中的org.apache.sshd.common.keyprovider.KeyPairProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论