Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes to work with security 3.1-SNAPSHOT

Changes to work with thread-safety changes made in security 3.1
  • Loading branch information...
commit 9aa7b92afcfc8de1827bef924f4b75cd66765cfb 1 parent e8434db
@scarlucci scarlucci authored
View
21 nexus-core/src/main/java/org/sonatype/nexus/security/NexusViewSecurityResource.java
@@ -36,8 +36,11 @@
import org.sonatype.security.model.Configuration;
import org.sonatype.security.realms.tools.AbstractDynamicSecurityResource;
import org.sonatype.security.realms.tools.ConfigurationManager;
+import org.sonatype.security.realms.tools.ConfigurationManagerAction;
import org.sonatype.security.realms.tools.DynamicSecurityResource;
import org.sonatype.sisu.goodies.eventbus.EventBus;
+
+import com.google.common.base.Throwables;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
@@ -162,7 +165,23 @@ public void onEvent( final RepositoryRegistryEventRemove event )
{
setDirty( true );
- configManager.cleanRemovedPrivilege( createPrivilegeId( event.getRepository().getId() ) );
+ try
+ {
+ configManager.runWrite(new ConfigurationManagerAction()
+ {
+ @Override
+ public void run()
+ throws Exception
+ {
+ configManager.cleanRemovedPrivilege( createPrivilegeId( event.getRepository().getId() ) );
+ }
+
+ });
+ }
+ catch(Exception e)
+ {
+ throw Throwables.propagate(e);
+ }
}
public void initialize()
View
27 nexus-core/src/main/java/org/sonatype/nexus/security/SecurityCleanupEventInspector.java
@@ -32,6 +32,9 @@
import org.sonatype.security.authorization.Privilege;
import org.sonatype.security.authorization.xml.SecurityXmlAuthorizationManager;
import org.sonatype.security.realms.tools.ConfigurationManager;
+import org.sonatype.security.realms.tools.ConfigurationManagerAction;
+
+import com.google.common.base.Throwables;
@Component( role = EventInspector.class, hint = "SecurityCleanupEventInspector" )
public class SecurityCleanupEventInspector
@@ -97,7 +100,7 @@ protected void cleanupPrivileges( String propertyId, String propertyValue )
{
Set<Privilege> privileges = security.listPrivileges();
- Set<String> removedIds = new HashSet<String>();
+ final Set<String> removedIds = new HashSet<String>();
for ( Privilege privilege : privileges )
{
@@ -111,10 +114,26 @@ protected void cleanupPrivileges( String propertyId, String propertyValue )
}
}
- for ( String privilegeId : removedIds )
+ try
+ {
+ configManager.runWrite(new ConfigurationManagerAction()
+ {
+ @Override
+ public void run()
+ throws Exception
+ {
+ for ( String privilegeId : removedIds )
+ {
+ configManager.cleanRemovedPrivilege( privilegeId );
+ }
+ configManager.save();
+ }
+
+ });
+ }
+ catch(Exception e)
{
- configManager.cleanRemovedPrivilege( privilegeId );
+ throw Throwables.propagate(e);
}
- configManager.save();
}
}
View
2  ...ugin/src/main/java/org/sonatype/security/rest/privileges/PrivilegeTypePlexusResource.java
@@ -58,7 +58,7 @@
public static final String RESOURCE_URI = "/privilege_types";
@Inject
- @Named( "resourceMerging" )
+ @Named( "default" )
private ConfigurationManager configurationManager;
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.