public final static String toHexString(byte data[]) { StringBuilder sb = new StringBuilder(); try { append(sb, data); } catch (IOException e) { // cannot happen with sb } return sb.toString(); }
@Override public Object convert(Type dest, Object o) throws Exception { if (o instanceof String) { String s = (String) o; if (Hex.isHex(s)) return Hex.toByteArray(s); } return null; } });
@Override public String toString() { try { return "P-" + getResource(); } catch (Exception e) { return "P-" + Hex.toHexString(sha); } }
@Override Object decode(Decoder dec, String s) throws Exception { return Hex.toByteArray(s); } }
if (!Hex.isHex(unicode)) { error("Invalid unicode string \\u%s", sb); return '?';
public static String separated(byte[] bytes, String separator) { String del=""; StringBuilder sb = new StringBuilder(); for ( byte x : bytes) { sb.append(del); sb.append(toHex(x)); del = separator; } return sb.toString(); } }
@Override public void encode(Encoder app, Object object, Map<Object,Type> visited) throws IOException, Exception { StringHandler.string(app, Hex.toHexString((byte[]) object)); }
@Override public Object convert(Type dest, Object o) throws Exception { if (o instanceof String) return Hex.toByteArray((String) o); return null; } });
if (!Hex.isHex(head)) {
public static String separated(byte[] bytes, String separator) { String del=""; StringBuilder sb = new StringBuilder(); for ( byte x : bytes) { sb.append(del); sb.append(toHex(x)); del = separator; } return sb.toString(); } }
public String toString() { try { return "P-" + getResource(); } catch (Exception e) { return "P-" + Hex.toHexString(sha); } }
public final static String toHexString(byte data[]) { StringBuilder sb = new StringBuilder(); try { append(sb, data); } catch (IOException e) { // cannot happen with sb } return sb.toString(); }
@Override public void setProperties(Map<String, String> map) throws Exception { super.setProperties(map); String email = map.get(EMAIL); if (email == null) { Settings settings = registry.getPlugin(Settings.class); email = settings.getEmail(); if (email == null) { error( "The bnd authentication URL connection handler has no email set as property, nor have the bnd settings been set"); return; } credentials(email, settings.getPublicKey(), settings.getPrivateKey()); } else { String pub = map.get(PUBLIC_KEY); String prv = map.get(PRIVATE_KEY); if (pub == null || !Hex.isHex(pub)) { error("The bnd authentication URL public key for email %s is not a hex string %s", email, pub); return; } if (prv == null || !Hex.isHex(prv)) { error("The bnd authentication URL private key for email %s is not a hex string", email); return; } credentials(email, Hex.toByteArray(pub), Hex.toByteArray(prv)); } machine = map.get(MACHINE); }
return Hex.toByteArray(sb.toString()); else return Base64.decodeBase64(sb.toString());
if (!Hex.isHex(head)) {
public static String separated(byte[] bytes, String separator) { String del=""; StringBuilder sb = new StringBuilder(); for ( byte x : bytes) { sb.append(del); sb.append(toHex(x)); del = separator; } return sb.toString(); } }
@Override public String toString() { try { return "P-" + getResource(); } catch (Exception e) { return "P-" + Hex.toHexString(sha); } }