portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1653148 - in /portals/jetspeed-2/portal/trunk/components: jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/ jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/ jetspeed-security/src/test/java...
Date Mon, 19 Jan 2015 23:03:51 GMT
Author: taylor
Date: Mon Jan 19 23:03:50 2015
New Revision: 1653148

URL: http://svn.apache.org/r1653148
Log:
JS2-1300: delete user preferences when deleting a user

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/JETSPEED-INF/spring/TestRegistryStubs.xml
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubPortletPreferences.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/StubPortletPreferences.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java?rev=1653148&r1=1653147&r2=1653148&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/components/portletpreferences/PortletPreferencesServiceImpl.java
Mon Jan 19 23:03:50 2015
@@ -638,6 +638,15 @@ public class PortletPreferencesServiceIm
         }
     }
 
+    @Override
+    public void removeUserPreferences(String user) {
+        Criteria c = new Criteria();
+        c.addEqualTo(DTYPE, DISCRIMINATOR_USER);
+        c.addEqualTo(USER_NAME, user);
+        QueryByCriteria query = QueryFactory.newQuery(DatabasePreference.class, c);
+        getPersistenceBrokerTemplate().deleteByQuery(query);
+    }
+
     /**
      * Jetspeed: PortletPreferencesProvider
      */        

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java?rev=1653148&r1=1653147&r2=1653148&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/main/java/org/apache/jetspeed/security/impl/UserManagerImpl.java
Mon Jan 19 23:03:50 2015
@@ -16,17 +16,7 @@
  */
 package org.apache.jetspeed.security.impl;
 
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
 import org.apache.jetspeed.security.AuthenticatedUser;
 import org.apache.jetspeed.security.AuthenticatedUserImpl;
 import org.apache.jetspeed.security.GroupManager;
@@ -48,6 +38,16 @@ import org.apache.jetspeed.security.spi.
 import org.apache.jetspeed.security.spi.UserPasswordCredentialManager;
 import org.apache.jetspeed.security.spi.UserSubjectPrincipalsProvider;
 import org.apache.jetspeed.security.spi.UserSubjectPrincipalsResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * <p>
@@ -72,6 +72,7 @@ public class UserManagerImpl extends Bas
 	private RoleManager roleManager;
 	private GroupManager groupManager;
 	private Map<String, UserSubjectPrincipalsResolver> usprMap = new HashMap<String,
UserSubjectPrincipalsResolver>();
+	private PortletPreferencesProvider preferencesProvider = null;
 
 	public UserManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType roleType,
JetspeedPrincipalType groupType,
 			JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialManager
credentialManager)
@@ -82,6 +83,17 @@ public class UserManagerImpl extends Bas
 		this.groupType = groupType;
 	}
 
+	public UserManagerImpl(JetspeedPrincipalType principalType, JetspeedPrincipalType roleType,
JetspeedPrincipalType groupType,
+						   JetspeedPrincipalAccessManager jpam, JetspeedPrincipalStorageManager jpsm, UserPasswordCredentialManager
credentialManager,
+						   PortletPreferencesProvider preferencesProvider)
+	{
+		super(principalType, jpam, jpsm);
+		this.credentialManager = credentialManager;
+		this.roleType = roleType;
+		this.groupType = groupType;
+		this.preferencesProvider = preferencesProvider;
+	}
+
 	public void checkInitialized()
 	{
 		if (groupManager == null)
@@ -246,6 +258,11 @@ public class UserManagerImpl extends Bas
 		
 		user = getUser(username);
 		super.removePrincipal(user);
+
+		// Since 2.3.0
+		if (preferencesProvider != null) {
+			preferencesProvider.removeUserPreferences(username);
+		}
 	}
 	
 	public void removePrincipal(String principalName) throws SecurityException

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/JETSPEED-INF/spring/TestRegistryStubs.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/JETSPEED-INF/spring/TestRegistryStubs.xml?rev=1653148&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/JETSPEED-INF/spring/TestRegistryStubs.xml
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/JETSPEED-INF/spring/TestRegistryStubs.xml
Mon Jan 19 23:03:50 2015
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+    <bean id="org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider"
name="portletPreferencesProvider"
+          class="org.apache.jetspeed.security.stubs.StubPortletPreferences">
+    </bean>
+
+</beans>
\ No newline at end of file

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java?rev=1653148&r1=1653147&r2=1653148&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/AbstractSecurityTestcase.java
Mon Jan 19 23:03:50 2015
@@ -151,6 +151,7 @@ public class AbstractSecurityTestcase ex
         // override the JetspeedPrincipalManagerProvider bean to get rid of
         // dependency on SSO
         confList.add("JETSPEED-INF/spring/JetspeedPrincipalManagerProviderOverride.xml");
+        confList.add("JETSPEED-INF/spring/TestRegistryStubs.xml");
         return (String[]) confList.toArray(new String[1]);
     }
 

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubPortletPreferences.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubPortletPreferences.java?rev=1653148&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubPortletPreferences.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-security/src/test/java/org/apache/jetspeed/security/stubs/StubPortletPreferences.java
Mon Jan 19 23:03:50 2015
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.security.stubs;
+
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
+import org.apache.jetspeed.components.portletpreferences.PreferencesException;
+import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.om.portlet.Preferences;
+import org.apache.pluto.container.PortletContainerException;
+import org.apache.pluto.container.PortletPreference;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ValidatorException;
+import java.util.Map;
+import java.util.Set;
+
+public class StubPortletPreferences implements PortletPreferencesProvider {
+    @Override
+    public void preload() throws Exception {
+
+    }
+
+    @Override
+    public void preloadApplicationPreferences(String portletApplicationName) {
+
+    }
+
+    @Override
+    public void preloadUserPreferences() {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletDefinition pd, Preferences prefs) {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletDefinition pd, Preference preference) {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletApplication app) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletDefinition pd) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletDefinition pd, String preferenceName) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletApplication app) {
+
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveDefaultPreferences(PortletDefinition
pd) {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveUserPreferences(PortletWindow window,
String userName) {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveEntityPreferences(PortletWindow window)
{
+        return null;
+    }
+
+    @Override
+    public void storeUserPreferences(Map<String, PortletPreference> map, PortletWindow
window, String userName) throws PreferencesException {
+
+    }
+
+    @Override
+    public void storeEntityPreferences(Map<String, PortletPreference> map, PortletWindow
window) throws PreferencesException {
+
+    }
+
+    @Override
+    public Set<String> getPortletWindowIds(PortletDefinition portletdefinition) {
+        return null;
+    }
+
+    @Override
+    public Set<String> getUserNames(PortletDefinition portletdefinition, String windowId)
{
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> getUserPreferences(PortletDefinition portletdefinition,
String windowId, String userName) {
+        return null;
+    }
+
+    @Override
+    public void storePortletPreference(PortletDefinition portletdefinition, String windowId,
String userName, Map<String, PortletPreference> map) {
+
+    }
+
+    @Override
+    public void storePortletPreference(String appName, String portletName, String windowId,
String userName, Map<String, PortletPreference> map) {
+
+    }
+
+    @Override
+    public void removeUserPreferences(String user) {
+
+    }
+
+    @Override
+    public Map<String, PortletPreference> getDefaultPreferences(org.apache.pluto.container.PortletWindow
portletWindow, PortletRequest portletRequest) throws PortletContainerException {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> getStoredPreferences(org.apache.pluto.container.PortletWindow
portletWindow, PortletRequest portletRequest) throws PortletContainerException {
+        return null;
+    }
+
+    @Override
+    public void store(org.apache.pluto.container.PortletWindow portletWindow, PortletRequest
portletRequest, Map<String, PortletPreference> map) throws PortletContainerException
{
+
+    }
+
+    @Override
+    public PreferencesValidator getPreferencesValidator(org.apache.pluto.container.om.portlet.PortletDefinition
portletDefinition) throws ValidatorException {
+        return null;
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/StubPortletPreferences.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/StubPortletPreferences.java?rev=1653148&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/StubPortletPreferences.java
(added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/java/org/apache/jetspeed/sso/StubPortletPreferences.java
Mon Jan 19 23:03:50 2015
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.jetspeed.sso;
+
+import org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider;
+import org.apache.jetspeed.components.portletpreferences.PreferencesException;
+import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.Preference;
+import org.apache.jetspeed.om.portlet.Preferences;
+import org.apache.pluto.container.PortletContainerException;
+import org.apache.pluto.container.PortletPreference;
+
+import javax.portlet.PortletRequest;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ValidatorException;
+import java.util.Map;
+import java.util.Set;
+
+public class StubPortletPreferences implements PortletPreferencesProvider {
+    @Override
+    public void preload() throws Exception {
+
+    }
+
+    @Override
+    public void preloadApplicationPreferences(String portletApplicationName) {
+
+    }
+
+    @Override
+    public void preloadUserPreferences() {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletDefinition pd, Preferences prefs) {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletDefinition pd, Preference preference) {
+
+    }
+
+    @Override
+    public void storeDefaults(PortletApplication app) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletDefinition pd) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletDefinition pd, String preferenceName) {
+
+    }
+
+    @Override
+    public void removeDefaults(PortletApplication app) {
+
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveDefaultPreferences(PortletDefinition
pd) {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveUserPreferences(PortletWindow window,
String userName) {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> retrieveEntityPreferences(PortletWindow window)
{
+        return null;
+    }
+
+    @Override
+    public void storeUserPreferences(Map<String, PortletPreference> map, PortletWindow
window, String userName) throws PreferencesException {
+
+    }
+
+    @Override
+    public void storeEntityPreferences(Map<String, PortletPreference> map, PortletWindow
window) throws PreferencesException {
+
+    }
+
+    @Override
+    public Set<String> getPortletWindowIds(PortletDefinition portletdefinition) {
+        return null;
+    }
+
+    @Override
+    public Set<String> getUserNames(PortletDefinition portletdefinition, String windowId)
{
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> getUserPreferences(PortletDefinition portletdefinition,
String windowId, String userName) {
+        return null;
+    }
+
+    @Override
+    public void storePortletPreference(PortletDefinition portletdefinition, String windowId,
String userName, Map<String, PortletPreference> map) {
+
+    }
+
+    @Override
+    public void storePortletPreference(String appName, String portletName, String windowId,
String userName, Map<String, PortletPreference> map) {
+
+    }
+
+    @Override
+    public void removeUserPreferences(String user) {
+
+    }
+
+    @Override
+    public Map<String, PortletPreference> getDefaultPreferences(org.apache.pluto.container.PortletWindow
portletWindow, PortletRequest portletRequest) throws PortletContainerException {
+        return null;
+    }
+
+    @Override
+    public Map<String, PortletPreference> getStoredPreferences(org.apache.pluto.container.PortletWindow
portletWindow, PortletRequest portletRequest) throws PortletContainerException {
+        return null;
+    }
+
+    @Override
+    public void store(org.apache.pluto.container.PortletWindow portletWindow, PortletRequest
portletRequest, Map<String, PortletPreference> map) throws PortletContainerException
{
+
+    }
+
+    @Override
+    public PreferencesValidator getPreferencesValidator(org.apache.pluto.container.om.portlet.PortletDefinition
portletDefinition) throws ValidatorException {
+        return null;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml?rev=1653148&r1=1653147&r2=1653148&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-sso/src/test/resources/cache-test.xml
Mon Jan 19 23:03:50 2015
@@ -329,5 +329,9 @@
         <meta key="j2:cat" value="default or cache"/>
         <constructor-arg><ref bean="ehPageManagerPrincipalPropertiesPathCache"/></constructor-arg>
     </bean>
-    
+
+    <bean id="org.apache.jetspeed.components.portletpreferences.PortletPreferencesProvider"
name="portletPreferencesProvider"
+          class="org.apache.jetspeed.sso.StubPortletPreferences">
+    </bean>
+
 </beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message