river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sijs...@apache.org
Subject svn commit: r1400937 - /river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java
Date Mon, 22 Oct 2012 16:20:43 GMT
Author: sijskes
Date: Mon Oct 22 16:20:43 2012
New Revision: 1400937

URL: http://svn.apache.org/viewvc?rev=1400937&view=rev
Log:
added permission check.

Modified:
    river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java

Modified: river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java
URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java?rev=1400937&r1=1400936&r2=1400937&view=diff
==============================================================================
--- river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java (original)
+++ river/jtsk/trunk/src/org/apache/river/config/LocalHostLookup.java Mon Oct 22 16:20:43
2012
@@ -20,6 +20,8 @@ package org.apache.river.config;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.river.common.Beta;
@@ -52,17 +54,29 @@ public class LocalHostLookup
     private static synchronized LocalHostLookupProvider getProvider()
     {
         if( provider == null ) {
-            setProvider( new DefaultLocalHostLookupProvider() );
+            AccessController.doPrivileged( new PrivilegedAction<Object>() {
+                @Override
+                public Object run() 
+                {
+                    setProvider( new DefaultLocalHostLookupProvider() );
+                    return null; // nothing to return
+                }
+            });            
         }
         return provider ;
     }
 
     public static synchronized void setProvider(LocalHostLookupProvider prvdr )
     {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission( new RuntimePermission("setLocalHostLookupProvider") );
+        }
+        
         if( LocalHostLookup.provider != null ) {
             throw new RuntimeException( "provider already set" );
         }
-        
+      
         LocalHostLookup.provider = prvdr ;
 
         try {



Mime
View raw message