use of org.tomitribe.util.PrintString in project churchkey by tomitribe.
the class JsonAsserts method normalize.
private static String normalize(final String json) {
final JsonReader reader = Json.createReader(IO.read(json));
final JsonValue object = reader.readValue();
final JsonValue jsonObject = sort(object);
final Map<String, Object> properties = new HashMap<>(1);
properties.put(JsonGenerator.PRETTY_PRINTING, true);
final JsonGeneratorFactory jgf = Json.createGeneratorFactory(properties);
final PrintString out = new PrintString();
final JsonGenerator jg = jgf.createGenerator(out);
jg.write(jsonObject);
jg.flush();
return out.toString();
}
use of org.tomitribe.util.PrintString in project churchkey by tomitribe.
the class ECParameterSpecs method toString.
public static String toString(final ECParameterSpec spec) {
final PrintString out = new PrintString();
final String x = hex(spec.getGenerator().getAffineX());
final String y = hex(spec.getGenerator().getAffineY());
final String a = hex(spec.getCurve().getA());
final String b = hex(spec.getCurve().getB());
final String n = hex(spec.getOrder());
final int cofactor = spec.getCofactor();
final ECField field = spec.getCurve().getField();
if (field instanceof ECFieldFp) {
final ECFieldFp fp = (ECFieldFp) field;
final String p = hex(fp.getP());
out.printf("prime(\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " %s), %s)\n", p, a, b, x, y, n, cofactor, null);
} else if (field instanceof ECFieldF2m) {
final ECFieldF2m binary = (ECFieldF2m) field;
final int m = binary.getM();
final List<Integer> terms = new ArrayList<>();
for (final int i : binary.getMidTermsOfReductionPolynomial()) {
terms.add(i);
}
out.printf("binary(%s, new int[]{%s},\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " \"%s\",\n" + " %s), %s)\n", m, Join.join(", ", terms), a, b, x, y, n, cofactor, null);
}
return out.toString();
}
use of org.tomitribe.util.PrintString in project tomee-site-generator by apache.
the class ApisUsed method addApiList.
private static String addApiList(final String source, final String link, final String linkText) {
final PrintString out = new PrintString();
out.println("");
out.println("== APIs Used");
out.println("");
out.printf("- link:%s[%s]%n", link, linkText);
return source + out.toString();
}
use of org.tomitribe.util.PrintString in project churchkey by tomitribe.
the class KeyInput method readAuthMagic.
public String readAuthMagic() throws IOException {
final PrintString string = new PrintString();
int read = this.read();
while (read != '\000') {
if (read == -1)
throw new EOFException();
string.write(read);
read = this.read();
}
return string.toString();
}
use of org.tomitribe.util.PrintString in project churchkey by tomitribe.
the class Pem method format.
public String format() {
final PrintString out = new PrintString();
out.println(header);
for (final Map.Entry<String, String> entry : attributes.entrySet()) {
out.printf("%s: \"%s\"%n", entry.getKey(), entry.getValue());
}
{
// Write the data as base64 encoded
final ByteArrayInputStream encoded = new ByteArrayInputStream(Base64.getEncoder().encode(data));
try {
final byte[] line = new byte[wrap];
int length;
while ((length = encoded.read(line)) != -1) {
out.println(new String(line, 0, length));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
out.println(footer);
return out.toString();
}
Aggregations