public static PemBlock parse(String entry) throws ParseException { return new PemBlockModel().parse(entry); }
public static PemKey toKey(String key) throws ParseException { return new PemKey(new PemBlockModel().parse(key)); }
public PemBlockList(String string) { while(true) { try { int p = string.indexOf("-----BEGIN "); if (p < 0) break; PemBlockModel next = new PemBlockModel().parse(string); add(next); string = next.getRest(); } catch (ParseException e) { MLogUtil.log().t(e); break; } } }
public static PemPriv cipherPrivFromString(String str) throws ParseException, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPriv key = MVaultUtil.adaptTo(entry, PemPriv.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':').toUpperCase().trim(); String key = MString.afterIndex(str, ':').trim(); return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPriv signPrivFromString(String str) throws Exception, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPriv key = MVaultUtil.adaptTo(entry, PemPriv.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_SIGN).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPub signPubFromString(String str) throws NotSupportedException, IOException, ParseException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPub key = MVaultUtil.adaptTo(entry, PemPub.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_SIGN).set(PemBlock.METHOD, name).setBlock(key); }
public static PemPub cipherPubFromString(String str) throws ParseException, NotSupportedException, IOException { if (MValidator.isUUID(str)) { MVault vault = MVaultUtil.loadDefault(); VaultEntry entry = vault.getEntry(UUID.fromString(str)); PemPub key = MVaultUtil.adaptTo(entry, PemPub.class); return key; } if (isPemBlock(str)) { PemBlockModel block = new PemBlockModel().parse(str); // return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, block.getString(PemBlock.METHOD,"")).setBlock(block.getEncodedBlock()); return new PemKey(block); } String name = MString.beforeIndex(str, ':'); String key = MString.afterIndex(str, ':'); return new PemKey(PemBlock.BLOCK_CIPHER).set(PemBlock.METHOD, name).setBlock(key); }