Role/group security is now at a frustrating 'very nearly' stage. I now believe I'm setting up all

the security correctly in the transforms, but the SecurityHelper is not yet correctly discovering
group membership.
This commit is contained in:
sb 2009-02-02 18:13:39 +00:00
parent b7caa8281a
commit 493cbb9527
3 changed files with 161 additions and 64 deletions

View file

@ -8,8 +8,8 @@
Transform ADL into C# entity classes
$Author: sb $
$Revision: 1.15 $
$Date: 2009-01-12 10:51:40 $
$Revision: 1.16 $
$Date: 2009-02-02 18:13:39 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -48,12 +48,65 @@
<xsl:variable name="permittedinconstantname">ABCDEFGHIJKLMNOPQRSTUVWXYZ_________</xsl:variable>
<xsl:template match="adl:application">
<xsl:apply-templates select="adl:group"/>
<xsl:apply-templates select="adl:entity"/>
</xsl:template>
<!-- Don't bother generating anything for foreign entities -->
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:group">
/* ---- [ cut here: next file '<xsl:value-of select="concat( 'AuthCheck', @name)"/>.auto.cs'] ---------------- */
//-------------------------------------------------------------
//
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="concat( 'AuthCheck', @name)"/>.auto.cs
//
// (c)2007 Cygnet Solutions Ltd
//
// Automatically generated from application description using
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
//
// <xsl:value-of select="/adl:application/@revision"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
//-------------------------------------------------------------
using System;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Cygnet.Exceptions;
using Cygnet.Entities;
using Iesi.Collections.Generic;
using NHibernate;
using NHibernate.Classic;
namespace <xsl:value-of select="$entityns"/>
{
/// &lt;summary&gt;
/// Dummy entity class for security group <xsl:value-of select="@name"/>
/// <xsl:value-of select="normalize-space( adl:documentation)"/>
/// &lt;/summary&gt;
/// &lt;remarks&gt;
/// Automatically generated from description of group <xsl:value-of select="@name"/>
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>.
///
/// DO NOT EDIT THIS FILE!
/// &lt;/remarks&gt;
public class <xsl:value-of select="concat( 'AuthCheck', @name)"/> : Entity {
private int _Check;
public virtual int Check {
get { return Check; }
set { _Check = value; }
}
}
}
</xsl:template>
<xsl:template match="adl:entity">
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
@ -66,7 +119,7 @@
// (c)2007 Cygnet Solutions Ltd
//
// Automatically generated from application description using
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/>
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>
//
// <xsl:value-of select="/adl:application/@revision"/>
//
@ -92,7 +145,7 @@
/// &lt;/summary&gt;
/// &lt;remarks&gt;
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.15 $', 10)"/>.
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/>.
/// Note that manually maintained parts of this class may be defined in
/// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v.
///

View file

@ -12,7 +12,7 @@
Transform ADL to Hibernate
$Author: sb $
$Revision: 1.7 $
$Revision: 1.8 $
-->
<xsl:param name="namespace"/>
@ -138,7 +138,7 @@
*
* <xsl:value-of select="@revision"/>
*
* Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.7 $', 12)"/>
* Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.8 $', 12)"/>
*
***************************************************************************
</xsl:comment>
@ -148,6 +148,32 @@
</xsl:template>
<xsl:template match="adl:group">
<xsl:comment>
Authentication check table for security group <xsl:value-of select="@name"/>
</xsl:comment>
<xsl:apply-templates select="adl:documentation"/>
<xsl:variable name="prefix">
<xsl:choose>
<xsl:when test="string-length( $database) &gt; 0">
<xsl:value-of select="concat( $database, '.dbo.')"/>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:variable>
<class>
<xsl:attribute name="name">
<xsl:value-of select="concat( 'AuthCheck', @name)"/>
</xsl:attribute>
<xsl:attribute name="table">
<xsl:value-of select="concat( $prefix, '[', @table, ']')"/>
</xsl:attribute>
<id name="Check" column="Check" type="int">
<generator class="native"/>
</id>
</class>
</xsl:template>
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:entity">

View file

@ -15,8 +15,8 @@
Transform ADL into velocity view templates
$Author: sb $
$Revision: 1.21 $
$Date: 2009-02-02 10:49:13 $
$Revision: 1.22 $
$Date: 2009-02-02 18:13:39 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! -->
@ -126,7 +126,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
</xsl:comment>
<xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/>
@ -163,7 +163,7 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
<xsl:value-of select="/adl:application/@revision"/>
</xsl:comment>
@ -246,7 +246,7 @@
Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
<xsl:value-of select="/adl:application/@revision"/>
</xsl:comment>
@ -368,7 +368,7 @@
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
<xsl:value-of select="/adl:application/@revision"/>
</xsl:comment>
@ -963,7 +963,7 @@
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.DisplayAndHidden( "<xsl:value-of select="concat( 'instance.', @name)"/>", "%{rendermode='<xsl:value-of select="normalize-space($render-mode)"/>',class='<xsl:value-of select="normalize-space($cssclass)"/>',title='<xsl:value-of select="normalize-space($if-missing)"/>',size='<xsl:value-of select="normalize-space($size)"/>',maxlength='<xsl:value-of select="normalize-space($maxlength)"/>',rows='<xsl:value-of select="normalize-space($rows)"/>'}")}
#else
</xsl:if>
[You are not authorised to view this value]
[Not authorised]
<xsl:if test="exsl:node-set( $readgroups)/*">
#end
</xsl:if>
@ -1000,7 +1000,7 @@
Auto generated Velocity list for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
</xsl:comment>
#capturefor( title)
@ -1038,7 +1038,7 @@
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.21 $', 10)"/>
Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.22 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
</head>
@ -1190,31 +1190,10 @@
<tr class="$oddity">
<xsl:for-each select="$fields">
<xsl:variable name="field" select="."/>
<td>
<xsl:choose>
<xsl:when test="not( $entity//adl:property[@name=$field/@property]/@name)">
<!-- shouldn't happen. There is definitely a bug here, because it does happen - but it shouldn't -->
</xsl:when>
<xsl:when test="$entity//adl:property[@name=$field/@property]/@type = 'date'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="$entity//adl:property[@name=$field/@property]/@type='message'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
$t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
#end
</xsl:when>
<xsl:when test="$entity//adl:property[@name=$field/@property]/@type='entity'">
#if( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name, '.UserIdentifier')"/>
#end
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '$!', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:call-template name="list-field">
<xsl:with-param name="entity" select="$entity"/>
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into
@ -1332,28 +1311,10 @@
#end
<tr class="$oddity">
<xsl:for-each select="$properties">
<td>
<xsl:choose>
<xsl:when test="@type = 'date'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="@type='message'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
$t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
#end
</xsl:when>
<xsl:when test="@type='entity'">
#if( <xsl:value-of select="concat( '$', $entity/@name, '.', @name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', @name, '.UserIdentifier')"/>
#end
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '$!', $entity/@name, '.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</td>
<xsl:call-template name="list-field">
<xsl:with-param name="entity" select="$entity"/>
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into
@ -1392,6 +1353,48 @@
</table>
</xsl:template>
<!-- output a list field -->
<xsl:template name="list-field">
<xsl:param name="entity"/>
<xsl:param name="property"/>
<xsl:variable name="readgroups">
<xsl:call-template name="collect-read-groups">
<xsl:with-param name="property" select="$property"/>
</xsl:call-template>
</xsl:variable>
<td>
<xsl:if test="exsl:node-set( $readgroups)/*">
#if ( <xsl:for-each select="exsl:node-set( $readgroups)/*">${SecurityHelper.InGroup( "<xsl:value-of select="./@name"/>")}<xsl:if test="not( position() = last())"> || </xsl:if></xsl:for-each>)
${<xsl:value-of select="concat( ancestor::adl:entity/@name, 'FieldHelper')"/>.Display( "<xsl:value-of select="concat( 'instance.', $property/@name)"/>", "")}
#else
</xsl:if>
[Not authorised]
<xsl:if test="exsl:node-set( $readgroups)/*">
#end
</xsl:if>
<!-- xsl:choose>
<xsl:when test="$property/@type = 'date'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="$property/@type='message'">
#if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
$t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
#end
</xsl:when>
<xsl:when test="$property/@type='entity'">
#if( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
<xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name, '.UserIdentifier')"/>
#end
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( '$!', $entity/@name, '.', $property/@name)"/>
</xsl:otherwise>
</xsl:choose -->
</td>
</xsl:template>
<!-- overall page layout -->
@ -1604,7 +1607,7 @@
</xsl:for-each>
</xsl:template>
<!-- those groups which can insert but not edit -->
<!-- those groups which can insert -->
<xsl:template name="collect-insert-groups">
<xsl:param name="property"/>
<xsl:for-each select="//adl:group">
@ -1615,6 +1618,12 @@
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$perm='all'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="$perm='edit'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="$perm='insert'">
<xsl:copy-of select="."/>
</xsl:when>
@ -1626,7 +1635,7 @@
</xsl:for-each>
</xsl:template>
<!-- those groups which can read but not insert -->
<!-- those groups which can read -->
<xsl:template name="collect-read-groups">
<xsl:param name="property"/>
<xsl:for-each select="//adl:group">
@ -1637,6 +1646,15 @@
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$perm='all'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="$perm='edit'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="$perm='insert'">
<xsl:copy-of select="."/>
</xsl:when>
<xsl:when test="$perm='noedit'">
<xsl:copy-of select="."/>
</xsl:when>