Jaspersoft / jrs-rest-java-client

Java Rest Client for JasperReports Server
GNU Lesser General Public License v3.0
101 stars 103 forks source link

Attributes service creates attributes, but do not associate permissions with it #139

Closed tmatveyeva closed 9 years ago

tmatveyeva commented 9 years ago

If we have profile attribute defined as follows:

<bean id="pattrTenantAttribute" class="com.jaspersoft.jasperserver.dto.authority.ClientUserAttribute">
    <property name="name" value="OrganizationAttributeTest"/>
    <property name="value" value="Organization attribute test value"/>
    <property name="description" value="Organization attribute description"/>
    <property name="permissionMask" value="32"/>
    <property name="secure" value="false"/>
    <property name="inherited" value="false"/>
    <property name="holder" value="tenant:/organization_1"/>
</bean>

(Permission mask is different than administrate)

and run the following request:

                session.attributesService()
                        .forOrganization("organization_1)
                        .attribute("OrganizationAttributeTest")
                        .setIncludePermissions(true)
                        .createOrUpdate(attribute);

Attribute is created, but permission mask would be 1 (administrate)

yaroslav-kovalchyk commented 9 years ago

Fixed

tmatveyeva commented 9 years ago

The issue isn't fixed in 6.1.1

Test code

Maven dependency:

<dependency>
    <groupId>com.jaspersoft</groupId>
    <artifactId>jrs-rest-java-client</artifactId>
    <version>6.1.1</version>
</dependency>

Attribute:

<bean id="executeOnlyAttribute" class="com.jaspersoft.jasperserver.dto.authority.hypermedia.HypermediaAttribute">
    <property name="name" value="ExecuteOnlyAttribute"/>
    <property name="value" value="Execute Only Attribute value"/>
    <property name="description" value="Execute Only Attribute description"/>
    <property name="permissionMask" value="32"/>
    <property name="secure" value="false"/>
    <property name="inherited" value="true"/>
    <property name="holder" value="tenant:/"/>
    <property name="embedded" ref="executeOnlyPermissionContainer"/>
</bean>
<bean id="executeOnlyPermission" class="com.jaspersoft.jasperserver.dto.permissions.RepositoryPermission">
    <property name="mask" value="0"/>
    <property name="recipient" value="role:/ROLE_ADMINISTRATOR"/>
</bean>
<bean id="executeOnlyPermissionContainer"  class="com.jaspersoft.jasperserver.dto.authority.hypermedia.HypermediaAttributeEmbeddedContainer">
    <property name="repositoryPermissions">
        <list value-type="com.jaspersoft.jasperserver.dto.permissions.RepositoryPermission">
            <ref bean="executeOnlyPermission"/>
        </list>
    </property>
</bean>

Java code:

session.attributesService()
        .attribute(executeOnlyAttribute.getName())
        .setIncludePermissions(true)
        .createOrUpdate(executeOnlyAttribute);

This will still create an administrate permission. I think to make it work in the client you need to pass HypermediaAttribute, and not ClientUserAttribute.

yaroslav-kovalchyk commented 9 years ago

Fixed