portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1685293 - /portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
Date Sat, 13 Jun 2015 17:35:22 GMT
Author: taylor
Date: Sat Jun 13 17:35:22 2015
New Revision: 1685293

URL: http://svn.apache.org/r1685293
Log:
JS2-1326: fixed bugs with Credential expiration processing in User Admin portlet

Modified:
    portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java

Modified: portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java?rev=1685293&r1=1685292&r2=1685293&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/branches/J2-ADMIN-BRANCH-2.2.2-POST-RELEASE/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
Sat Jun 13 17:35:22 2015
@@ -16,20 +16,6 @@
  */
 package org.apache.jetspeed.portlets.security;
 
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.portlet.PortletPreferences;
-import javax.security.auth.Subject;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.administration.PortalConfigurationConstants;
 import org.apache.jetspeed.audit.AuditActivity;
@@ -103,6 +89,19 @@ import org.apache.wicket.validation.vali
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.portlet.PortletPreferences;
+import javax.security.auth.Subject;
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
 /**
  * @author vkumar <a href="vkumar@apache.org">Vivek Kumar</a>
  */
@@ -120,8 +119,7 @@ public class JetspeedPrincipalManagement
     public static final String NEW_USER_TEMPLATE_DIR = "newUserTemplateDirectory";
     public static final String SUB_SITE_ROOT = "subsiteRootFolder";
 
-    private static final java.sql.Date MAX_DATE = java.sql.Date
-            .valueOf("8099-01-01");
+    private static final java.sql.Date MAX_DATE = java.sql.Date.valueOf("2099-01-01");
 
     private String principalParam;
 
@@ -1066,11 +1064,26 @@ public class JetspeedPrincipalManagement
                         if (expiredFlagStr != null)
                         {
                             if (!passwordSet
-                                    && expiredFlagStr.equals("expired"))
+                                    && expiredFlagStr.equalsIgnoreCase("active"))
{
+                                credential.setExpirationDate(null);
+                                credential.setExpired(false);
+                                getServiceLocator()
+                                        .getAuditActivity()
+                                        .logAdminCredentialActivity(
+                                                getPortletRequest()
+                                                        .getUserPrincipal()
+                                                        .getName(),
+                                                getIPAddress(),
+                                                getPrincipal().getName(),
+                                                AuditActivity.PASSWORD_ENABLED,
+                                                AdminPortletWebPage.USER_ADMINISTRATION);
+                            }
+                            else if (!passwordSet
+                                    && expiredFlagStr.equalsIgnoreCase("expired"))
                             {
-                                java.sql.Date today = new java.sql.Date(
-                                        new Date().getTime());
+                                java.sql.Date today = new java.sql.Date(new Date().getTime());
                                 credential.setExpirationDate(today);
+                                credential.setExpired(true);
                                 getServiceLocator()
                                         .getAuditActivity()
                                         .logAdminCredentialActivity(
@@ -1081,12 +1094,11 @@ public class JetspeedPrincipalManagement
                                                 getPrincipal().getName(),
                                                 AuditActivity.PASSWORD_EXPIRE,
                                                 AdminPortletWebPage.USER_ADMINISTRATION);
-                            } else if (expiredFlagStr.equals("extend"))
+                            } else if (expiredFlagStr.equalsIgnoreCase("extend"))
                             {
-                                // getUserManager().setPasswordExpiration(getUserName(),
-                                // null);
-                                // TODO confirm with Ate/David
-                                credential.setExpirationDate(MAX_DATE);
+                                long oneWeekExtension = System.currentTimeMillis() + (86400L
* 7L * 1000L);
+                                credential.setExpirationDate(new java.sql.Date(oneWeekExtension));
+                                credential.setExpired(false);
                                 getServiceLocator()
                                         .getAuditActivity()
                                         .logAdminCredentialActivity(
@@ -1097,9 +1109,10 @@ public class JetspeedPrincipalManagement
                                                 getPrincipal().getName(),
                                                 AuditActivity.PASSWORD_EXTEND,
                                                 AdminPortletWebPage.USER_ADMINISTRATION);
-                            } else if (expiredFlagStr.equals("unlimited"))
+                            } else if (expiredFlagStr.equalsIgnoreCase("unlimited"))
                             {
                                 credential.setExpirationDate(MAX_DATE);
+                                credential.setExpired(false);
                                 getServiceLocator()
                                         .getAuditActivity()
                                         .logAdminCredentialActivity(
@@ -1261,8 +1274,7 @@ public class JetspeedPrincipalManagement
                 setLastAuthenticationDate(credential
                         .getLastAuthenticationDate());
                 setCredentialExpirationDate(credential.getExpirationDate());
-                setUserExpiredFlag(credential.isExpired() ? "expired"
-                        : "active");
+                setUserExpiredFlag(credential.isExpired() ? "Expired" : "Active");
             }
             catch (SecurityException secExp)
             {



---------------------------------------------------------------------
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