@Override public Iterable<java.security.KeyPair> loadKeys() { if (!SecurityUtils.isBouncyCastleRegistered()) { throw new IllegalStateException("BouncyCastle must be registered as a JCE provider"); } List<KeyPair> keys = new ArrayList<KeyPair>(); if (key != null) { try { Object o = KeyPairUtils.readKey(new InputStreamReader(new ByteArrayInputStream(key.getContent()))); if (o instanceof KeyPair) { keys.add((KeyPair) o); } else if(o instanceof PEMKeyPair) { JcaPEMKeyConverter converter = new JcaPEMKeyConverter(); keys.add(converter.getKeyPair((PEMKeyPair)o)); } } catch (Exception e) { log.log(Level.INFO, "Unable to read key " + key + ": " + key, e); } } return keys; } }
public static int[] checkNotNullAndNotEmpty(int[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(NumberUtils.length(a) > 0, message, args); return a; }
public static <T, C extends Iterable<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) { t = checkNotNull(t, message, args); checkTrue(GenericUtils.isNotEmpty(t), message, args); return t; }
public static char[] checkNotNullAndNotEmpty(char[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(GenericUtils.length(a) > 0, message, args); return a; }
public static <T, C extends Collection<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) { t = checkNotNull(t, message, args); checkTrue(GenericUtils.size(t) > 0, message, args); return t; }
@Override public void init() { SecurityUtils.setRegisterBouncyCastle(true);
public SSHClient connect() throws Exception { Map<PtyMode, Integer> tty = SttySupport.parsePtyModes(TTY);
public static byte[] checkNotNullAndNotEmpty(byte[] a, String message) { a = checkNotNull(a, message); checkTrue(NumberUtils.length(a) > 0, message); return a; }
public static char[] checkNotNullAndNotEmpty(char[] a, String message) { a = checkNotNull(a, message); checkTrue(GenericUtils.length(a) > 0, message); return a; }
public static <T, C extends Collection<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) { t = checkNotNull(t, message, args); checkTrue(GenericUtils.size(t) > 0, message, args); return t; }
public static <T, C extends Iterable<T>> C checkNotNullAndNotEmpty(C t, String message, Object... args) { t = checkNotNull(t, message, args); checkTrue(GenericUtils.isNotEmpty(t), message, args); return t; }
public Iterable<KeyPair> loadKeys() { if (!SecurityUtils.isBouncyCastleRegistered()) { throw new IllegalStateException("BouncyCastle must be registered as a JCE provider"); } List<KeyPair> keys = new ArrayList<KeyPair>(); for (String file : files) { try { Object o = KeyPairUtils.readKey(new InputStreamReader(new FileInputStream(file))); if (o instanceof KeyPair) { keys.add(new KeyPair(((KeyPair)o).getPublic(), null)); } else if (o instanceof PublicKey) { keys.add(new KeyPair((PublicKey)o, null)); } else if (o instanceof PEMKeyPair) { PEMKeyPair keyPair = (PEMKeyPair)o; keys.add(convertPemKeyPair(keyPair)); } else if (o instanceof SubjectPublicKeyInfo) { PEMKeyPair keyPair = new PEMKeyPair((SubjectPublicKeyInfo) o, null); keys.add(convertPemKeyPair(keyPair)); } else { throw new UnsupportedOperationException(String.format("Key type %s not supported.", o.getClass().getName())); } } catch (Exception e) { LOG.info("Unable to read key {}: {}", file, e); } } return keys; }
public static int[] checkNotNullAndNotEmpty(int[] a, String message) { a = checkNotNull(a, message); checkTrue(NumberUtils.length(a) > 0, message); return a; }
public static <T> T[] checkNotNullAndNotEmpty(T[] t, String message, Object... args) { t = checkNotNull(t, message, args); checkTrue(GenericUtils.length(t) > 0, message, args); return t; }
public static byte[] checkNotNullAndNotEmpty(byte[] a, String message) { a = checkNotNull(a, message); checkTrue(NumberUtils.length(a) > 0, message); return a; }
public static char[] checkNotNullAndNotEmpty(char[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(GenericUtils.length(a) > 0, message, args); return a; }
public static int[] checkNotNullAndNotEmpty(int[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(NumberUtils.length(a) > 0, message, args); return a; }
public static byte[] checkNotNullAndNotEmpty(byte[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(NumberUtils.length(a) > 0, message, args); return a; }
public static byte[] checkNotNullAndNotEmpty(byte[] a, String message, Object... args) { a = checkNotNull(a, message, args); checkTrue(NumberUtils.length(a) > 0, message, args); return a; }
public static int[] checkNotNullAndNotEmpty(int[] a, String message) { a = checkNotNull(a, message); checkTrue(NumberUtils.length(a) > 0, message); return a; }