Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Best practice to handle security exceptions

    Hi,
    I'm trying to handle the following exception:
    java.lang.SecurityException: DataSource 'histprices', operationType 'update', operationId 'histprices_update'. This operation requires role(s) 'user'. User 'visitor' fails the role check.

    This is the standard error reported by the server when I try to update a table without sufficient privileges. Find below the Datasource description:
    <DataSource
    dbName="DB2"
    tableName="histprices"
    ID="histprices"
    dataSourceVersion="1"
    serverType="sql"
    >
    <fields>
    <field title="Instrument ID" name="INSTRID" type="number" primaryKey="true" canEdit="false" width="100" detail="true"></field>
    <field title="Session date" name="PRICEDATE" type="date" displayFormat= "toEuropeanShortDate" primaryKey="true" width="100" detail="false"></field>
    <field title="Closing price" name="CLOSEPR" type="decimal" required="true" detail="false">
    <validators>
    <validator type="floatRange" min="0" errorMessage="Please enter a positive value"/>
    </validators>
    </field>
    <field title="Status" name="STATUS" length="1" type="text" width="50" detail="true">
    <valueMap>
    <value ID="E">Enabled</value>
    <value ID="A">Analysis only</value>
    <value ID="D">Disabled</value>
    </valueMap>
    </field>
    <field title="Last update" name="UPDDATE" type="datetime" displayFormat= "toEuropeanShortDateTime" width="110" canEdit="false" detail="true"></field>
    <field title="User" name="USERUPD" length="30" type="text" canEdit="false" width="90" detail="true" ></field>
    </fields>
    <operationBindings>
    <operationBinding operationType="fetch" requiresAuthentication="true" requiresRoles="user,visitor"/>
    <operationBinding operationType="add" requiresAuthentication="true" requiresRole="user"/>
    <operationBinding operationType="update" requiresAuthentication="true" requiresRole="user"/>
    <operationBinding operationType="remove" requiresAuthentication="true" requiresRole="user"/>
    </operationBindings>
    </DataSource>

    What is the best practice to do that?
    Thank you very much for your help.

    #2
    Not sure what kind of best practice you're looking for - error handling, UI design, something else? Generally, don't offer a user functionality that you know in advance won't work because they don't have the privileges. Do this by, for example, sending the list of roles to the browser as the application start up, and using it to avoid creating UI controls, such as buttons, that won't work for the current user.

    Comment

    Working...
    X