private static XRD createAuthRoot(String uri, TrustType tt) {
XRD xrd = new XRD();
// construct an authority resolution service
Service srv = new Service();
if (tt == null)
tt = new TrustType(); // default trust type
else {
try {
X509Certificate[] arr = new X509Certificate[1];
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("keystore.jks");
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(is, "password".toCharArray());
arr[0] = (X509Certificate)ks.getCertificate("issuercert");
Document oDoc = new DocumentImpl();
KeyInfo oKeyInfo = new KeyInfo(oDoc);
X509Data oData = new X509Data(oDoc);
oData.addCertificate(arr[0]);
oKeyInfo.add(oData);
srv.setKeyInfo(oKeyInfo);
srv.setProviderId("@!E459.819D.771.7990!5B62.6F13.7602.5176");
} catch (Exception e) {
throw new RuntimeException("Failed to load keystore alias (certificate): " + e.toString());
}
}
String authMediaType = Tags.CONTENT_TYPE_XRDS + ";"
+ tt.getParameterPair();
srv.addMediaType(authMediaType, null, Boolean.FALSE);
srv.addType(Tags.SERVICE_AUTH_RES);
srv.addURI(uri);
// add it to the XRD
xrd.addService(srv);