Question
How to create a PRPC Page 'pxResults' type page from Java Step.
I'm trying to build an Utility to list some details of Trusted Certificates (contained in the default JVM Truststore).
Here's the code : this works - but only logs the results to the PegaRules.log - Ideally, I would like this in the form a PRPC Page (so we can do more interesting stuff with it; and also to avoid having to check the logs):
This all works within a single Java Step:
try {
javax.net.ssl.TrustManagerFactory trustManagerFactory = javax.net.ssl.TrustManagerFactory.getInstance(javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm() );
trustManagerFactory.init((java.security.KeyStore)null);
for (javax.net.ssl.TrustManager trustManager : trustManagerFactory.getTrustManagers() ) {
javax.net.ssl.X509TrustManager x509TrustManager = (javax.net.ssl.X509TrustManager)trustManager;
int i = 1;
for (java.security.cert.X509Certificate cert : x509TrustManager.getAcceptedIssuers()) {
oLog.infoForced( i + ":"+cert.getIssuerX500Principal());
i++;
}
}
}
catch(Exception e) { throw new PRRuntimeException(e); }
So: as an example how could we get a PRPC Page to contain this information : assume I have a DATA CLASS which contains a Property called 'Issuer' (which would correspond to 'getIssuerX500Principal') - can somebody provide a working example of how to do this ?
(And then I can try and generalize it to include other Certificate information such as "Serial Number" [using 'getSerialNumber' of the Java API]).
Thanks,
John
Hi John,
While there are many ways to achive this, if I were trying to do this, I would call an activity from inside the loop in your java. The activity can do the actual propery sets, or call a data transform. Since you are using an activity that would be more traceable, and understandable by other PRPC developers.
You can call an activity from java steps like this...
myStepPage will be generated by the rule generation so you don't need to declare it.