Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove SecurityManager references #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static boolean isSupported()
// caller context; virtual threads have no permissions
// when executing code that performs a privileged
// action.
return System.getSecurityManager() == null;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,20 +620,6 @@ protected void bindService(com.tangosol.coherence.component.util.daemon.queuePro
(List) config.getServiceFilterMap().get(sServiceType));
}

/**
* Security check.
*/
protected void checkShutdownPermission()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(
new LocalPermission("Cluster.shutdown"));
}
}

// From interface: com.tangosol.net.Cluster
/**
Expand Down Expand Up @@ -3357,7 +3343,6 @@ public synchronized void shutdown()
case STATE_RUNNING:
try
{
checkShutdownPermission();

// shutdown services in reverse order (i.e. shut down system services last)
setState(STATE_LEAVING);
Expand Down Expand Up @@ -3567,7 +3552,6 @@ public synchronized void stop()

if (getState() != STATE_EXITED)
{
checkShutdownPermission();

setState(STATE_STOPPING);
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,13 +813,7 @@ protected RuntimeException ensureRuntimeException(Exception e, String sName, Str
public Object execute(com.tangosol.util.function.Remote.Function function)
{
// import com.tangosol.util.Base;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(EXECUTE_PERMISSION);
}


return executeInternal(function, /*continuation*/ null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,16 +361,7 @@ public Object removeInternalValueDecoration(Object oValue, int nDecorId)
* The ClassLoader associated with this context.
*/
public void setClassLoader(ClassLoader loader)
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(
new LocalPermission("BackingMapManagerContext.setClassLoader"));
}

{
__m_ClassLoader = (loader);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,7 @@ public com.oracle.coherence.common.base.Disposable unregisterResource(String sNa
return ((com.tangosol.net.Cluster) getRunningCluster()).unregisterResource(sName);
}
//-- com.tangosol.net.Cluster integration

private void checkInternalAccess()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(LocalPermission.INTERNAL_SERVICE);
}
}

protected void cleanup()
{
setInternalCluster(null);
Expand Down Expand Up @@ -588,9 +577,7 @@ public com.tangosol.coherence.component.net.Cluster ensureRunningCluster()
// import Component.Net.Cluster;
// import Component.Net.Management.Gateway;
// import com.tangosol.net.management.Registry;

checkInternalAccess();


Cluster cluster = getInternalCluster();
if (cluster == null || !cluster.isRunning())
{
Expand Down Expand Up @@ -722,9 +709,7 @@ public com.tangosol.net.Service ensureService(String sName, String sType)
action.setServiceName(sName);
action.setServiceType(sType);

return (Service) (System.getSecurityManager() == null
? action.run()
: AccessController.doPrivileged(new DoAsAction(action)));
return (Service) action.run();
}

// From interface: com.oracle.coherence.common.base.Lockable
Expand Down Expand Up @@ -755,7 +740,6 @@ public com.tangosol.coherence.config.builder.ParameterizedBuilderRegistry getBui
*/
public com.tangosol.coherence.component.net.Cluster getCluster()
{
checkInternalAccess();

return getInternalCluster();
}
Expand Down Expand Up @@ -955,15 +939,8 @@ public com.tangosol.coherence.component.net.Cluster getRunningCluster()
{
// import Component.Net.Cluster;
// import com.tangosol.net.security.DoAsAction;
// import java.security.AccessController;

if (System.getSecurityManager() == null)
{
return ensureRunningCluster();
}

return (Cluster) AccessController.doPrivileged(
new DoAsAction(getEnsureClusterAction()));
}

// Accessor for the property "ScopedServiceStore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -749,18 +749,7 @@ public int characteristics()

return MapListener.ASYNCHRONOUS | MapListener.VERSION_AWARE;
}

private void checkInternalAccess()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(LocalPermission.INTERNAL_SERVICE);
}
}

// From interface: com.tangosol.net.NamedCache
public void destroy()
{
Expand Down Expand Up @@ -848,7 +837,6 @@ public com.tangosol.net.NamedCache ensureRunningNamedCache()
{
// import com.tangosol.net.NamedCache;

checkInternalAccess();

NamedCache cache = getInternalNamedCache();
SafeService serviceSafe = getSafeCacheService();
Expand Down Expand Up @@ -1030,8 +1018,7 @@ public java.util.concurrent.locks.ReentrantLock getLock()
*/
public com.tangosol.net.NamedCache getNamedCache()
{
checkInternalAccess();


return getInternalNamedCache();
}

Expand Down Expand Up @@ -1162,15 +1149,8 @@ protected com.tangosol.net.NamedCache getRunningNamedCache()
{
// import com.tangosol.net.NamedCache;
// import com.tangosol.net.security.DoAsAction;
// import java.security.AccessController;

if (System.getSecurityManager() == null)
{
return ensureRunningNamedCache();
}

return (NamedCache) AccessController.doPrivileged(
new DoAsAction(getEnsureCacheAction()));
}

// Accessor for the property "SafeAsyncNamedCache"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@ public java.util.Set getSubscriberGroups()
}
//-- com.tangosol.net.topic.NamedTopic integration

private void checkInternalAccess()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(LocalPermission.INTERNAL_SERVICE);
}
}

// From interface: com.tangosol.net.topic.NamedTopic
public com.tangosol.net.topic.Publisher createPublisher(com.tangosol.net.topic.Publisher.Option[] options)
Expand Down Expand Up @@ -422,9 +412,7 @@ public void ensureLocked()
public com.tangosol.net.topic.NamedTopic ensureRunningNamedTopic()
{
// import com.tangosol.net.topic.NamedTopic;

checkInternalAccess();


NamedTopic topic = getInternalNamedTopic();
SafeService serviceSafe = getSafeTopicService();

Expand Down Expand Up @@ -542,8 +530,7 @@ public String getName()
*/
public com.tangosol.net.topic.NamedTopic getNamedTopic()
{
checkInternalAccess();


return getInternalNamedTopic();
}

Expand Down Expand Up @@ -574,15 +561,8 @@ protected com.tangosol.net.topic.NamedTopic getRunningNamedTopic()
{
// import com.tangosol.net.topic.NamedTopic;
// import com.tangosol.net.security.DoAsAction;
// import java.security.AccessController;

if (System.getSecurityManager() == null)
{
return ensureRunningNamedTopic();
}

return (NamedTopic) AccessController.doPrivileged(
new DoAsAction(getEnsureTopicAction()));
}

// Accessor for the property "SafeTopicService"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,7 @@ protected void checkClientThread(String sMethod)
}
}
}

private void checkInternalAccess()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(LocalPermission.INTERNAL_SERVICE);
}
}

protected void cleanup()
{
// import com.tangosol.util.SimpleResourceRegistry;
Expand Down Expand Up @@ -579,9 +568,7 @@ public com.tangosol.net.Service ensureRunningService()
// import com.tangosol.net.InvocationService;
// import com.tangosol.net.ProxyService;
// import com.tangosol.net.Service;

checkInternalAccess();


Service service = getInternalService();
if (service == null || !service.isRunning())
{
Expand Down Expand Up @@ -763,15 +750,7 @@ public com.tangosol.util.Service getRunningService()
{
// import com.tangosol.net.Service;
// import com.tangosol.net.security.DoAsAction;
// import java.security.AccessController;

if (System.getSecurityManager() == null)
{
return ensureRunningService();
}

return (Service) AccessController.doPrivileged(
new DoAsAction(getEnsureServiceAction()));
}

// Accessor for the property "SafeCluster"
Expand Down Expand Up @@ -804,8 +783,7 @@ public int getSafeServiceState()
*/
public com.tangosol.net.Service getService()
{
checkInternalAccess();


return getInternalService();
}

Expand Down Expand Up @@ -1151,14 +1129,7 @@ public void setContextClassLoader(ClassLoader loader)
{
// import com.tangosol.net.security.LocalPermission;
// import com.tangosol.net.Service;

SecurityManager security = System.getSecurityManager();
if (security != null && loader != null)
{
security.checkPermission(
new LocalPermission("BackingMapManagerContext.setClassLoader"));
}


__m_ContextClassLoader = (loader);

Service service = getInternalService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,7 @@ public void setThread(Thread thread)
public void unregister()
{
// import com.tangosol.net.security.DoAsAction;
// import java.security.AccessController;

if (System.getSecurityManager() == null)
{
unregisterInternal();
}
else
{
AccessController.doPrivileged(
new DoAsAction((ShutdownHook.UnregisterAction) _newChild("UnregisterAction")));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,20 +770,6 @@ public long calculateRequestTimeout(com.tangosol.coherence.component.net.message
return cTimeoutMillis;
}

/**
* Security check.
*/
protected void checkShutdownPermission()
{
// import com.tangosol.net.security.LocalPermission;

SecurityManager security = System.getSecurityManager();
if (security != null)
{
security.checkPermission(
new LocalPermission("Cluster.shutdown"));
}
}

// Declared at the super level
/**
Expand Down Expand Up @@ -4955,7 +4941,6 @@ public synchronized void shutdown()
{
if (getServiceState() < SERVICE_STOPPING)
{
checkShutdownPermission();

// send the request to shut down
send(instantiateMessage("NotifyShutdown"));
Expand Down Expand Up @@ -5019,9 +5004,7 @@ public synchronized void start()
public void stop()
{
// import com.tangosol.internal.util.NullMessagePublisher;

checkShutdownPermission();


setMessagePublisher(NullMessagePublisher.INSTANCE); // prevent further external communication

super.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24136,9 +24136,7 @@ public com.tangosol.util.InvocableMap.Entry getReadOnlyEntry(Object oKey)
Storage storage = getStorage();
Map mapStatus = (Map) ctx.getStorageStatusMap().get(storage);

Map mapResource = System.getSecurityManager() == null
? storage.getBackingMapInternal()
: (Map) AccessController.doPrivileged(new DoAsAction(storage.getBackingMapAction()));
Map mapResource = storage.getBackingMapInternal();

Storage.EntryStatus status = mapStatus == null ? null : (Storage.EntryStatus) mapStatus.get((Binary) oKey);

Expand Down
Loading