I am loading Google's java client for service account authorization by putting the .jar files in the WEB-INF/lib folder of the Coldfusion server. The java objects can be created by like this:
<cfset credential = createObject("java", "com.google.api.client.googleapis.auth.oauth2.GoogleCredential") />
but if the java class has any inner classes in the form of ClassName$InnerClassName
, they don't seem to be loaded when the object is dumped.
Specifically, I trying to add the .jar files downloaded from here: https://code.google.com/p/google-api-java-client/downloads/list
The code I'm trying to convert to CF is:
GoogleCredential credential = new GoogleCredential.Builder().setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("[[INSERT SERVICE ACCOUNT EMAIL HERE]]")
.setServiceAccountScopes(PlusScopes.PLUS_ME)
.setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
.build();
This <cfset credential = createObject("java", "com.google.api.client.googleapis.auth.oauth2.GoogleCredential") />
creates the object just fine but when it's dumped or the Builder() method is called in the code, the dump doesn't show the Builder method or it's says the method can't be found respectively.
When I extracted the classes from the google-api-client-1.17.0-rc.jar
file the class with the method is there as GoogleCredential$Builder.class
Bottom line is that everything seems to be in order in the .jar files but when they are added to CF, not everything is there.
Anyone know why CF isn't loading the .jar files completely?
To get CF to load the nested class you need to call it like this:
After that the conversion process from java to CF went smoothly.