clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bblf...@apache.org
Subject svn commit: r1088522 - /incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java
Date Mon, 04 Apr 2011 09:29:27 GMT
Author: bblfish
Date: Mon Apr  4 09:29:27 2011
New Revision: 1088522

URL: http://svn.apache.org/viewvc?rev=1088522&view=rev
Log:
avoid a null pointer exception by testing for it. Reported by Reto in response to an exception
thrown by MailManPermissionTest after checking in code for CLEREZZA-479

Modified:
    incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java

Modified: incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java?rev=1088522&r1=1088521&r2=1088522&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java
(original)
+++ incubator/clerezza/trunk/parent/platform.security/src/main/java/org/apache/clerezza/platform/security/UserUtil.java
Mon Apr  4 09:29:27 2011
@@ -25,6 +25,7 @@ import java.security.PrivilegedActionExc
 import java.security.PrivilegedExceptionAction;
 import java.util.Collections;
 import java.util.Iterator;
+import java.util.Set;
 import javax.security.auth.Subject;
 import org.apache.clerezza.platform.security.auth.PrincipalImpl;
 
@@ -65,7 +66,9 @@ public class UserUtil {
 	 */
 	public static String getUserName(final AccessControlContext context) {
 		Subject subject = getSubject(context);
-		Iterator<Principal> iter = subject.getPrincipals().iterator();
+        Set<Principal> principals = subject.getPrincipals();
+        if (principals==null) return null;
+        Iterator<Principal> iter = principals.iterator();
 		String name = null;
 		if (iter.hasNext()) {
 				name = iter.next().getName();



Mime
View raw message