Skip to content

Instantly share code, notes, and snippets.

@pglezen
Created October 7, 2014 03:17
Show Gist options
  • Save pglezen/56d1069b55b5f3caa363 to your computer and use it in GitHub Desktop.
Save pglezen/56d1069b55b5f3caa363 to your computer and use it in GitHub Desktop.
Script WAS WS-Security client policy set bindings
import sys
appName = "CCConsumerApp"
serviceName = "WebService:/CCConsumerWeb.war:{urn:issw:bare:wssec:cc:query}CCService"
policySetExport = "\\policySets\\Sign Timestamp.zip"
policySetName = "Sign Timestamp"
clientBindingExport = "\\policySets\\CCConsumerBindings.zip"
clientBindingName = "CCConsumerBindings"
print "Cell name", AdminControl.getCell()
print "Node name", AdminControl.getNode()
print
print "The following are hard-coded parameters."
print "\tApplication name =", appName
print "\tService name =", serviceName
print "\tPolicy Set Export =", policySetExport
print "\tPolicy Set Name =", policySetName
print "\tClient Bindings Export =", clientBindingExport
print "\tClient Bindings Name =", clientBindingName
print "Importing policy set from", policySetExport
rc = AdminTask.importPolicySet('[-importFile "' + policySetExport + '" -verifyPolicySetType application]')
if rc == 'true':
print "Policy set import succeeded."
else:
print "Policy set import failed with return code", rc
sys.exit()
print "Import client binding from, ", clientBindingExport
rc = AdminTask.importBinding('[-importFile "' + clientBindingExport + '" -verifyBindingType client]')
if rc == 'true':
print "Client binding import succeeded."
else:
print "Client binding import failed."
sys.exit()
print "Attaching policy set to", appName, " with client", serviceName
attachID = AdminTask.createPolicySetAttachment('[-applicationName ' + appName + ' -attachmentType client -policySet "' + policySetName + '" -resources [' + serviceName + ']]')
print "Attachment ID = ", attachID
print "Assigning binding ..."
rc = AdminTask.setBinding('[-bindingScope domain -bindingName ' + clientBindingName + ' -attachmentType client -bindingLocation [[application ' + appName + '] [attachmentId ' + attachID + ']]]')
if rc == 'true':
print "Binding assigned successfully. Saving result."
AdminConfig.save()
print "Saved. Remember to restart client service JVM for changes to take affect."
else:
print "Binding assignment failed. Return code", rc
print "Not saving changes."
>wsadmin -lang jython -f \wsadmin\ccConsumer.py
WASX7209I: Connected to process "server1" on node node1 using SOAP connector; The type of process is: UnManagedProcess
Cell name WIN-Node06Cell
Node name node1
The following are hard-coded parameters.
Application name = CCConsumerApp
Service name = WebService:/CCConsumerWeb.war:{urn:issw:bare:wssec:cc:query}CCService
Policy Set Export = \policySets\Sign Timestamp.zip
Policy Set Name = Sign Timestamp
Client Bindings Export = \policySets\CCConsumerBindings.zip
Client Bindings Name = CCConsumerBindings
Importing policy set from \policySets\Sign Timestamp.zip
Policy set import succeeded.
Import client binding from, \policySets\CCConsumerBindings.zip
Client binding import succeeded.
Attaching policy set to CCConsumerApp with client WebService:/CCConsumerWeb.war:{urn:issw:bare:wssec:cc:query}CCService
Attachment ID = 1013
Assigning binding ...
Binding assigned successfully. Saving result.
Saved. Remember to restart client service JVM for changes to take affect.
C:\>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment