Author: husted
Date: Fri Jun 24 18:42:57 2005
New Revision: 201704

URL: http://svn.apache.org/viewcvs?rev=201704&view=rev
Log:
OVR-5
* Add authentification support and editor field to data grid.

Added:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs
Modified:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Web.config

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppContext.cs Fri Jun 24 
18:42:57 2005
@@ -91,5 +91,10 @@
                        set { Set (App.HOURS, value); }
                }
 
+               public string editor
+               {
+                       get { return Get (App.EDITOR); }
+                       set { Set (App.EDITOR, value); }
+               }
        }
 }

Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs?rev=201704&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs (added)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/AppUserProfile.cs Fri Jun 24 
18:42:57 2005
@@ -0,0 +1,28 @@
+using System.Security.Principal;
+using Nexus.Core.Profile;
+
+namespace PhoneBook.Core
+{
+       /// <summary>
+       /// Extend UserProfile to include an IsEditor property.
+       /// </summary>
+       public class AppUserProfile : UserProfile
+       {
+               private bool _IsEditor = false;
+               public bool IsEditor
+               {
+                       get { return _IsEditor; }
+                       set { _IsEditor = value; }
+               }
+
+               /// <summary>
+               /// Instantiate from an IIdentity.
+               /// </summary>
+               /// <param name="id">Identity to copy for this profile.</param>
+               public AppUserProfile (IIdentity id)
+               {
+                       Principal = new UserPrincipal (id);
+               }
+
+       }
+}
\ No newline at end of file

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj Fri Jun 24 
18:42:57 2005
@@ -119,6 +119,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "AppUserProfile.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "AssemblyInfo.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx Fri Jun 
24 18:42:57 2005
@@ -12,6 +12,7 @@
        <body>
                <h1>PhoneBook Directory</h1>
                        <form id="frmDirectory" method="post" runat="server">
+                       <p>Welcome, <asp:Label ID="lblUser" 
Runat="server"></asp:Label></p>
                        
                        <!-- ERROR -->
                        <asp:Panel ID="pnlError" Runat="server">

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs Fri 
Jun 24 18:42:57 2005
@@ -1,7 +1,10 @@
 using System;
+using System.Security.Principal;
 using System.Web.UI.WebControls;
 using Nexus.Core.Helpers;
+using Nexus.Core.Profile;
 using Nexus.Web;
+using PhoneBook.Core;
 
 namespace PhoneBook.Web.Forms
 {
@@ -18,11 +21,63 @@
 
                #endregion
 
+               #region Helpers 
+
+               private IViewHelper _UserHelper;
+               /// <summary>
+               /// Obtain entry for a user.
+               /// </summary>
+               ///
+               public virtual IViewHelper UserHelper
+               {
+                       get { return _UserHelper; }
+                       set { _UserHelper = value; }
+               }
+
+               #endregion
+
                #region Page Properties 
 
+               protected Label lblUser;
+
                protected Panel pnlError;
                protected Label lblError;
 
+               private AppUserProfile _Profile;
+               protected AppUserProfile Profile
+               {
+                       set
+                       {
+                               if (value==null) 
+                                       _Profile = NewProfile();
+                               else 
+                                       _Profile = value;
+
+                       }
+                       get
+                       {
+                               return _Profile;
+                       }
+               }
+
+               protected AppUserProfile NewProfile()   {
+                       
+                       WindowsIdentity id = WindowsIdentity.GetCurrent ();
+                       AppUserProfile profile = new AppUserProfile (id);
+                       Session [UserProfile.USER_PROFILE] = profile;
+
+                       UserHelper.Criteria[App.USER_NAME] = profile.UserId;
+                       UserHelper.Execute();
+                       if (UserHelper.IsNominal)
+                       {
+                               string editor = UserHelper.Criteria[App.EDITOR] 
as string;
+                               bool isEditor = ((editor!=null) && 
(editor=="1"));
+                               profile.IsEditor = isEditor;                    
        
+                       }
+
+                       return profile;
+               }
+
                /// <summary>
                /// Display a list of error mesasges.
                /// </summary>
@@ -131,8 +186,12 @@
                        base.Page_Init ();
                        pnlList.Visible = true;
                        pnlError.Visible = false;
-                       if (!IsPostBack)
+                       if (!IsPostBack) 
+                       {
                                Page_Prompt = msg_FILTER;
+                               Profile = Session [UserProfile.USER_PROFILE] as 
AppUserProfile;
+                               lblUser.Text = Profile.UserId;
+                       }
                }
 
                #endregion

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config Fri Jun 24 
18:42:57 2005
@@ -22,6 +22,7 @@
               
                <object id="Directory2" type="Directory2.aspx">
                        <property name="GridHelper"><ref 
object="directory_grid_helper"/></property>
+                       <property name="UserHelper"><ref 
object="directory_list_helper"/></property>
                </object>
 
    </objects>

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml 
(original)
+++ 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml 
Fri Jun 24 18:42:57 2005
@@ -63,6 +63,10 @@
                <property name="Label"><value>Hours</value></property>  
        </object>
        
+       <object id="editor" parent="BaseFieldContext">
+               <property name="ID"><value>editor</value></property>    
+               <property name="Label"><value>Editor?</value></property>        
+       </object>
 
        <!-- We need to "hash" the name with "_" to avoid conflict with the 
filter Command -->
        <object id="_filter" parent="BaseFieldContext">

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml 
Fri Jun 24 18:42:57 2005
@@ -16,6 +16,7 @@
                                <value>user_name</value>
                                <value>hired</value>
                                <value>hours</value>
+                               <value>editor</value>
                        </list>
                </property>
                <property name="ID"><value>filter</value></property>
@@ -119,6 +120,7 @@
                                <ref object="user_name"/>
                                <ref object="hired"/> 
                                <ref object="hours"/>
+                               <ref object="editor"/>
                        </list>
                </property>
        </object>  
@@ -155,8 +157,9 @@
                                <value>user_name</value>
                                <value>hours</value>
                                <value>hired</value>
+                               <value>editor</value>
                        </list>
                </property>
        </object>
-  
+         
 </objects>

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml 
Fri Jun 24 18:42:57 2005
@@ -14,6 +14,7 @@
                        <parameter property="user_name"/>
                        <parameter property="hired"/>
                        <parameter property="hours"/>
+                       <parameter property="editor"/>
                      <parameter property="entry_key"/>             
         </parameterMap>                  
       
@@ -28,6 +29,7 @@
                                user_name,
                                hired,
                                hours,
+                               editor,
                                pk_entry AS entry_key                           
                        FROM entry
                        <dynamic prepend="WHERE">                       
@@ -49,6 +51,9 @@
                                <isNotNull property="hours" prepend="AND">
                                        hours=#hours#
                                </isNotNull>
+                               <isNotNull property="editor" prepend="AND">
+                                       hours=#editor#
+                               </isNotNull>
                                <isNotNull property="entry_key" prepend="AND">
                                        pk_entry=#entry_key#
                                </isNotNull>
@@ -63,9 +68,10 @@
                                user_name,
                                hired,
                                hours,
+                               editor
                                pk_entry
                                )
-                       VALUES (?,?,?,?, ?,?,?)
+                       VALUES (?,?,?,?, ?,?,?,?)
                </insert>               
 
                <update id="entry_update" parameterMap="entry_save_param">
@@ -75,7 +81,8 @@
                                extension=?,
                                user_name=?,
                                hired=?,
-                               hours=?
+                               hours=?,
+                               editor=?
                        WHERE 
                                pk_entry=?
                </update>

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Web.config
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Web.config?rev=201704&r1=201703&r2=201704&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Web.config (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Web.config Fri Jun 24 18:42:57 
2005
@@ -67,6 +67,7 @@
            by Microsoft that offers a single logon and core profile services 
for member sites.
     -->
     <authentication mode="Windows" /> 
+    <identity impersonate="true" />
 
        <!--  AUTHORIZATION 
           This section sets the authorization policies of the application. You 
can allow or deny access



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to