Merge security.ui bundle in the cms.ui.workbench bundle
authorBruno Sinou <bsinou@argeo.org>
Wed, 14 Sep 2016 15:49:52 +0000 (15:49 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 14 Sep 2016 15:49:52 +0000 (15:49 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@9140 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

64 files changed:
org.argeo.cms.ui.workbench/META-INF/spring/keyring.xml [new file with mode: 0644]
org.argeo.cms.ui.workbench/META-INF/spring/osgi.xml
org.argeo.cms.ui.workbench/META-INF/spring/views.xml [new file with mode: 0644]
org.argeo.cms.ui.workbench/bnd.bnd
org.argeo.cms.ui.workbench/icons/adminLog.gif [new file with mode: 0644]
org.argeo.cms.ui.workbench/icons/home.gif [new file with mode: 0644]
org.argeo.cms.ui.workbench/icons/log.gif [new file with mode: 0644]
org.argeo.cms.ui.workbench/icons/maintenance.gif [new file with mode: 0644]
org.argeo.cms.ui.workbench/icons/password.gif [new file with mode: 0644]
org.argeo.cms.ui.workbench/plugin.xml
org.argeo.cms.ui.workbench/pom.xml
org.argeo.cms.ui.workbench/securityui.properties [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/MaintenancePerspective.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/PrivilegedJob.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/RolesSourceProvider.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/SecurityUiPlugin.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/UserHomePerspective.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/SecurityAdminImages.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/SecurityAdminPlugin.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/DeleteGroups.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/DeleteUsers.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/NewGroup.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/NewUser.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/SaveArgeoUser.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/commands/UserTransactionHandler.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/parts/GroupsView.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/parts/UserEditor.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/parts/UsersView.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/admin/internal/providers/UserTransactionProvider.java
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenHomePerspective.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/AdminLogView.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogContentProvider.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogView.java [new file with mode: 0644]
org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/UserProfile.java [new file with mode: 0644]
org.argeo.security.ui/.classpath [deleted file]
org.argeo.security.ui/.project [deleted file]
org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs [deleted file]
org.argeo.security.ui/META-INF/spring/commands.xml [deleted file]
org.argeo.security.ui/META-INF/spring/keyring.xml [deleted file]
org.argeo.security.ui/META-INF/spring/osgi.xml [deleted file]
org.argeo.security.ui/META-INF/spring/views.xml [deleted file]
org.argeo.security.ui/bnd.bnd [deleted file]
org.argeo.security.ui/build.properties [deleted file]
org.argeo.security.ui/icons/adminLog.gif [deleted file]
org.argeo.security.ui/icons/home.gif [deleted file]
org.argeo.security.ui/icons/log.gif [deleted file]
org.argeo.security.ui/icons/maintenance.gif [deleted file]
org.argeo.security.ui/icons/password.gif [deleted file]
org.argeo.security.ui/icons/user.gif [deleted file]
org.argeo.security.ui/plugin.xml [deleted file]
org.argeo.security.ui/pom.xml [deleted file]
org.argeo.security.ui/securityui.properties [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/MaintenancePerspective.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/PrivilegedJob.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/RolesSourceProvider.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/SecurityUiPlugin.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/UserHomePerspective.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/views/AdminLogView.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/views/LogContentProvider.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/views/LogView.java [deleted file]
org.argeo.security.ui/src/org/argeo/security/ui/views/UserProfile.java [deleted file]

diff --git a/org.argeo.cms.ui.workbench/META-INF/spring/keyring.xml b/org.argeo.cms.ui.workbench/META-INF/spring/keyring.xml
new file mode 100644 (file)
index 0000000..74c4ad6
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
+       xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
+
+       <bean
+               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
+               <property name="locations">
+                       <value>osgibundle:securityui.properties</value>
+               </property>
+       </bean>
+
+       <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession"
+               destroy-method="dispose">
+               <property name="repository" ref="nodeRepository" />
+       </bean>
+
+       <bean id="keyring" class="org.argeo.jcr.security.JcrKeyring">
+               <property name="session" ref="nodeSession" />
+               <property name="defaultCallbackHandler" ref="defaultCallbackHandler" />
+               <property name="secreteKeyLength" value="${argeo.keyring.secreteKeyLength}" />
+       </bean>
+
+</beans>
index 02a63748f8d81c717b4b0462c54c9aabdee6593b..e884f7838d32010b13b11c6c23e2936f3a6bade9 100644 (file)
@@ -8,10 +8,24 @@
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
        osgi:default-timeout="30000">\r
 \r
+<!--   <reference id="nodeRepository" interface="javax.jcr.Repository" -->\r
+<!--           filter="(argeo.jcr.repository.alias=node)" /> -->\r
+\r
        <reference id="nodeRepository" interface="javax.jcr.Repository"\r
-               filter="(argeo.jcr.repository.alias=node)" />\r
+               filter="(argeo.jcr.repository.alias=home)" />\r
+\r
                \r
        <!-- New user admin -->\r
        <reference id="userAdmin" interface="org.osgi.service.useradmin.UserAdmin" />\r
        <reference id="userTransaction" interface="javax.transaction.UserTransaction" />\r
+       \r
+       <reference id="secureLogger" interface="org.argeo.node.ArgeoLogger"\r
+               cardinality="0..1" />\r
+\r
+\r
+       <reference id="defaultCallbackHandler" interface="javax.security.auth.callback.CallbackHandler" />\r
+\r
+       <!-- SERVICES -->\r
+       <service interface="org.argeo.util.security.CryptoKeyring"\r
+               ref="keyring" />\r
 </beans:beans>
\ No newline at end of file
diff --git a/org.argeo.cms.ui.workbench/META-INF/spring/views.xml b/org.argeo.cms.ui.workbench/META-INF/spring/views.xml
new file mode 100644 (file)
index 0000000..e5363dc
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+       <bean id="logView" class="org.argeo.security.ui.views.LogView"
+               scope="prototype">
+               <property name="argeoLogger" ref="secureLogger" />
+       </bean>
+
+       <bean id="adminLogView" class="org.argeo.security.ui.views.AdminLogView"
+               scope="prototype">
+               <property name="argeoLogger" ref="secureLogger" />
+       </bean>
+
+</beans>
index 4ace8db0e2115f7ab5e16591c3abf5dcb5a5d378..2a5b6bf675e00b5e31232186e67ac0ca75d190e8 100644 (file)
@@ -1,12 +1,12 @@
 Bundle-SymbolicName: org.argeo.cms.ui.workbench;singleton:=true
-Bundle-Activator: org.argeo.security.ui.admin.SecurityAdminPlugin
+Bundle-Activator: org.argeo.security.ui.SecurityUiPlugin
 Bundle-ActivationPolicy: lazy
 
 Require-Bundle:        org.eclipse.core.runtime
 
-Import-Package:        org.eclipse.core.runtime.jobs,\
-org.argeo.cms.auth,\
+Import-Package:        org.argeo.cms.auth,\
 org.argeo.eclipse.spring,\
+org.eclipse.core.runtime.jobs,\
 org.eclipse.jface.window,\
 org.eclipse.swt,\
 org.eclipse.swt.widgets,\
@@ -14,3 +14,6 @@ org.eclipse.ui.services,\
 org.osgi.framework,\
 org.springframework.core,\
 *                              
+
+
+# org.argeo.eclipse.ui.workbench;resolution:=optional,\
diff --git a/org.argeo.cms.ui.workbench/icons/adminLog.gif b/org.argeo.cms.ui.workbench/icons/adminLog.gif
new file mode 100644 (file)
index 0000000..6ef3bca
Binary files /dev/null and b/org.argeo.cms.ui.workbench/icons/adminLog.gif differ
diff --git a/org.argeo.cms.ui.workbench/icons/home.gif b/org.argeo.cms.ui.workbench/icons/home.gif
new file mode 100644 (file)
index 0000000..fd0c669
Binary files /dev/null and b/org.argeo.cms.ui.workbench/icons/home.gif differ
diff --git a/org.argeo.cms.ui.workbench/icons/log.gif b/org.argeo.cms.ui.workbench/icons/log.gif
new file mode 100644 (file)
index 0000000..e3ecc55
Binary files /dev/null and b/org.argeo.cms.ui.workbench/icons/log.gif differ
diff --git a/org.argeo.cms.ui.workbench/icons/maintenance.gif b/org.argeo.cms.ui.workbench/icons/maintenance.gif
new file mode 100644 (file)
index 0000000..e5690ec
Binary files /dev/null and b/org.argeo.cms.ui.workbench/icons/maintenance.gif differ
diff --git a/org.argeo.cms.ui.workbench/icons/password.gif b/org.argeo.cms.ui.workbench/icons/password.gif
new file mode 100644 (file)
index 0000000..a6b251f
Binary files /dev/null and b/org.argeo.cms.ui.workbench/icons/password.gif differ
index 2cf0ba210191824bea9c1854a47d791327b15bbf..2636818eb29c413c05bb1ed9bf6acb00d1df6a51 100644 (file)
@@ -6,28 +6,65 @@
       <perspective
             class="org.argeo.security.ui.admin.SecurityAdminPerspective"
             icon="icons/security.gif"
-            id="org.argeo.security.ui.admin.adminSecurityPerspective"
+            id="org.argeo.cms.ui.workbench.adminSecurityPerspective"
             name="Security">
       </perspective>
+      <perspective
+            class="org.argeo.security.ui.UserHomePerspective"
+            icon="icons/home.gif"
+            id="org.argeo.cms.ui.workbench.userHomePerspective"
+            name="Home">
+      </perspective>
+      <perspective
+            class="org.argeo.security.ui.MaintenancePerspective"
+            icon="icons/maintenance.gif"
+            id="org.argeo.cms.ui.workbench.adminMaintenancePerspective"
+            name="Maintenance">
+      </perspective>
    </extension>
    
    <!-- VIEWS -->
    <extension
                point="org.eclipse.ui.views">
+      <!-- Security -->
       <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             icon="icons/users.gif"
-            id="org.argeo.security.ui.admin.usersView"
+            id="org.argeo.cms.ui.workbench.usersView"
             name="Users"
             restorable="true">
       </view>
       <view
             class="org.argeo.eclipse.spring.SpringExtensionFactory"
             icon="icons/role.gif"
-            id="org.argeo.security.ui.admin.groupsView"
+            id="org.argeo.cms.ui.workbench.groupsView"
             name="Groups"
             restorable="false">
       </view>
+      <!-- Home -->
+      <view
+            id="org.argeo.cms.ui.workbench.userProfile"
+            class="org.argeo.security.ui.views.UserProfile"
+            icon="icons/user.gif"
+            name="Profile"
+            restorable="true">
+      </view>
+      <!-- Maintenance -->
+      <view
+            id="org.argeo.cms.ui.workbench.logView"
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            name="Log"
+            icon="icons/log.gif"
+            restorable="true">
+      </view>
+      <view
+            id="org.argeo.cms.ui.workbench.adminLogView"
+            class="org.argeo.eclipse.spring.SpringExtensionFactory"
+            name="Admin Log"
+            icon="icons/adminLog.gif"
+            restorable="true">
+      </view>
+      
     </extension> 
        
        <!-- EDITORS -->
                point="org.eclipse.ui.editors">
                <editor
                        class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.security.ui.admin.userEditor"
+            id="org.argeo.cms.ui.workbench.userEditor"
             name="User"
             icon="icons/user.gif"
             default="false">
                </editor>
                <editor
                        class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            id="org.argeo.security.ui.admin.groupEditor"
+            id="org.argeo.cms.ui.workbench.groupEditor"
             name="User"
             icon="icons/users.gif"
             default="false">
          point="org.eclipse.ui.commands">
                <!-- User CRUD -->
                <command
-            id="org.argeo.security.ui.admin.newUser"
+            id="org.argeo.cms.ui.workbench.newUser"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="New User">
        </command>
                <command
-                       id="org.argeo.security.ui.admin.deleteUsers"
+                       id="org.argeo.cms.ui.workbench.deleteUsers"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                        name="Delete User">
                </command>
                <command
                        defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
-            id="org.argeo.security.ui.admin.userBatchUpdate"
+            id="org.argeo.cms.ui.workbench.userBatchUpdate"
             name="User batch update">
                </command>
                <!-- Group CRUD -->
                <command
-                       id="org.argeo.security.ui.admin.newGroup"
+                       id="org.argeo.cms.ui.workbench.newGroup"
                        defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="New Group">
                </command>
                <command
-            id="org.argeo.security.ui.admin.deleteGroups"
+            id="org.argeo.cms.ui.workbench.deleteGroups"
                        defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
             name="Delete Group">
                </command>
                <!-- Transaction -->
                <command
-                   id="org.argeo.security.ui.admin.userTransactionHandler"
+                   id="org.argeo.cms.ui.workbench.userTransactionHandler"
             defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
                name="Manage a user transaction">
                        <commandParameter
          <!-- Force the refresh when the various listener are not enough -->
       <command
             defaultHandler="org.argeo.security.ui.admin.internal.commands.ForceRefresh"
-            id="org.argeo.security.ui.admin.forceRefresh"
+            id="org.argeo.cms.ui.workbench.forceRefresh"
             name="Force Refresh">
       </command>
        </extension>
        <extension
                point="org.eclipse.ui.menus">
                <menuContribution
-                       locationURI="toolbar:org.argeo.security.ui.rap.userToolbar?after=org.eclipse.ui.file.saveAll"> 
+                       locationURI="toolbar:org.argeo.cms.ui.workbench.rap.userToolbar?after=org.eclipse.ui.file.saveAll"> 
                        <!-- Transaction management --> 
                        <command
-                               commandId="org.argeo.security.ui.admin.userTransactionHandler"
+                               commandId="org.argeo.cms.ui.workbench.userTransactionHandler"
                                icon="icons/commit.gif"
                                label="Commit Transaction"
                                style="push"
                                tooltip="Commit a user transaction">
                                <parameter name="param.commandId" value="transaction.commit" />
                                <visibleWhen>
-                                       <with variable="org.argeo.security.ui.admin.userTransactionState">
+                                       <with variable="org.argeo.cms.ui.workbench.userTransactionState">
                                                <equals value="status.active" />
                                        </with>
                                </visibleWhen>
                        </command>
                        <command
-                               commandId="org.argeo.security.ui.admin.userTransactionHandler"
+                               commandId="org.argeo.cms.ui.workbench.userTransactionHandler"
                                icon="icons/rollback.gif"
                                label="Rollback Transaction"
                                style="push"
                                tooltip="Abandon current changes and rollback to the latest commited version">
                                <parameter name="param.commandId" value="transaction.rollback" />
                                <visibleWhen>
-                                       <with variable="org.argeo.security.ui.admin.userTransactionState">
+                                       <with variable="org.argeo.cms.ui.workbench.userTransactionState">
                                                        <equals value="status.active" />
                                        </with>
                                </visibleWhen>
     
        <!-- UsersView specific toolbar menu -->
                <menuContribution
-            locationURI="toolbar:org.argeo.security.ui.admin.usersView">
+            locationURI="toolbar:org.argeo.cms.ui.workbench.usersView">
             <command
-                  commandId="org.argeo.security.ui.admin.deleteUsers"
+                  commandId="org.argeo.cms.ui.workbench.deleteUsers"
                   icon="icons/remove.gif"
                   label="Delete User"
                   tooltip="Delete selected users">
             </command>
             <command
-                  commandId="org.argeo.security.ui.admin.forceRefresh"
+                  commandId="org.argeo.cms.ui.workbench.forceRefresh"
                   icon="icons/refresh.png"
                   label="Refresh list"
                   tooltip="Force the full refresh of the user list">
             </command>
             <command
-                  commandId="org.argeo.security.ui.admin.newUser"
+                  commandId="org.argeo.cms.ui.workbench.newUser"
                   icon="icons/add.gif"
                   label="Add User"
                   tooltip="Create a new user">
             </command>
             <command
-                  commandId="org.argeo.security.ui.admin.userBatchUpdate"
+                  commandId="org.argeo.cms.ui.workbench.userBatchUpdate"
                   icon="icons/batch.gif"
                   label="Update users"
                   tooltip="Perform maintenance activities on a list of chosen users">
 
        <!-- GroupsView specific toolbar menu -->
         <menuContribution
-            locationURI="toolbar:org.argeo.security.ui.admin.groupsView">
+            locationURI="toolbar:org.argeo.cms.ui.workbench.groupsView">
             <command
-                  commandId="org.argeo.security.ui.admin.deleteGroups"
+                  commandId="org.argeo.cms.ui.workbench.deleteGroups"
                   icon="icons/remove.gif"
                   label="Delete Group"
                   tooltip="Delete selected groups">
             </command>
             <command
-                  commandId="org.argeo.security.ui.admin.forceRefresh"
+                  commandId="org.argeo.cms.ui.workbench.forceRefresh"
                   icon="icons/refresh.png"
                   label="Refresh list"
                   tooltip="Force the full refresh of the group list">
             </command>
             <command
-                  commandId="org.argeo.security.ui.admin.newGroup"
+                  commandId="org.argeo.cms.ui.workbench.newGroup"
                   icon="icons/add.gif"
                   label="Add Group"
                   tooltip="Create a new group">
         </menuContribution>
          
                <!--            <menuContribution
-            locationURI="toolbar:org.argeo.security.ui.admin.adminRolesView">
+            locationURI="toolbar:org.argeo.cms.ui.workbench.admin.adminRolesView">
             <command
-                  commandId="org.argeo.security.ui.admin.refreshRoles"
+                  commandId="org.argeo.cms.ui.workbench.admin.refreshRoles"
                   icon="icons/sync.gif"
                   label="LDAP Roles Sync"
                   tooltip="Synchronize roles from LDAP">
        <!-- SERVICES -->
        <extension
        point="org.eclipse.ui.services">
-        <sourceProvider
-               id="org.argeo.security.ui.admin.userTransactionProvider"
+               <sourceProvider
+               id="org.argeo.cms.ui.workbench.userTransactionProvider"
             provider="org.argeo.eclipse.spring.SpringExtensionFactory" >
                        <variable
-                   name="org.argeo.security.ui.admin.userTransactionState"
+                   name="org.argeo.cms.ui.workbench.userTransactionState"
                    priorityLevel="workbench">
                </variable>
                </sourceProvider>
+               <sourceProvider
+              provider="org.argeo.cms.ui.workbench.RolesSourceProvider">
+           <variable
+                 name="org.argeo.cms.ui.workbench.rolesVariable"
+                 priorityLevel="workbench">
+           </variable>
+        </sourceProvider>
        </extension>
   
        <!-- ACTIVITIES -->
                point="org.eclipse.ui.activities">
                <!-- group admin is intended to make all user and group maintenance operations -->
                <!--<activityPatternBinding
-                       activityId="org.argeo.security.ui.userAdminActivity"
+                       activityId="org.argeo.cms.ui.workbench.userAdminActivity"
                        isEqualityPattern="true"
-                       pattern="org.argeo.security.ui.admin/org.argeo.security.ui.admin.adminSecurityPerspective">
+                       pattern="org.argeo.cms.ui.workbench.admin/org.argeo.cms.ui.workbench.admin.adminSecurityPerspective">
                </activityPatternBinding>-->
                <activityPatternBinding
-                       activityId="org.argeo.security.ui.groupAdminActivity"
+                       activityId="org.argeo.cms.ui.workbench.groupAdminActivity"
                        isEqualityPattern="true"
-                       pattern="org.argeo.security.ui.admin/org.argeo.security.ui.admin.adminSecurityPerspective">
+                       pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminSecurityPerspective">
                </activityPatternBinding>
+               
+                       <activity
+              description="Authenticated users"
+              id="org.argeo.cms.ui.workbench.userActivity"
+              name="User">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=user,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <activity
+              description="Admins"
+              id="org.argeo.cms.ui.workbench.adminActivity"
+              name="Admin">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=admin,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <activity
+              description="User Admins"
+              id="org.argeo.cms.ui.workbench.userAdminActivity"
+              name="User Admin">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=userAdmin,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <activity
+              description="Group Admins"
+              id="org.argeo.cms.ui.workbench.groupAdminActivity"
+              name="User Admin">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=groupAdmin,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <activity
+              description="Non admins"
+              id="org.argeo.cms.ui.workbench.notAdminActivity"
+              name="Not Admin">
+                 <enabledWhen>
+                       <not>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="cn=admin,ou=roles,ou=node" />
+                     </iterate>
+                   </with>
+                       </not>
+                 </enabledWhen>
+        </activity>
+        <activity
+              description="Non remote"
+              id="org.argeo.cms.ui.workbench.notRemoteActivity"
+              name="NonRemote">
+                 <enabledWhen>
+                       <not>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="ROLE_REMOTE" />
+                     </iterate>
+                   </with>
+                       </not>
+                 </enabledWhen>
+        </activity>
+        <activityPatternBinding
+              activityId="org.argeo.cms.ui.workbench.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminMaintenancePerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.cms.ui.workbench.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.adminLogView">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.cms.ui.workbench.userActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.userHomePerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.cms.ui.workbench.userActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.cms.ui.workbench/org.argeo.cms.ui.workbench.userProfile">
+        </activityPatternBinding>
+               
        </extension>
        
        <!-- STARTUP  --> 
index ead8e2e8480d9190e449bee2cbfd31553ff90895..2dccd6a3f6437510862e4460540abcf7d54beb14 100644 (file)
                        <artifactId>org.argeo.cms</artifactId>
                        <version>2.1.46-SNAPSHOT</version>
                </dependency>
-               <dependency>
+                               <dependency>
                        <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.util</artifactId>
+                       <artifactId>org.argeo.eclipse.ui.workbench</artifactId>
                        <version>2.1.46-SNAPSHOT</version>
                </dependency>
                <dependency>
                        <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.security.ui</artifactId>
+                       <artifactId>org.argeo.util</artifactId>
                        <version>2.1.46-SNAPSHOT</version>
                </dependency>
+<!--           <dependency> -->
+<!--                   <groupId>org.argeo.commons</groupId> -->
+<!--                   <artifactId>org.argeo.security.ui</artifactId> -->
+<!--                   <version>2.1.46-SNAPSHOT</version> -->
+<!--           </dependency> -->
                <dependency>
                        <groupId>org.argeo.commons</groupId>
                        <artifactId>org.argeo.enterprise</artifactId>
diff --git a/org.argeo.cms.ui.workbench/securityui.properties b/org.argeo.cms.ui.workbench/securityui.properties
new file mode 100644 (file)
index 0000000..0228d47
--- /dev/null
@@ -0,0 +1 @@
+argeo.keyring.secreteKeyLength=256
\ No newline at end of file
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/MaintenancePerspective.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/MaintenancePerspective.java
new file mode 100644 (file)
index 0000000..86307ab
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui;
+
+import org.argeo.security.ui.views.AdminLogView;
+import org.argeo.security.ui.views.UserProfile;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Home perspective for the current user */
+public class MaintenancePerspective implements IPerspectiveFactory {
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID
+                       + ".adminMaintenancePerspective";
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               layout.setEditorAreaVisible(true);
+               layout.setFixed(false);
+
+               IFolderLayout bottom = layout.createFolder("bottom",
+                               IPageLayout.BOTTOM, 0.50f, editorArea);
+               bottom.addView(AdminLogView.ID);
+
+               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
+                               0.30f, editorArea);
+               left.addView(UserProfile.ID);
+               // left.addView(RolesView.ID);
+
+       }
+
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/PrivilegedJob.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/PrivilegedJob.java
new file mode 100644 (file)
index 0000000..3a9ade4
--- /dev/null
@@ -0,0 +1,49 @@
+package org.argeo.security.ui;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.Job;
+
+/**
+ * Propagate authentication to an eclipse job. Typically to execute a privileged
+ * action outside the UI thread
+ */
+public abstract class PrivilegedJob extends Job {
+       private final Subject subject;
+
+       public PrivilegedJob(String jobName) {
+               this(jobName, AccessController.getContext());
+       }
+
+       public PrivilegedJob(String jobName,
+                       AccessControlContext accessControlContext) {
+               super(jobName);
+               subject = Subject.getSubject(accessControlContext);
+
+               // Must be called *before* the job is scheduled,
+               // it is required for the progress window to appear
+               setUser(true);
+       }
+
+       @Override
+       protected IStatus run(final IProgressMonitor progressMonitor) {
+               PrivilegedAction<IStatus> privilegedAction = new PrivilegedAction<IStatus>() {
+                       public IStatus run() {
+                               return doRun(progressMonitor);
+                       }
+               };
+               return Subject.doAs(subject, privilegedAction);
+       }
+
+       /**
+        * Implement here what should be executed with default context
+        * authentication
+        */
+       protected abstract IStatus doRun(IProgressMonitor progressMonitor);
+}
\ No newline at end of file
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/RolesSourceProvider.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/RolesSourceProvider.java
new file mode 100644 (file)
index 0000000..42e6f10
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.argeo.cms.auth.CurrentUser;
+import org.eclipse.ui.AbstractSourceProvider;
+
+/**
+ * Provides the roles of the current user as a variable to be used for activity
+ * binding
+ */
+public class RolesSourceProvider extends AbstractSourceProvider {
+       public final static String ROLES_VARIABLE = "roles";
+       private final static String[] PROVIDED_SOURCE_NAMES = new String[] { ROLES_VARIABLE };
+
+       public Map<String, Set<String>> getCurrentState() {
+               Map<String, Set<String>> stateMap = new HashMap<String, Set<String>>();
+               stateMap.put(ROLES_VARIABLE, CurrentUser.roles());
+               return stateMap;
+       }
+
+       public String[] getProvidedSourceNames() {
+               return PROVIDED_SOURCE_NAMES;
+       }
+
+       public void updateRoles() {
+               fireSourceChanged(0, getCurrentState());
+       }
+
+       public void dispose() {
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/SecurityUiPlugin.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/SecurityUiPlugin.java
new file mode 100644 (file)
index 0000000..617fcec
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.argeo.cms.CmsException;
+import org.argeo.cms.widgets.auth.DefaultLoginDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SecurityUiPlugin extends AbstractUIPlugin {
+       private static BundleContext bundleContext;
+       public static InheritableThreadLocal<Display> display = new InheritableThreadLocal<Display>() {
+
+               @Override
+               protected Display initialValue() {
+                       return Display.getCurrent();
+               }
+       };
+
+       // The plug-in ID
+       //      public final static String PLUGIN_ID = "org.argeo.security.ui"; //$NON-NLS-1$
+       public final static String PLUGIN_ID = "org.argeo.cms.ui.workbench"; //$NON-NLS-1$
+
+       final static String CONTEXT_KEYRING = "KEYRING";
+
+       private CallbackHandler defaultCallbackHandler;
+       private ServiceRegistration<CallbackHandler> defaultCallbackHandlerReg;
+
+       public void start(BundleContext context) throws Exception {
+               bundleContext = context;
+
+               defaultCallbackHandler = new DefaultCallbackHandler();
+               defaultCallbackHandlerReg = context.registerService(
+                               CallbackHandler.class, defaultCallbackHandler, null);
+       }
+
+       public void stop(BundleContext context) throws Exception {
+               bundleContext = null;
+               defaultCallbackHandlerReg.unregister();
+       }
+
+       public static BundleContext getBundleContext() {
+               return bundleContext;
+       }
+
+       protected class DefaultCallbackHandler implements CallbackHandler {
+               public void handle(final Callback[] callbacks) throws IOException,
+                               UnsupportedCallbackException {
+
+                       // if (display != null) // RCP
+                       Display displayToUse = display.get();
+                       if (displayToUse == null)// RCP
+                               displayToUse = Display.getDefault();
+                       displayToUse.syncExec(new Runnable() {
+                               public void run() {
+                                       DefaultLoginDialog dialog = new DefaultLoginDialog(display
+                                                       .get().getActiveShell());
+                                       try {
+                                               dialog.handle(callbacks);
+                                       } catch (IOException e) {
+                                               throw new CmsException("Cannot open dialog", e);
+                                       }
+                               }
+                       });
+                       // else {// RAP
+                       // DefaultLoginDialog dialog = new DefaultLoginDialog();
+                       // dialog.handle(callbacks);
+                       // }
+               }
+
+       }
+
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return imageDescriptorFromPlugin(PLUGIN_ID, path);
+       }
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/UserHomePerspective.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/UserHomePerspective.java
new file mode 100644 (file)
index 0000000..119549f
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui;
+
+import org.argeo.security.ui.views.LogView;
+import org.argeo.security.ui.views.UserProfile;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** Home perspective for the current user */
+public class UserHomePerspective implements IPerspectiveFactory {
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID
+                       + ".userHomePerspective";
+
+       public void createInitialLayout(IPageLayout layout) {
+               String editorArea = layout.getEditorArea();
+               layout.setEditorAreaVisible(true);
+               layout.setFixed(false);
+
+               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
+                               0.30f, editorArea);
+               left.addView(UserProfile.ID);
+               left.addView(LogView.ID);
+       }
+
+}
index f15f8ec9a624ee8c0591a142515218d60eeb9c0b..6cccb08a840b7a395cb58cf09b360df8aeb59fb6 100644 (file)
@@ -26,6 +26,7 @@
  */
 package org.argeo.security.ui.admin;
 
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.swt.graphics.Image;
 
@@ -33,15 +34,15 @@ import org.eclipse.swt.graphics.Image;
 public class SecurityAdminImages {
        private final static String PREFIX = "icons/";
 
-       public final static ImageDescriptor ICON_REMOVE_DESC = SecurityAdminPlugin
+       public final static ImageDescriptor ICON_REMOVE_DESC = SecurityUiPlugin
                        .getImageDescriptor(PREFIX + "remove.gif");
-       public final static ImageDescriptor ICON_USER_DESC = SecurityAdminPlugin
+       public final static ImageDescriptor ICON_USER_DESC = SecurityUiPlugin
                        .getImageDescriptor(PREFIX + "user.gif");
-       
+
        public final static Image ICON_USER = ICON_USER_DESC.createImage();
-       public final static Image ICON_GROUP = SecurityAdminPlugin
-                       .getImageDescriptor(PREFIX + "users.gif").createImage();
-       public final static Image ICON_ROLE = SecurityAdminPlugin
-                       .getImageDescriptor(PREFIX + "role.gif").createImage();
+       public final static Image ICON_GROUP = SecurityUiPlugin.getImageDescriptor(
+                       PREFIX + "users.gif").createImage();
+       public final static Image ICON_ROLE = SecurityUiPlugin.getImageDescriptor(
+                       PREFIX + "role.gif").createImage();
 
 }
index f9c0ad9afef3da9cce2af73fafd1c259346b4691..7222f92342794dda09ac1c6fa0277e0b67972227 100644 (file)
  */
 package org.argeo.security.ui.admin;
 
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-public class SecurityAdminPlugin extends AbstractUIPlugin {
-       public static final String PLUGIN_ID = "org.argeo.security.ui.admin"; //$NON-NLS-1$
-       private static SecurityAdminPlugin plugin;
-       private static BundleContext bundleContext;
-
-       public SecurityAdminPlugin() {
-       }
-
-       public void start(BundleContext context) throws Exception {
-               super.start(context);
-               plugin = this;
-               bundleContext = context;
-       }
-
-       public void stop(BundleContext context) throws Exception {
-               plugin = null;
-               bundleContext = null;
-               super.stop(context);
-       }
-
-       public static SecurityAdminPlugin getDefault() {
-               return plugin;
-       }
-
-       public static BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-       public static ImageDescriptor getImageDescriptor(String path) {
-               return imageDescriptorFromPlugin(PLUGIN_ID, path);
-       }
-
-}
+public class SecurityAdminPlugin{}
+
+// public class SecurityAdminPlugin extends AbstractUIPlugin {
+//     public static final String PLUGIN_ID = "org.argeo.security.ui.admin"; //$NON-NLS-1$
+// private static SecurityAdminPlugin plugin;
+// private static BundleContext bundleContext;
+//
+// public SecurityAdminPlugin() {
+// }
+//
+// public void start(BundleContext context) throws Exception {
+// super.start(context);
+// plugin = this;
+// bundleContext = context;
+// }
+//
+// public void stop(BundleContext context) throws Exception {
+// plugin = null;
+// bundleContext = null;
+// super.stop(context);
+// }
+//
+// public static SecurityAdminPlugin getDefault() {
+// return plugin;
+// }
+//
+// public static BundleContext getBundleContext() {
+// return bundleContext;
+// }
+//
+// public static ImageDescriptor getImageDescriptor(String path) {
+// return imageDescriptorFromPlugin(PLUGIN_ID, path);
+// }
+//
+// }
index df5d430abd1fad48dee70330d558819dec39c415..5a9b033bb3e6e057f75c23cf059f491d872673e9 100644 (file)
@@ -20,7 +20,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.argeo.cms.util.useradmin.UserAdminUtils;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.argeo.security.ui.admin.internal.parts.UserEditorInput;
 import org.eclipse.core.commands.AbstractHandler;
@@ -38,7 +38,7 @@ import org.osgi.service.useradmin.UserAdminEvent;
 
 /** Delete the selected groups */
 public class DeleteGroups extends AbstractHandler {
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID
                        + ".deleteGroups";
 
        /* DEPENDENCY INJECTION */
index e583bef53bd610b5d99af00ab2266271536760d1..3618be187a38550715bb3b50efe2158b1b9d2414 100644 (file)
@@ -20,7 +20,7 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.argeo.cms.util.useradmin.UserAdminUtils;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.argeo.security.ui.admin.internal.parts.UserEditorInput;
 import org.eclipse.core.commands.AbstractHandler;
@@ -38,8 +38,7 @@ import org.osgi.service.useradmin.UserAdminEvent;
 
 /** Delete the selected users */
 public class DeleteUsers extends AbstractHandler {
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
-                       + ".deleteUsers";
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID + ".deleteUsers";
 
        /* DEPENDENCY INJECTION */
        private UserAdminWrapper userAdminWrapper;
index 75b9b0b33e4e52e06d675014c644d096a42c0d2e..755f05bf328d690e8e0606f12885f64bca505e70 100644 (file)
@@ -24,7 +24,7 @@ import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
 import org.argeo.osgi.useradmin.UserAdminConf;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -48,7 +48,7 @@ import org.osgi.service.useradmin.UserAdminEvent;
 
 /** Create a new group */
 public class NewGroup extends AbstractHandler {
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".newGroup";
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID + ".newGroup";
 
        /* DEPENDENCY INJECTION */
        private UserAdminWrapper userAdminWrapper;
index c04c83562f3cad02fdbbed82a40b5eedf4cd728e..8289d59bf91deaa81906a997a87db5db12d137b9 100644 (file)
@@ -30,7 +30,7 @@ import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
 import org.argeo.osgi.useradmin.UserAdminConf;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
@@ -62,7 +62,7 @@ public class NewUser extends AbstractHandler {
         */
        public final static String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
        // private final static Log log = LogFactory.getLog(NewUser.class);
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".newUser";
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID + ".newUser";
 
        /* DEPENDENCY INJECTION */
        private UserAdminWrapper userAdminWrapper;
index 61d8a7daf3c422166c16a43138f92ee6c97d8a03..c2c78f90c696a7cb6da4e1a0f7561772c9a9d2ef 100644 (file)
@@ -15,7 +15,7 @@
  */
 package org.argeo.security.ui.admin.internal.commands;
 
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
@@ -27,7 +27,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 /** Save the currently edited Argeo user. */
 public class SaveArgeoUser extends AbstractHandler {
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID
                        + ".saveArgeoUser";
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
index 236584ca3fcf16bb0a68403f8d65c764b01bdb64..6f04635af3cbacc74b31eda700f86efec76aa381 100644 (file)
@@ -19,7 +19,7 @@ import javax.transaction.Status;
 import javax.transaction.UserTransaction;
 
 import org.argeo.cms.CmsException;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UiAdminUtils;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.eclipse.core.commands.AbstractHandler;
@@ -29,7 +29,7 @@ import org.osgi.service.useradmin.UserAdminEvent;
 
 /** Manage the transaction that is bound to the current perspective */
 public class UserTransactionHandler extends AbstractHandler {
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID
                        + ".userTransactionHandler";
 
        public final static String PARAM_COMMAND_ID = "param.commandId";
index 82f4e1bdd8f27a0f6f1713f159d85e68910846ed..7225ef865ed1e3b61a024779f8d588d6af47f33b 100644 (file)
@@ -28,7 +28,7 @@ import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.parts.LdifUsersTable;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UiUserAdminListener;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.argeo.security.ui.admin.internal.providers.CommonNameLP;
@@ -58,8 +58,7 @@ import org.osgi.service.useradmin.UserAdminListener;
 /** List all groups with filter */
 public class GroupsView extends ViewPart implements ArgeoNames {
        private final static Log log = LogFactory.getLog(GroupsView.class);
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
-                       + ".groupsView";
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID + ".groupsView";
 
        /* DEPENDENCY INJECTION */
        private UserAdminWrapper userAdminWrapper;
index 6c0731d01d26902bfc01c21df9be724039c6e7a2..d6cae1a1a51f8d8246a434b5dd42b8979d8095c5 100644 (file)
@@ -21,7 +21,7 @@ import java.util.List;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.util.useradmin.UserAdminUtils;
 import org.argeo.osgi.useradmin.LdifName;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UiUserAdminListener;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -44,9 +44,9 @@ import org.osgi.service.useradmin.UserAdminEvent;
 public class UserEditor extends FormEditor {
        private static final long serialVersionUID = 8357851520380820241L;
 
-       public final static String USER_EDITOR_ID = SecurityAdminPlugin.PLUGIN_ID
+       public final static String USER_EDITOR_ID = SecurityUiPlugin.PLUGIN_ID
                        + ".userEditor";
-       public final static String GROUP_EDITOR_ID = SecurityAdminPlugin.PLUGIN_ID
+       public final static String GROUP_EDITOR_ID = SecurityUiPlugin.PLUGIN_ID
                        + ".groupEditor";
 
        /* DEPENDENCY INJECTION */
index a397432a84dce719802b8ca68ea571742e378869..86fb439ff3fd0912598413684c7fe641215748aa 100644 (file)
@@ -26,7 +26,7 @@ import org.argeo.eclipse.ui.EclipseUiUtils;
 import org.argeo.eclipse.ui.parts.LdifUsersTable;
 import org.argeo.jcr.ArgeoNames;
 import org.argeo.osgi.useradmin.LdifName;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.argeo.security.ui.admin.internal.UiUserAdminListener;
 import org.argeo.security.ui.admin.internal.UserAdminWrapper;
 import org.argeo.security.ui.admin.internal.providers.CommonNameLP;
@@ -53,8 +53,7 @@ import org.osgi.service.useradmin.UserAdminListener;
 public class UsersView extends ViewPart implements ArgeoNames {
        // private final static Log log = LogFactory.getLog(UsersView.class);
 
-       public final static String ID = SecurityAdminPlugin.PLUGIN_ID
-                       + ".usersView";
+       public final static String ID = SecurityUiPlugin.PLUGIN_ID + ".usersView";
 
        /* DEPENDENCY INJECTION */
        private UserAdminWrapper userAdminWrapper;
index 4ba304bb5f09082896ad951cf0befe1ce2e7919a..d4a53fcff8abe807769b08a60029ec01cf17cc13 100644 (file)
@@ -9,7 +9,7 @@ import javax.transaction.UserTransaction;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.cms.CmsException;
-import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.SecurityUiPlugin;
 import org.eclipse.ui.AbstractSourceProvider;
 import org.eclipse.ui.ISources;
 
@@ -18,7 +18,7 @@ public class UserTransactionProvider extends AbstractSourceProvider {
        private final static Log log = LogFactory
                        .getLog(UserTransactionProvider.class);
 
-       public final static String TRANSACTION_STATE = SecurityAdminPlugin.PLUGIN_ID
+       public final static String TRANSACTION_STATE = SecurityUiPlugin.PLUGIN_ID
                        + ".userTransactionState";
        public final static String STATUS_ACTIVE = "status.active";
        public final static String STATUS_NO_TRANSACTION = "status.noTransaction";
@@ -28,13 +28,13 @@ public class UserTransactionProvider extends AbstractSourceProvider {
 
        @Override
        public String[] getProvidedSourceNames() {
-               return new String[] { TRANSACTION_STATE};
+               return new String[] { TRANSACTION_STATE };
        }
 
        @Override
        public Map<String, String> getCurrentState() {
                Map<String, String> currentState = new HashMap<String, String>(1);
-                       currentState.put(TRANSACTION_STATE, getInternalCurrentState());
+               currentState.put(TRANSACTION_STATE, getInternalCurrentState());
                return currentState;
        }
 
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java
new file mode 100644 (file)
index 0000000..817354f
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.commands;
+
+import static org.argeo.cms.CmsMsg.changePassword;
+import static org.argeo.cms.CmsMsg.currentPassword;
+import static org.argeo.cms.CmsMsg.newPassword;
+import static org.argeo.cms.CmsMsg.passwordChanged;
+import static org.argeo.cms.CmsMsg.repeatNewPassword;
+import static org.eclipse.jface.dialogs.IMessageProvider.INFORMATION;
+
+import java.security.AccessController;
+
+import javax.naming.InvalidNameException;
+import javax.naming.ldap.LdapName;
+import javax.security.auth.Subject;
+import javax.security.auth.x500.X500Principal;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.cms.CmsException;
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.User;
+import org.osgi.service.useradmin.UserAdmin;
+
+/** Opens the change password dialog. */
+public class OpenChangePasswordDialog extends AbstractHandler {
+       private final static Log log = LogFactory
+                       .getLog(OpenChangePasswordDialog.class);
+       private UserAdmin userAdmin;
+       private UserTransaction userTransaction;
+
+       public Object execute(ExecutionEvent event) throws ExecutionException {
+               ChangePasswordDialog dialog = new ChangePasswordDialog(
+                               HandlerUtil.getActiveShell(event), userAdmin);
+               if (dialog.open() == Dialog.OK) {
+                       MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
+                                       passwordChanged.lead(), passwordChanged.lead());
+               }
+               return null;
+       }
+
+       @SuppressWarnings("unchecked")
+       protected void changePassword(char[] oldPassword, char[] newPassword) {
+               Subject subject = Subject.getSubject(AccessController.getContext());
+               String name = subject.getPrincipals(X500Principal.class).iterator()
+                               .next().toString();
+               LdapName dn;
+               try {
+                       dn = new LdapName(name);
+               } catch (InvalidNameException e) {
+                       throw new CmsException("Invalid user dn " + name, e);
+               }
+               User user = (User) userAdmin.getRole(dn.toString());
+               if (!user.hasCredential(null, oldPassword))
+                       throw new CmsException("Invalid password");
+               if (newPassword.equals(""))
+                       throw new CmsException("New password empty");
+               try {
+                       userTransaction.begin();
+                       user.getCredentials().put(null, newPassword);
+                       userTransaction.commit();
+               } catch (Exception e) {
+                       try {
+                               userTransaction.rollback();
+                       } catch (Exception e1) {
+                               log.error("Could not roll back", e1);
+                       }
+                       if (e instanceof RuntimeException)
+                               throw (RuntimeException) e;
+                       else
+                               throw new CmsException("Cannot change password", e);
+               }
+       }
+
+       public void setUserAdmin(UserAdmin userDetailsManager) {
+               this.userAdmin = userDetailsManager;
+       }
+
+       public void setUserTransaction(UserTransaction userTransaction) {
+               this.userTransaction = userTransaction;
+       }
+
+       class ChangePasswordDialog extends TitleAreaDialog {
+               private static final long serialVersionUID = -6963970583882720962L;
+               private Text oldPassword, newPassword1, newPassword2;
+
+               public ChangePasswordDialog(Shell parentShell, UserAdmin securityService) {
+                       super(parentShell);
+               }
+
+               protected Point getInitialSize() {
+                       return new Point(400, 450);
+               }
+
+               protected Control createDialogArea(Composite parent) {
+                       Composite dialogarea = (Composite) super.createDialogArea(parent);
+                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                       true));
+                       Composite composite = new Composite(dialogarea, SWT.NONE);
+                       composite.setLayout(new GridLayout(2, false));
+                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+                                       false));
+                       oldPassword = createLP(composite, currentPassword.lead());
+                       newPassword1 = createLP(composite, newPassword.lead());
+                       newPassword2 = createLP(composite, repeatNewPassword.lead());
+
+                       setMessage(changePassword.lead(), INFORMATION);
+                       parent.pack();
+                       return composite;
+               }
+
+               @Override
+               protected void okPressed() {
+                       try {
+                               if (!newPassword1.getText().equals(newPassword2.getText()))
+                                       throw new CmsException("New passwords are different");
+                               changePassword(oldPassword.getTextChars(),
+                                               newPassword1.getTextChars());
+                               close();
+                       } catch (Exception e) {
+                               ErrorFeedback.show("Cannot change password", e);
+                       }
+               }
+
+               /** Creates label and password. */
+               protected Text createLP(Composite parent, String label) {
+                       new Label(parent, SWT.NONE).setText(label);
+                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.PASSWORD
+                                       | SWT.BORDER);
+                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+                       return text;
+               }
+
+               protected void configureShell(Shell shell) {
+                       super.configureShell(shell);
+                       shell.setText(changePassword.lead());
+               }
+
+       }
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenHomePerspective.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/commands/OpenHomePerspective.java
new file mode 100644 (file)
index 0000000..f6aa0d1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.commands;
+
+import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
+import org.argeo.security.ui.UserHomePerspective;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.WorkbenchException;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Default action of the user menu */
+public class OpenHomePerspective extends AbstractHandler {
+       
+       public Object execute(ExecutionEvent event) throws ExecutionException {         
+               try {
+                       HandlerUtil.getActiveSite(event).getWorkbenchWindow()
+                                       .openPage(UserHomePerspective.ID, null);
+               } catch (WorkbenchException e) {
+                       ErrorFeedback.show("Cannot open home perspective", e);
+               }
+               return null;
+       }
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/AdminLogView.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/AdminLogView.java
new file mode 100644 (file)
index 0000000..61efc8c
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.views;
+
+import java.util.ArrayList;
+
+import org.argeo.node.ArgeoLogger;
+import org.argeo.security.ui.SecurityUiPlugin;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Display log lines for all users with a virtual table.
+ */
+public class AdminLogView extends ViewPart {
+       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".adminLogView";
+
+       private TableViewer viewer;
+
+       private LogContentProvider logContentProvider;
+       private ArgeoLogger argeoLogger;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               // FIXME doesn't return a monospace font in RAP
+               Font font = JFaceResources.getTextFont();
+               Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+               table.setFont(font);
+
+               viewer = new TableViewer(table);
+               viewer.setLabelProvider(new LabelProvider());
+               logContentProvider = new LogContentProvider(viewer) {
+                       private static final long serialVersionUID = -3401776448301180724L;
+
+                       @Override
+                       protected StringBuffer prefix(String username, Long timestamp,
+                                       String level, String category, String thread) {
+                               return super
+                                               .prefix(username, timestamp, level, category, thread)
+                                               .append(norm(level, 5))
+                                               .append(' ')
+                                               .append(norm(username != null ? username
+                                                               : "<anonymous>", 16)).append(' ');
+                       }
+               };
+               viewer.setContentProvider(logContentProvider);
+               // viewer.setUseHashlookup(true);
+               viewer.setInput(new ArrayList<String>());
+
+               if (argeoLogger != null)
+                       argeoLogger.registerForAll(logContentProvider, 1000, true);
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       @Override
+       public void dispose() {
+               if (argeoLogger != null)
+                       argeoLogger.unregisterForAll(logContentProvider);
+       }
+
+       public void setArgeoLogger(ArgeoLogger argeoLogger) {
+               this.argeoLogger = argeoLogger;
+       }
+
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogContentProvider.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogContentProvider.java
new file mode 100644 (file)
index 0000000..5b12f43
--- /dev/null
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.views;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.argeo.node.ArgeoLogListener;
+import org.eclipse.jface.viewers.ILazyContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+
+/** A content provider maintaining an array of lines */
+class LogContentProvider implements ILazyContentProvider, ArgeoLogListener {
+       private static final long serialVersionUID = -2084872367738339721L;
+
+       private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
+
+       private final Long start;
+       /** current - start = line number. first line is number '1' */
+       private Long current;
+
+       // TODO make it configurable
+       private final Integer maxLineBufferSize = 10 * 1000;
+
+       private final TableViewer viewer;
+       private LinkedList<LogLine> lines;
+
+       public LogContentProvider(TableViewer viewer) {
+               this.viewer = viewer;
+               start = System.currentTimeMillis();
+               lines = new LinkedList<LogLine>();
+               current = start;
+       }
+
+       public synchronized void dispose() {
+               lines.clear();
+               lines = null;
+       }
+
+       @SuppressWarnings("unchecked")
+       public synchronized void inputChanged(Viewer viewer, Object oldInput,
+                       Object newInput) {
+               List<String> lin = (List<String>) newInput;
+               if (lin == null)
+                       return;
+               for (String line : lin) {
+                       addLine(line);
+               }
+               this.viewer.setItemCount(lines.size());
+       }
+
+       public void updateElement(int index) {
+               viewer.replace(lines.get(index), index);
+       }
+
+       public synchronized void appendLog(String username, Long timestamp,
+                       String level, String category, String thread, Object msg,
+                       String[] exception) {
+               // check if valid
+               if (lines == null)
+                       return;
+
+               String message = msg.toString();
+               int count = 0;
+               String prefix = prefix(username, timestamp, level, category, thread)
+                               .toString();
+               // String suffix = suffix(username, timestamp, level, category, thread);
+               for (String line : message.split("\n")) {
+                       addLine(count == 0 ? prefix + line : line);
+                       count++;
+               }
+
+               if (exception != null) {
+                       for (String ste : exception) {
+                               addLine(ste);
+                       }
+               }
+
+               viewer.getTable().getDisplay().asyncExec(new Runnable() {
+                       public void run() {
+                               if (lines == null)
+                                       return;
+                               viewer.setItemCount(lines.size());
+                               // doesn't work with syncExec
+                               scrollToLastLine();
+                       }
+               });
+       }
+
+       protected StringBuffer prefix(String username, Long timestamp,
+                       String level, String category, String thread) {
+               StringBuffer buf = new StringBuffer("");
+               buf.append(dateFormat.format(new Date(timestamp))).append(" ");
+               // buf.append(level).append(" ");
+               return buf;
+       }
+
+       /** Normalize string to the given size */
+       protected String norm(String str, Integer size) {
+               int length = str.length();
+               if (length == size)
+                       return str;
+               else if (length > size)
+                       return str.substring(0, size);
+               else {
+                       char[] arr = new char[size - length];
+                       Arrays.fill(arr, ' ');
+                       return str + new String(arr);
+               }
+       }
+
+       // protected String suffix(String username, Long timestamp, String level,
+       // String category, String thread) {
+       // return "";
+       // }
+
+       /** Scroll to the last line */
+       protected synchronized void scrollToLastLine() {
+               // we try to show last line with two methods
+               // viewer.reveal(lines.peekLast());
+
+               Table table = viewer.getTable();
+               TableItem ti = table.getItem(table.getItemCount() - 1);
+               table.showItem(ti);
+       }
+
+       protected synchronized LogLine addLine(String line) {
+               // check for maximal size and purge if necessary
+               while (lines.size() >= maxLineBufferSize) {
+                       for (int i = 0; i < maxLineBufferSize / 10; i++) {
+                               lines.poll();
+                       }
+               }
+
+               current++;
+               LogLine logLine = new LogLine(current, line);
+               lines.add(logLine);
+               return logLine;
+       }
+
+       private class LogLine {
+               private Long linenumber;
+               private String message;
+
+               public LogLine(Long linenumber, String message) {
+                       this.linenumber = linenumber;
+                       this.message = message;
+               }
+
+               @Override
+               public int hashCode() {
+                       return linenumber.intValue();
+               }
+
+               @Override
+               public boolean equals(Object obj) {
+                       if (obj instanceof LogLine)
+                               return ((LogLine) obj).linenumber.equals(linenumber);
+                       else
+                               return false;
+               }
+
+               @Override
+               public String toString() {
+                       return message;
+               }
+
+       }
+}
\ No newline at end of file
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogView.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/LogView.java
new file mode 100644 (file)
index 0000000..f9e197a
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.views;
+
+import java.util.ArrayList;
+
+import org.argeo.node.ArgeoLogListener;
+import org.argeo.node.ArgeoLogger;
+import org.argeo.security.ui.SecurityUiPlugin;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+
+/**
+ * Display log lines with a virtual table. Register and unregisters a
+ * {@link ArgeoLogListener} via OSGi services.
+ */
+public class LogView extends ViewPart {
+       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".logView";
+
+       private TableViewer viewer;
+
+       private LogContentProvider logContentProvider;
+       private ArgeoLogger argeoLogger;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               Font font = JFaceResources.getTextFont();
+               Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
+                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+               table.setFont(font);
+
+               viewer = new TableViewer(table);
+               viewer.setLabelProvider(new LabelProvider());
+               logContentProvider = new LogContentProvider(viewer);
+               viewer.setContentProvider(logContentProvider);
+               // viewer.setUseHashlookup(true);
+               viewer.setInput(new ArrayList<String>());
+
+               if (argeoLogger != null)
+                       argeoLogger.register(logContentProvider, 1000);
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable().setFocus();
+       }
+
+       @Override
+       public void dispose() {
+               if (argeoLogger != null)
+                       argeoLogger.unregister(logContentProvider);
+       }
+
+       public void setArgeoLogger(ArgeoLogger argeoLogger) {
+               this.argeoLogger = argeoLogger;
+       }
+
+}
diff --git a/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/UserProfile.java b/org.argeo.cms.ui.workbench/src/org/argeo/security/ui/views/UserProfile.java
new file mode 100644 (file)
index 0000000..49f5bea
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.argeo.security.ui.views;
+
+import java.util.TreeSet;
+
+import org.argeo.cms.auth.CurrentUser;
+import org.argeo.eclipse.ui.EclipseUiUtils;
+import org.argeo.security.ui.SecurityUiPlugin;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+
+/** Information about the currently logged in user */
+public class UserProfile extends ViewPart {
+       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".userProfile";
+
+       private TableViewer viewer;
+
+       @Override
+       public void createPartControl(Composite parent) {
+               parent.setLayout(new GridLayout(2, false));
+
+               // Authentication authentication = CurrentUser.getAuthentication();
+               // EclipseUiUtils.createGridLL(parent, "Name", authentication
+               // .getPrincipal().toString());
+               EclipseUiUtils.createGridLL(parent, "User ID",
+                               CurrentUser.getUsername());
+
+               // roles table
+               Table table = new Table(parent, SWT.V_SCROLL | SWT.BORDER);
+               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+               table.setLinesVisible(false);
+               table.setHeaderVisible(false);
+               viewer = new TableViewer(table);
+               viewer.setContentProvider(new RolesContentProvider());
+               viewer.setLabelProvider(new LabelProvider());
+               getViewSite().setSelectionProvider(viewer);
+               viewer.setInput(getViewSite());
+       }
+
+       @Override
+       public void setFocus() {
+               viewer.getTable();
+       }
+
+       private class RolesContentProvider implements IStructuredContentProvider {
+               private static final long serialVersionUID = -4576917440167866233L;
+
+               public Object[] getElements(Object inputElement) {
+                       return new TreeSet<String>(CurrentUser.roles()).toArray();
+               }
+
+               public void dispose() {
+               }
+
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               }
+
+       }
+
+}
diff --git a/org.argeo.security.ui/.classpath b/org.argeo.security.ui/.classpath
deleted file mode 100644 (file)
index 457b115..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-       <classpathentry kind="src" path="src" />
-       <classpathentry kind="con"
-               path="org.eclipse.pde.core.requiredPlugins" />
-       <classpathentry kind="con"
-               path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
-       <classpathentry kind="output" path="bin" />
-</classpath>
diff --git a/org.argeo.security.ui/.project b/org.argeo.security.ui/.project
deleted file mode 100644 (file)
index a052e9a..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
-       <name>org.argeo.security.ui</name>
-       <comment></comment>
-       <projects>
-       </projects>
-       <buildSpec>
-               <buildCommand>
-                       <name>org.eclipse.jdt.core.javabuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.ManifestBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-               <buildCommand>
-                       <name>org.eclipse.pde.SchemaBuilder</name>
-                       <arguments>
-                       </arguments>
-               </buildCommand>
-       </buildSpec>
-       <natures>
-               <nature>org.eclipse.pde.PluginNature</nature>
-               <nature>org.eclipse.jdt.core.javanature</nature>
-       </natures>
-</projectDescription>
diff --git a/org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs b/org.argeo.security.ui/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644 (file)
index dfa507d..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#Sat Jan 15 18:15:48 CET 2011
-eclipse.preferences.version=1
-resolve.requirebundle=false
diff --git a/org.argeo.security.ui/META-INF/spring/commands.xml b/org.argeo.security.ui/META-INF/spring/commands.xml
deleted file mode 100644 (file)
index 3b2e6cc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-</beans>
diff --git a/org.argeo.security.ui/META-INF/spring/keyring.xml b/org.argeo.security.ui/META-INF/spring/keyring.xml
deleted file mode 100644 (file)
index 74c4ad6..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
-
-       <bean
-               class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-               <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
-               <property name="locations">
-                       <value>osgibundle:securityui.properties</value>
-               </property>
-       </bean>
-
-       <bean id="nodeSession" class="org.argeo.jcr.spring.ThreadBoundSession"
-               destroy-method="dispose">
-               <property name="repository" ref="nodeRepository" />
-       </bean>
-
-       <bean id="keyring" class="org.argeo.jcr.security.JcrKeyring">
-               <property name="session" ref="nodeSession" />
-               <property name="defaultCallbackHandler" ref="defaultCallbackHandler" />
-               <property name="secreteKeyLength" value="${argeo.keyring.secreteKeyLength}" />
-       </bean>
-
-</beans>
diff --git a/org.argeo.security.ui/META-INF/spring/osgi.xml b/org.argeo.security.ui/META-INF/spring/osgi.xml
deleted file mode 100644 (file)
index 500efd1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<beans:beans xmlns="http://www.springframework.org/schema/osgi"\r
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"\r
-       xmlns:osgi="http://www.springframework.org/schema/osgi"\r
-       xsi:schemaLocation="http://www.springframework.org/schema/osgi  \r
-       http://www.springframework.org/schema/osgi/spring-osgi-1.1.xsd\r
-       http://www.springframework.org/schema/beans   \r
-       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">\r
-\r
-       <!-- REFERENCES -->\r
-       <reference id="secureLogger" interface="org.argeo.node.ArgeoLogger"\r
-               cardinality="0..1" />\r
-\r
-       <reference id="nodeRepository" interface="javax.jcr.Repository"\r
-               filter="(argeo.jcr.repository.alias=home)" />\r
-\r
-       <reference id="defaultCallbackHandler" interface="javax.security.auth.callback.CallbackHandler" />\r
-\r
-       <!-- SERVICES -->\r
-       <service interface="org.argeo.util.security.CryptoKeyring"\r
-               ref="keyring" />\r
-</beans:beans>
\ No newline at end of file
diff --git a/org.argeo.security.ui/META-INF/spring/views.xml b/org.argeo.security.ui/META-INF/spring/views.xml
deleted file mode 100644 (file)
index e5363dc..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd">
-
-       <bean id="logView" class="org.argeo.security.ui.views.LogView"
-               scope="prototype">
-               <property name="argeoLogger" ref="secureLogger" />
-       </bean>
-
-       <bean id="adminLogView" class="org.argeo.security.ui.views.AdminLogView"
-               scope="prototype">
-               <property name="argeoLogger" ref="secureLogger" />
-       </bean>
-
-</beans>
diff --git a/org.argeo.security.ui/bnd.bnd b/org.argeo.security.ui/bnd.bnd
deleted file mode 100644 (file)
index 66284b1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-Bundle-SymbolicName: org.argeo.security.ui;singleton:=true
-Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.argeo.security.ui.SecurityUiPlugin
-
-Import-Package: org.argeo.eclipse.spring,\
-org.osgi.framework,\
-org.eclipse.swt,\
-org.eclipse.jface.window,\
-org.apache.log4j;resolution:=optional,\
-org.eclipse.ui;resolution:=optional,\
-*
diff --git a/org.argeo.security.ui/build.properties b/org.argeo.security.ui/build.properties
deleted file mode 100644 (file)
index 30f7153..0000000
+++ /dev/null
@@ -1 +0,0 @@
-source.. = src/
diff --git a/org.argeo.security.ui/icons/adminLog.gif b/org.argeo.security.ui/icons/adminLog.gif
deleted file mode 100644 (file)
index 6ef3bca..0000000
Binary files a/org.argeo.security.ui/icons/adminLog.gif and /dev/null differ
diff --git a/org.argeo.security.ui/icons/home.gif b/org.argeo.security.ui/icons/home.gif
deleted file mode 100644 (file)
index fd0c669..0000000
Binary files a/org.argeo.security.ui/icons/home.gif and /dev/null differ
diff --git a/org.argeo.security.ui/icons/log.gif b/org.argeo.security.ui/icons/log.gif
deleted file mode 100644 (file)
index e3ecc55..0000000
Binary files a/org.argeo.security.ui/icons/log.gif and /dev/null differ
diff --git a/org.argeo.security.ui/icons/maintenance.gif b/org.argeo.security.ui/icons/maintenance.gif
deleted file mode 100644 (file)
index e5690ec..0000000
Binary files a/org.argeo.security.ui/icons/maintenance.gif and /dev/null differ
diff --git a/org.argeo.security.ui/icons/password.gif b/org.argeo.security.ui/icons/password.gif
deleted file mode 100644 (file)
index a6b251f..0000000
Binary files a/org.argeo.security.ui/icons/password.gif and /dev/null differ
diff --git a/org.argeo.security.ui/icons/user.gif b/org.argeo.security.ui/icons/user.gif
deleted file mode 100644 (file)
index 90a0014..0000000
Binary files a/org.argeo.security.ui/icons/user.gif and /dev/null differ
diff --git a/org.argeo.security.ui/plugin.xml b/org.argeo.security.ui/plugin.xml
deleted file mode 100644 (file)
index b843d9c..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-   <!-- Security -->
-   <extension point="org.eclipse.ui.services">
-        <sourceProvider
-              provider="org.argeo.security.ui.RolesSourceProvider">
-           <variable
-                 name="org.argeo.security.ui.rolesVariable"
-                 priorityLevel="workbench">
-           </variable>
-        </sourceProvider>
-     </extension>
-   <extension
-         point="org.eclipse.ui.views">
-      <view
-            id="org.argeo.security.ui.userProfile"
-            class="org.argeo.security.ui.views.UserProfile"
-            icon="icons/user.gif"
-            name="Profile"
-            restorable="true">
-      </view>
-      <view
-            id="org.argeo.security.ui.logView"
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            name="Log"
-            icon="icons/log.gif"
-            restorable="true">
-      </view>
-      <view
-            id="org.argeo.security.ui.adminLogView"
-            class="org.argeo.eclipse.spring.SpringExtensionFactory"
-            name="Admin Log"
-            icon="icons/adminLog.gif"
-            restorable="true">
-      </view>
-   </extension>
-   <extension
-         point="org.eclipse.ui.perspectives">
-      <perspective
-            class="org.argeo.security.ui.UserHomePerspective"
-            icon="icons/home.gif"
-            id="org.argeo.security.ui.userHomePerspective"
-            name="Home">
-      </perspective>
-      <perspective
-            class="org.argeo.security.ui.MaintenancePerspective"
-            icon="icons/maintenance.gif"
-            id="org.argeo.security.ui.adminMaintenancePerspective"
-            name="Maintenance">
-      </perspective>
-   </extension>
-  <extension
-           point="org.eclipse.ui.activities">
-        <activity
-              description="Authenticated users"
-              id="org.argeo.security.ui.userActivity"
-              name="User">
-                 <enabledWhen>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=user,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                 </enabledWhen>
-        </activity>
-        <activity
-              description="Admins"
-              id="org.argeo.security.ui.adminActivity"
-              name="Admin">
-                 <enabledWhen>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=admin,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                 </enabledWhen>
-        </activity>
-        <activity
-              description="User Admins"
-              id="org.argeo.security.ui.userAdminActivity"
-              name="User Admin">
-                 <enabledWhen>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=userAdmin,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                 </enabledWhen>
-        </activity>
-        <activity
-              description="Group Admins"
-              id="org.argeo.security.ui.groupAdminActivity"
-              name="User Admin">
-                 <enabledWhen>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=groupAdmin,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                 </enabledWhen>
-        </activity>
-        <activity
-              description="Non admins"
-              id="org.argeo.security.ui.notAdminActivity"
-              name="Not Admin">
-                 <enabledWhen>
-                       <not>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="cn=admin,ou=roles,ou=node" />
-                     </iterate>
-                   </with>
-                       </not>
-                 </enabledWhen>
-        </activity>
-        <activity
-              description="Non remote"
-              id="org.argeo.security.ui.notRemoteActivity"
-              name="NonRemote">
-                 <enabledWhen>
-                       <not>
-                   <with variable="roles">
-                     <iterate ifEmpty="false" operator="or">
-                       <equals value="ROLE_REMOTE" />
-                     </iterate>
-                   </with>
-                       </not>
-                 </enabledWhen>
-        </activity>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.security.ui/org.argeo.security.ui.adminMaintenancePerspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.adminActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.security.ui/org.argeo.security.ui.adminLogView">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.userActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.security.ui/org.argeo.security.ui.userHomePerspective">
-        </activityPatternBinding>
-        <activityPatternBinding
-              activityId="org.argeo.security.ui.userActivity"
-              isEqualityPattern="true"
-              pattern="org.argeo.security.ui/org.argeo.security.ui.userProfile">
-        </activityPatternBinding>
-     </extension>
- </plugin>
diff --git a/org.argeo.security.ui/pom.xml b/org.argeo.security.ui/pom.xml
deleted file mode 100644 (file)
index beb3740..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-       <modelVersion>4.0.0</modelVersion>
-       <parent>
-               <groupId>org.argeo.commons</groupId>
-               <version>2.1.46-SNAPSHOT</version>
-               <artifactId>argeo-commons</artifactId>
-               <relativePath>..</relativePath>
-       </parent>
-       <artifactId>org.argeo.security.ui</artifactId>
-       <name>CMS Workbench</name>
-       <packaging>jar</packaging>
-       <dependencies>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.cms</artifactId>
-                       <version>2.1.46-SNAPSHOT</version>
-               </dependency>
-<!--           <dependency> -->
-<!--                   <groupId>org.argeo.commons</groupId> -->
-<!--                   <artifactId>org.argeo.security.core</artifactId> -->
-<!--                   <version>2.1.46-SNAPSHOT</version> -->
-<!--           </dependency> -->
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.eclipse.ui.workbench</artifactId>
-                       <version>2.1.46-SNAPSHOT</version>
-               </dependency>
-               <dependency>
-                       <groupId>org.argeo.commons</groupId>
-                       <artifactId>org.argeo.util</artifactId>
-                       <version>2.1.46-SNAPSHOT</version>
-               </dependency>
-       </dependencies>
-</project>
\ No newline at end of file
diff --git a/org.argeo.security.ui/securityui.properties b/org.argeo.security.ui/securityui.properties
deleted file mode 100644 (file)
index 0228d47..0000000
+++ /dev/null
@@ -1 +0,0 @@
-argeo.keyring.secreteKeyLength=256
\ No newline at end of file
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/MaintenancePerspective.java b/org.argeo.security.ui/src/org/argeo/security/ui/MaintenancePerspective.java
deleted file mode 100644 (file)
index 86307ab..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui;
-
-import org.argeo.security.ui.views.AdminLogView;
-import org.argeo.security.ui.views.UserProfile;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Home perspective for the current user */
-public class MaintenancePerspective implements IPerspectiveFactory {
-       public final static String ID = SecurityUiPlugin.PLUGIN_ID
-                       + ".adminMaintenancePerspective";
-
-       public void createInitialLayout(IPageLayout layout) {
-               String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(true);
-               layout.setFixed(false);
-
-               IFolderLayout bottom = layout.createFolder("bottom",
-                               IPageLayout.BOTTOM, 0.50f, editorArea);
-               bottom.addView(AdminLogView.ID);
-
-               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
-                               0.30f, editorArea);
-               left.addView(UserProfile.ID);
-               // left.addView(RolesView.ID);
-
-       }
-
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/PrivilegedJob.java b/org.argeo.security.ui/src/org/argeo/security/ui/PrivilegedJob.java
deleted file mode 100644 (file)
index 3a9ade4..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.argeo.security.ui;
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import javax.security.auth.Subject;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-
-/**
- * Propagate authentication to an eclipse job. Typically to execute a privileged
- * action outside the UI thread
- */
-public abstract class PrivilegedJob extends Job {
-       private final Subject subject;
-
-       public PrivilegedJob(String jobName) {
-               this(jobName, AccessController.getContext());
-       }
-
-       public PrivilegedJob(String jobName,
-                       AccessControlContext accessControlContext) {
-               super(jobName);
-               subject = Subject.getSubject(accessControlContext);
-
-               // Must be called *before* the job is scheduled,
-               // it is required for the progress window to appear
-               setUser(true);
-       }
-
-       @Override
-       protected IStatus run(final IProgressMonitor progressMonitor) {
-               PrivilegedAction<IStatus> privilegedAction = new PrivilegedAction<IStatus>() {
-                       public IStatus run() {
-                               return doRun(progressMonitor);
-                       }
-               };
-               return Subject.doAs(subject, privilegedAction);
-       }
-
-       /**
-        * Implement here what should be executed with default context
-        * authentication
-        */
-       protected abstract IStatus doRun(IProgressMonitor progressMonitor);
-}
\ No newline at end of file
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/RolesSourceProvider.java b/org.argeo.security.ui/src/org/argeo/security/ui/RolesSourceProvider.java
deleted file mode 100644 (file)
index 42e6f10..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.eclipse.ui.AbstractSourceProvider;
-
-/**
- * Provides the roles of the current user as a variable to be used for activity
- * binding
- */
-public class RolesSourceProvider extends AbstractSourceProvider {
-       public final static String ROLES_VARIABLE = "roles";
-       private final static String[] PROVIDED_SOURCE_NAMES = new String[] { ROLES_VARIABLE };
-
-       public Map<String, Set<String>> getCurrentState() {
-               Map<String, Set<String>> stateMap = new HashMap<String, Set<String>>();
-               stateMap.put(ROLES_VARIABLE, CurrentUser.roles());
-               return stateMap;
-       }
-
-       public String[] getProvidedSourceNames() {
-               return PROVIDED_SOURCE_NAMES;
-       }
-
-       public void updateRoles() {
-               fireSourceChanged(0, getCurrentState());
-       }
-
-       public void dispose() {
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/SecurityUiPlugin.java b/org.argeo.security.ui/src/org/argeo/security/ui/SecurityUiPlugin.java
deleted file mode 100644 (file)
index 935b543..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui;
-
-import java.io.IOException;
-
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-import org.argeo.cms.CmsException;
-import org.argeo.cms.widgets.auth.DefaultLoginDialog;
-import org.eclipse.swt.widgets.Display;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class SecurityUiPlugin implements BundleActivator {
-       private static BundleContext bundleContext;
-       public static InheritableThreadLocal<Display> display = new InheritableThreadLocal<Display>() {
-
-               @Override
-               protected Display initialValue() {
-                       return Display.getCurrent();
-               }
-       };
-
-       // The plug-in ID
-       public final static String PLUGIN_ID = "org.argeo.security.ui"; //$NON-NLS-1$
-
-       final static String CONTEXT_KEYRING = "KEYRING";
-
-       private CallbackHandler defaultCallbackHandler;
-       private ServiceRegistration<CallbackHandler> defaultCallbackHandlerReg;
-
-       public void start(BundleContext context) throws Exception {
-               bundleContext = context;
-
-               defaultCallbackHandler = new DefaultCallbackHandler();
-               defaultCallbackHandlerReg = context.registerService(
-                               CallbackHandler.class, defaultCallbackHandler, null);
-       }
-
-       public void stop(BundleContext context) throws Exception {
-               bundleContext = null;
-               defaultCallbackHandlerReg.unregister();
-       }
-
-       public static BundleContext getBundleContext() {
-               return bundleContext;
-       }
-
-       protected class DefaultCallbackHandler implements CallbackHandler {
-               public void handle(final Callback[] callbacks) throws IOException,
-                               UnsupportedCallbackException {
-
-                       // if (display != null) // RCP
-                       Display displayToUse = display.get();
-                       if (displayToUse == null)// RCP
-                               displayToUse = Display.getDefault();
-                       displayToUse.syncExec(new Runnable() {
-                               public void run() {
-                                       DefaultLoginDialog dialog = new DefaultLoginDialog(display
-                                                       .get().getActiveShell());
-                                       try {
-                                               dialog.handle(callbacks);
-                                       } catch (IOException e) {
-                                               throw new CmsException("Cannot open dialog", e);
-                                       }
-                               }
-                       });
-                       // else {// RAP
-                       // DefaultLoginDialog dialog = new DefaultLoginDialog();
-                       // dialog.handle(callbacks);
-                       // }
-               }
-
-       }
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/UserHomePerspective.java b/org.argeo.security.ui/src/org/argeo/security/ui/UserHomePerspective.java
deleted file mode 100644 (file)
index 119549f..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui;
-
-import org.argeo.security.ui.views.LogView;
-import org.argeo.security.ui.views.UserProfile;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-/** Home perspective for the current user */
-public class UserHomePerspective implements IPerspectiveFactory {
-       public final static String ID = SecurityUiPlugin.PLUGIN_ID
-                       + ".userHomePerspective";
-
-       public void createInitialLayout(IPageLayout layout) {
-               String editorArea = layout.getEditorArea();
-               layout.setEditorAreaVisible(true);
-               layout.setFixed(false);
-
-               IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
-                               0.30f, editorArea);
-               left.addView(UserProfile.ID);
-               left.addView(LogView.ID);
-       }
-
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java b/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenChangePasswordDialog.java
deleted file mode 100644 (file)
index 817354f..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.commands;
-
-import static org.argeo.cms.CmsMsg.changePassword;
-import static org.argeo.cms.CmsMsg.currentPassword;
-import static org.argeo.cms.CmsMsg.newPassword;
-import static org.argeo.cms.CmsMsg.passwordChanged;
-import static org.argeo.cms.CmsMsg.repeatNewPassword;
-import static org.eclipse.jface.dialogs.IMessageProvider.INFORMATION;
-
-import java.security.AccessController;
-
-import javax.naming.InvalidNameException;
-import javax.naming.ldap.LdapName;
-import javax.security.auth.Subject;
-import javax.security.auth.x500.X500Principal;
-import javax.transaction.UserTransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.cms.CmsException;
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.osgi.service.useradmin.User;
-import org.osgi.service.useradmin.UserAdmin;
-
-/** Opens the change password dialog. */
-public class OpenChangePasswordDialog extends AbstractHandler {
-       private final static Log log = LogFactory
-                       .getLog(OpenChangePasswordDialog.class);
-       private UserAdmin userAdmin;
-       private UserTransaction userTransaction;
-
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               ChangePasswordDialog dialog = new ChangePasswordDialog(
-                               HandlerUtil.getActiveShell(event), userAdmin);
-               if (dialog.open() == Dialog.OK) {
-                       MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
-                                       passwordChanged.lead(), passwordChanged.lead());
-               }
-               return null;
-       }
-
-       @SuppressWarnings("unchecked")
-       protected void changePassword(char[] oldPassword, char[] newPassword) {
-               Subject subject = Subject.getSubject(AccessController.getContext());
-               String name = subject.getPrincipals(X500Principal.class).iterator()
-                               .next().toString();
-               LdapName dn;
-               try {
-                       dn = new LdapName(name);
-               } catch (InvalidNameException e) {
-                       throw new CmsException("Invalid user dn " + name, e);
-               }
-               User user = (User) userAdmin.getRole(dn.toString());
-               if (!user.hasCredential(null, oldPassword))
-                       throw new CmsException("Invalid password");
-               if (newPassword.equals(""))
-                       throw new CmsException("New password empty");
-               try {
-                       userTransaction.begin();
-                       user.getCredentials().put(null, newPassword);
-                       userTransaction.commit();
-               } catch (Exception e) {
-                       try {
-                               userTransaction.rollback();
-                       } catch (Exception e1) {
-                               log.error("Could not roll back", e1);
-                       }
-                       if (e instanceof RuntimeException)
-                               throw (RuntimeException) e;
-                       else
-                               throw new CmsException("Cannot change password", e);
-               }
-       }
-
-       public void setUserAdmin(UserAdmin userDetailsManager) {
-               this.userAdmin = userDetailsManager;
-       }
-
-       public void setUserTransaction(UserTransaction userTransaction) {
-               this.userTransaction = userTransaction;
-       }
-
-       class ChangePasswordDialog extends TitleAreaDialog {
-               private static final long serialVersionUID = -6963970583882720962L;
-               private Text oldPassword, newPassword1, newPassword2;
-
-               public ChangePasswordDialog(Shell parentShell, UserAdmin securityService) {
-                       super(parentShell);
-               }
-
-               protected Point getInitialSize() {
-                       return new Point(400, 450);
-               }
-
-               protected Control createDialogArea(Composite parent) {
-                       Composite dialogarea = (Composite) super.createDialogArea(parent);
-                       dialogarea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                       true));
-                       Composite composite = new Composite(dialogarea, SWT.NONE);
-                       composite.setLayout(new GridLayout(2, false));
-                       composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
-                                       false));
-                       oldPassword = createLP(composite, currentPassword.lead());
-                       newPassword1 = createLP(composite, newPassword.lead());
-                       newPassword2 = createLP(composite, repeatNewPassword.lead());
-
-                       setMessage(changePassword.lead(), INFORMATION);
-                       parent.pack();
-                       return composite;
-               }
-
-               @Override
-               protected void okPressed() {
-                       try {
-                               if (!newPassword1.getText().equals(newPassword2.getText()))
-                                       throw new CmsException("New passwords are different");
-                               changePassword(oldPassword.getTextChars(),
-                                               newPassword1.getTextChars());
-                               close();
-                       } catch (Exception e) {
-                               ErrorFeedback.show("Cannot change password", e);
-                       }
-               }
-
-               /** Creates label and password. */
-               protected Text createLP(Composite parent, String label) {
-                       new Label(parent, SWT.NONE).setText(label);
-                       Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.PASSWORD
-                                       | SWT.BORDER);
-                       text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-                       return text;
-               }
-
-               protected void configureShell(Shell shell) {
-                       super.configureShell(shell);
-                       shell.setText(changePassword.lead());
-               }
-
-       }
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java b/org.argeo.security.ui/src/org/argeo/security/ui/commands/OpenHomePerspective.java
deleted file mode 100644 (file)
index f6aa0d1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.commands;
-
-import org.argeo.eclipse.ui.dialogs.ErrorFeedback;
-import org.argeo.security.ui.UserHomePerspective;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.WorkbenchException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Default action of the user menu */
-public class OpenHomePerspective extends AbstractHandler {
-       
-       public Object execute(ExecutionEvent event) throws ExecutionException {         
-               try {
-                       HandlerUtil.getActiveSite(event).getWorkbenchWindow()
-                                       .openPage(UserHomePerspective.ID, null);
-               } catch (WorkbenchException e) {
-                       ErrorFeedback.show("Cannot open home perspective", e);
-               }
-               return null;
-       }
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/views/AdminLogView.java b/org.argeo.security.ui/src/org/argeo/security/ui/views/AdminLogView.java
deleted file mode 100644 (file)
index 61efc8c..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.views;
-
-import java.util.ArrayList;
-
-import org.argeo.node.ArgeoLogger;
-import org.argeo.security.ui.SecurityUiPlugin;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Display log lines for all users with a virtual table.
- */
-public class AdminLogView extends ViewPart {
-       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".adminLogView";
-
-       private TableViewer viewer;
-
-       private LogContentProvider logContentProvider;
-       private ArgeoLogger argeoLogger;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               // FIXME doesn't return a monospace font in RAP
-               Font font = JFaceResources.getTextFont();
-               Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-               table.setFont(font);
-
-               viewer = new TableViewer(table);
-               viewer.setLabelProvider(new LabelProvider());
-               logContentProvider = new LogContentProvider(viewer) {
-                       private static final long serialVersionUID = -3401776448301180724L;
-
-                       @Override
-                       protected StringBuffer prefix(String username, Long timestamp,
-                                       String level, String category, String thread) {
-                               return super
-                                               .prefix(username, timestamp, level, category, thread)
-                                               .append(norm(level, 5))
-                                               .append(' ')
-                                               .append(norm(username != null ? username
-                                                               : "<anonymous>", 16)).append(' ');
-                       }
-               };
-               viewer.setContentProvider(logContentProvider);
-               // viewer.setUseHashlookup(true);
-               viewer.setInput(new ArrayList<String>());
-
-               if (argeoLogger != null)
-                       argeoLogger.registerForAll(logContentProvider, 1000, true);
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable().setFocus();
-       }
-
-       @Override
-       public void dispose() {
-               if (argeoLogger != null)
-                       argeoLogger.unregisterForAll(logContentProvider);
-       }
-
-       public void setArgeoLogger(ArgeoLogger argeoLogger) {
-               this.argeoLogger = argeoLogger;
-       }
-
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/views/LogContentProvider.java b/org.argeo.security.ui/src/org/argeo/security/ui/views/LogContentProvider.java
deleted file mode 100644 (file)
index 5b12f43..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.views;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.argeo.node.ArgeoLogListener;
-import org.eclipse.jface.viewers.ILazyContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-/** A content provider maintaining an array of lines */
-class LogContentProvider implements ILazyContentProvider, ArgeoLogListener {
-       private static final long serialVersionUID = -2084872367738339721L;
-
-       private DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
-
-       private final Long start;
-       /** current - start = line number. first line is number '1' */
-       private Long current;
-
-       // TODO make it configurable
-       private final Integer maxLineBufferSize = 10 * 1000;
-
-       private final TableViewer viewer;
-       private LinkedList<LogLine> lines;
-
-       public LogContentProvider(TableViewer viewer) {
-               this.viewer = viewer;
-               start = System.currentTimeMillis();
-               lines = new LinkedList<LogLine>();
-               current = start;
-       }
-
-       public synchronized void dispose() {
-               lines.clear();
-               lines = null;
-       }
-
-       @SuppressWarnings("unchecked")
-       public synchronized void inputChanged(Viewer viewer, Object oldInput,
-                       Object newInput) {
-               List<String> lin = (List<String>) newInput;
-               if (lin == null)
-                       return;
-               for (String line : lin) {
-                       addLine(line);
-               }
-               this.viewer.setItemCount(lines.size());
-       }
-
-       public void updateElement(int index) {
-               viewer.replace(lines.get(index), index);
-       }
-
-       public synchronized void appendLog(String username, Long timestamp,
-                       String level, String category, String thread, Object msg,
-                       String[] exception) {
-               // check if valid
-               if (lines == null)
-                       return;
-
-               String message = msg.toString();
-               int count = 0;
-               String prefix = prefix(username, timestamp, level, category, thread)
-                               .toString();
-               // String suffix = suffix(username, timestamp, level, category, thread);
-               for (String line : message.split("\n")) {
-                       addLine(count == 0 ? prefix + line : line);
-                       count++;
-               }
-
-               if (exception != null) {
-                       for (String ste : exception) {
-                               addLine(ste);
-                       }
-               }
-
-               viewer.getTable().getDisplay().asyncExec(new Runnable() {
-                       public void run() {
-                               if (lines == null)
-                                       return;
-                               viewer.setItemCount(lines.size());
-                               // doesn't work with syncExec
-                               scrollToLastLine();
-                       }
-               });
-       }
-
-       protected StringBuffer prefix(String username, Long timestamp,
-                       String level, String category, String thread) {
-               StringBuffer buf = new StringBuffer("");
-               buf.append(dateFormat.format(new Date(timestamp))).append(" ");
-               // buf.append(level).append(" ");
-               return buf;
-       }
-
-       /** Normalize string to the given size */
-       protected String norm(String str, Integer size) {
-               int length = str.length();
-               if (length == size)
-                       return str;
-               else if (length > size)
-                       return str.substring(0, size);
-               else {
-                       char[] arr = new char[size - length];
-                       Arrays.fill(arr, ' ');
-                       return str + new String(arr);
-               }
-       }
-
-       // protected String suffix(String username, Long timestamp, String level,
-       // String category, String thread) {
-       // return "";
-       // }
-
-       /** Scroll to the last line */
-       protected synchronized void scrollToLastLine() {
-               // we try to show last line with two methods
-               // viewer.reveal(lines.peekLast());
-
-               Table table = viewer.getTable();
-               TableItem ti = table.getItem(table.getItemCount() - 1);
-               table.showItem(ti);
-       }
-
-       protected synchronized LogLine addLine(String line) {
-               // check for maximal size and purge if necessary
-               while (lines.size() >= maxLineBufferSize) {
-                       for (int i = 0; i < maxLineBufferSize / 10; i++) {
-                               lines.poll();
-                       }
-               }
-
-               current++;
-               LogLine logLine = new LogLine(current, line);
-               lines.add(logLine);
-               return logLine;
-       }
-
-       private class LogLine {
-               private Long linenumber;
-               private String message;
-
-               public LogLine(Long linenumber, String message) {
-                       this.linenumber = linenumber;
-                       this.message = message;
-               }
-
-               @Override
-               public int hashCode() {
-                       return linenumber.intValue();
-               }
-
-               @Override
-               public boolean equals(Object obj) {
-                       if (obj instanceof LogLine)
-                               return ((LogLine) obj).linenumber.equals(linenumber);
-                       else
-                               return false;
-               }
-
-               @Override
-               public String toString() {
-                       return message;
-               }
-
-       }
-}
\ No newline at end of file
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/views/LogView.java b/org.argeo.security.ui/src/org/argeo/security/ui/views/LogView.java
deleted file mode 100644 (file)
index f9e197a..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.views;
-
-import java.util.ArrayList;
-
-import org.argeo.node.ArgeoLogListener;
-import org.argeo.node.ArgeoLogger;
-import org.argeo.security.ui.SecurityUiPlugin;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * Display log lines with a virtual table. Register and unregisters a
- * {@link ArgeoLogListener} via OSGi services.
- */
-public class LogView extends ViewPart {
-       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".logView";
-
-       private TableViewer viewer;
-
-       private LogContentProvider logContentProvider;
-       private ArgeoLogger argeoLogger;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               Font font = JFaceResources.getTextFont();
-               Table table = new Table(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL
-                               | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
-               table.setFont(font);
-
-               viewer = new TableViewer(table);
-               viewer.setLabelProvider(new LabelProvider());
-               logContentProvider = new LogContentProvider(viewer);
-               viewer.setContentProvider(logContentProvider);
-               // viewer.setUseHashlookup(true);
-               viewer.setInput(new ArrayList<String>());
-
-               if (argeoLogger != null)
-                       argeoLogger.register(logContentProvider, 1000);
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable().setFocus();
-       }
-
-       @Override
-       public void dispose() {
-               if (argeoLogger != null)
-                       argeoLogger.unregister(logContentProvider);
-       }
-
-       public void setArgeoLogger(ArgeoLogger argeoLogger) {
-               this.argeoLogger = argeoLogger;
-       }
-
-}
diff --git a/org.argeo.security.ui/src/org/argeo/security/ui/views/UserProfile.java b/org.argeo.security.ui/src/org/argeo/security/ui/views/UserProfile.java
deleted file mode 100644 (file)
index 49f5bea..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2007-2012 Argeo GmbH
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.argeo.security.ui.views;
-
-import java.util.TreeSet;
-
-import org.argeo.cms.auth.CurrentUser;
-import org.argeo.eclipse.ui.EclipseUiUtils;
-import org.argeo.security.ui.SecurityUiPlugin;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.part.ViewPart;
-
-/** Information about the currently logged in user */
-public class UserProfile extends ViewPart {
-       public static String ID = SecurityUiPlugin.PLUGIN_ID + ".userProfile";
-
-       private TableViewer viewer;
-
-       @Override
-       public void createPartControl(Composite parent) {
-               parent.setLayout(new GridLayout(2, false));
-
-               // Authentication authentication = CurrentUser.getAuthentication();
-               // EclipseUiUtils.createGridLL(parent, "Name", authentication
-               // .getPrincipal().toString());
-               EclipseUiUtils.createGridLL(parent, "User ID",
-                               CurrentUser.getUsername());
-
-               // roles table
-               Table table = new Table(parent, SWT.V_SCROLL | SWT.BORDER);
-               table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
-               table.setLinesVisible(false);
-               table.setHeaderVisible(false);
-               viewer = new TableViewer(table);
-               viewer.setContentProvider(new RolesContentProvider());
-               viewer.setLabelProvider(new LabelProvider());
-               getViewSite().setSelectionProvider(viewer);
-               viewer.setInput(getViewSite());
-       }
-
-       @Override
-       public void setFocus() {
-               viewer.getTable();
-       }
-
-       private class RolesContentProvider implements IStructuredContentProvider {
-               private static final long serialVersionUID = -4576917440167866233L;
-
-               public Object[] getElements(Object inputElement) {
-                       return new TreeSet<String>(CurrentUser.roles()).toArray();
-               }
-
-               public void dispose() {
-               }
-
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-               }
-
-       }
-
-}