Skip to main content
1-Visitor
Mar 28, 2018 2:36 PM UTC
Solved

Extension Development - setting Runtime permissions for your extension's services

Hello!

 

I've developed a java extension for a resource whose services will be called within my thingworx platform.

 

Is there a way to hardcode-set the 'Service Execute' RunTime permissions on this extension's services, inside the .java file itself?

 

The idea is to have the permissions defined in the extension itself, otherwise, the Resources' collective permissions will be automatically assigned to my custom resource.

 

I've consulted the Extension Development Guide , but I could not find out how to do so. 

 

I imagine, such parameterization is to be set on the tag '@ThingworxServiceDefinition ' in the java code

E.G.:       @ThingworxServiceDefinition(name = "GenerateBillingDetailsReport", description = "Generate a pdf file with the Billing Details Report", category = "", isAllowOverride = false, aspects = {

       "isAsync:false" })

 

Thank you!

1-Visitor
Apr 4, 2018 10:12 AM UTC

So, I've received a response elsewere, which worked fine, and I'll re-post that answer here:

 

You can add permissions in the metadata.xml file of your extension. In the following example i'm giving ServiceInvoke permissions to all members of the Users group (every user in the platform):
```
<Resource className="com.thingworx.extensions.myresource" description="Tomcat utilities" name="MyResource">
<JarResources>
<FileResource type="JAR" file="resource-extension.jar" description="Test"/>
</JarResources>
<RunTimePermissions>
<Permissions resourceName="*">
<ServiceInvoke>
<Principal isPermitted="true" principalName="Users" type="Group"/>
</ServiceInvoke>
</Permissions>
</RunTimePermissions>
</Resource>
```

The easiest way to figure out the syntax for this permissions is to create a Thing, create permissions on it and then export it as XML.

1 reply

sebastiaoburnay1-VisitorAuthorAnswer
1-Visitor
Apr 4, 2018 10:12 AM UTC

So, I've received a response elsewere, which worked fine, and I'll re-post that answer here:

 

You can add permissions in the metadata.xml file of your extension. In the following example i'm giving ServiceInvoke permissions to all members of the Users group (every user in the platform):
```
<Resource className="com.thingworx.extensions.myresource" description="Tomcat utilities" name="MyResource">
<JarResources>
<FileResource type="JAR" file="resource-extension.jar" description="Test"/>
</JarResources>
<RunTimePermissions>
<Permissions resourceName="*">
<ServiceInvoke>
<Principal isPermitted="true" principalName="Users" type="Group"/>
</ServiceInvoke>
</Permissions>
</RunTimePermissions>
</Resource>
```

The easiest way to figure out the syntax for this permissions is to create a Thing, create permissions on it and then export it as XML.

Translate