Question

5
Replies
4198
Views
John Pritchard-Williams (JOHNPW_GCS)
PEGA
Client Support Team Lead
Pegasystems Inc.
GB
JOHNPW_GCS Member since 2009 20 posts
PEGA
Posted: November 7, 2016
Last activity: January 1, 2017
Posted: 7 Nov 2016 12:45 EST
Last activity: 1 Jan 2017 9:28 EST
Closed
Solved

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 ?

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

 

Data Integration Java and Activities
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.