Integrate LDAP and JCR
[lgpl/argeo-commons.git] / security / runtime / org.argeo.security.core / src / main / java / org / argeo / security / core / KeyBasedSystemExecutionService.java
index 2fc4388afbca2de6411e400bc7303ad2248caf38..01d760f12befc1ce88fa38eb37c4d308505c6a49 100644 (file)
@@ -39,11 +39,12 @@ public class KeyBasedSystemExecutionService implements SystemExecutionService {
                                                .authenticate(new InternalAuthentication(
                                                                systemAuthenticationKey));
                                securityContext.setAuthentication(auth);
-
-                               runnable.run();
-
-                               // remove the authentication
-                               securityContext.setAuthentication(null);
+                               try {
+                                       runnable.run();
+                               } finally {
+                                       // remove the authentication
+                                       securityContext.setAuthentication(null);
+                               }
                        }
                };
        }