29
29
import java .lang .reflect .Method ;
30
30
import java .util .regex .Matcher ;
31
31
import java .util .regex .Pattern ;
32
+ import org .opensolaris .opengrok .authorization .AuthorizationFramework ;
32
33
import org .opensolaris .opengrok .configuration .Configuration ;
33
34
import org .opensolaris .opengrok .configuration .RuntimeEnvironment ;
34
35
@@ -53,6 +54,8 @@ public class ConfigMessage extends Message {
53
54
protected byte [] applyMessage (RuntimeEnvironment env ) throws IOException {
54
55
if (hasTag ("getconf" )) {
55
56
return env .getConfiguration ().getXMLRepresentationAsString ().getBytes ();
57
+ } else if (hasTag ("auth" ) && "reload" .equalsIgnoreCase (getText ())) {
58
+ AuthorizationFramework .getInstance ().reload ();
56
59
} else if (hasTag ("set" )) {
57
60
Matcher matcher = VARIABLE_PATTERN .matcher (getText ());
58
61
if (matcher .find ()) {
@@ -248,8 +251,9 @@ protected int toInteger(boolean b) {
248
251
public void validate () throws Exception {
249
252
if (toInteger (hasTag ("setconf" ))
250
253
+ toInteger (hasTag ("getconf" ))
254
+ + toInteger (hasTag ("auth" ))
251
255
+ 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" );
253
257
}
254
258
255
259
if (hasTag ("setconf" )) {
@@ -270,8 +274,15 @@ public void validate() throws Exception {
270
274
if (getTags ().size () != 1 ) {
271
275
throw new Exception ("The set message should be the only tag." );
272
276
}
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
+ }
273
284
} 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" );
275
286
}
276
287
277
288
super .validate ();
0 commit comments