Skip to content

Commit e181bd2

Browse files
authored
Merge pull request #1592 from tulinkry/auth-reload
adding a tag to the config message to reload all authorization plugins
2 parents 4bf5e98 + c36f8e6 commit e181bd2

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

README.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,14 @@ Currently supported message types:
134134
and returns the empty statistics
135135
- "get" the application returns current statistics
136136
4) ConfigMessage (config)
137-
This message retrieves or sends a configuration to the webapp,
138-
depending on tag. "setconf" tag sends config to webapp and requires
139-
file as argument. "set" tag sets particular configuration option in the webapp.
140-
5) RefreshMessage (refresh)
137+
This message performs some configuration communication with the webapp,
138+
depending on tag.
139+
- "setconf" tag sends config to webapp and requires a file as an argument.
140+
- "getconf" tag retrieves the configuration from the webapp.
141+
- "set" tag sets particular configuration option in the webapp.
142+
- "auth" tag requires "reload" text and
143+
reloads all authorization plugins.
144+
5) RefreshMesssage (refresh)
141145
Sent at the end of partial reindex to trigger refresh of SearcherManagers.
142146

143147
4. OpenGrok install

src/org/opensolaris/opengrok/configuration/messages/ConfigMessage.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.reflect.Method;
3030
import java.util.regex.Matcher;
3131
import java.util.regex.Pattern;
32+
import org.opensolaris.opengrok.authorization.AuthorizationFramework;
3233
import org.opensolaris.opengrok.configuration.Configuration;
3334
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
3435

@@ -53,6 +54,8 @@ public class ConfigMessage extends Message {
5354
protected byte[] applyMessage(RuntimeEnvironment env) throws IOException {
5455
if (hasTag("getconf")) {
5556
return env.getConfiguration().getXMLRepresentationAsString().getBytes();
57+
} else if (hasTag("auth") && "reload".equalsIgnoreCase(getText())) {
58+
AuthorizationFramework.getInstance().reload();
5659
} else if (hasTag("set")) {
5760
Matcher matcher = VARIABLE_PATTERN.matcher(getText());
5861
if (matcher.find()) {
@@ -248,8 +251,9 @@ protected int toInteger(boolean b) {
248251
public void validate() throws Exception {
249252
if (toInteger(hasTag("setconf"))
250253
+ toInteger(hasTag("getconf"))
254+
+ toInteger(hasTag("auth"))
251255
+ toInteger(hasTag("set")) > 1) {
252-
throw new Exception("The message tag must be either setconf, getconf or set");
256+
throw new Exception("The message tag must be either setconf, getconf, auth or set");
253257
}
254258

255259
if (hasTag("setconf")) {
@@ -270,8 +274,15 @@ public void validate() throws Exception {
270274
if (getTags().size() != 1) {
271275
throw new Exception("The set message should be the only tag.");
272276
}
277+
} else if (hasTag("auth")) {
278+
if (!"reload".equalsIgnoreCase(getText())) {
279+
throw new Exception("The auth message can only accept a text \"reload\".");
280+
}
281+
if (getTags().size() != 1) {
282+
throw new Exception("The auth message should be the only tag.");
283+
}
273284
} else {
274-
throw new Exception("The message tag must be either setconf, getconf or set");
285+
throw new Exception("The message tag must be either setconf, getconf, auth or set");
275286
}
276287

277288
super.validate();

0 commit comments

Comments
 (0)