@@ -71,6 +71,20 @@ public final class AuthorizationFramework {
71
71
*/
72
72
List <AuthorizationPluginWrapper > plugins ;
73
73
74
+ /**
75
+ * Keeping track of the number of reloads in this framework. This can be
76
+ * used by the plugins to invalidate the session and force reload the
77
+ * authorization values.
78
+ *
79
+ * Starting at 0 and increases with every reload.
80
+ *
81
+ * The plugin should call RuntimeEnvironment.getPluginVersion() to get this
82
+ * number.
83
+ *
84
+ * @see RuntimeEnvironment#getPluginVersion()
85
+ */
86
+ private int pluginVersion = 0 ;
87
+
74
88
/**
75
89
* Plugin directory is set through RuntimeEnvironment.
76
90
*
@@ -483,6 +497,9 @@ public Object run() {
483
497
// clean all plugins
484
498
removeAll ();
485
499
500
+ // increase the current plugin version tracked by the framework
501
+ increasePluginVersion ();
502
+
486
503
// add spaces with configured plugins - leaving null just to obtain the correct order of execution
487
504
for (AuthorizationCheck check : RuntimeEnvironment .getInstance ().getPluginConfiguration ()) {
488
505
plugins .add (new AuthorizationPluginWrapper (check , null ));
@@ -496,6 +513,39 @@ public Object run() {
496
513
loadAllPlugins ();
497
514
}
498
515
516
+ /**
517
+ * Returns the current plugins version in this framework. This can be used
518
+ * by the plugins to invalidate the session and force reload the
519
+ * authorization values.
520
+ *
521
+ * This number changes with every plugin reload.
522
+ *
523
+ * The plugin should call RuntimeEnvironment.getPluginVersion() to get this
524
+ * number and act upon if it needs to renew the session.
525
+ *
526
+ * @return the current version number
527
+ * @see RuntimeEnvironment#getPluginVersion()
528
+ */
529
+ public int getPluginVersion () {
530
+ return pluginVersion ;
531
+ }
532
+
533
+ /**
534
+ * Changes the plugin version to the next version.
535
+ */
536
+ public void increasePluginVersion () {
537
+ this .pluginVersion ++;
538
+ }
539
+
540
+ /**
541
+ * Sets the plugin version to an arbitrary number.
542
+ *
543
+ * @param pluginVersion the number
544
+ */
545
+ public void setPluginVersion (int pluginVersion ) {
546
+ this .pluginVersion = pluginVersion ;
547
+ }
548
+
499
549
/**
500
550
* Checks if the request should have an access to a resource.
501
551
*
0 commit comments