Produced by Araxis Merge on 9/25/2018 2:13:02 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\remote\security | MBeanServerAccessController.java | Mon Jan 22 14:46:50 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\remote\security | MBeanServerAccessController.java | Wed Sep 12 16:26:15 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 1328 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |
2 | * Copyrig ht (c) 200 3, 2006, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | package co m.sun.jmx. remote.sec urity; | |
27 | ||
28 | import com .sun.jmx.m beanserver .GetProper tyAction; | |
29 | import jav a.io.Objec tInputStre am; | |
30 | import jav a.security .AccessCon troller; | |
31 | import jav a.util.Set ; | |
32 | import jav ax.managem ent.Attrib ute; | |
33 | import jav ax.managem ent.Attrib uteList; | |
34 | import jav ax.managem ent.Attrib uteNotFoun dException ; | |
35 | import jav ax.managem ent.Instan ceNotFound Exception; | |
36 | import jav ax.managem ent.Instan ceAlreadyE xistsExcep tion; | |
37 | import jav ax.managem ent.Intros pectionExc eption; | |
38 | import jav ax.managem ent.Invali dAttribute ValueExcep tion; | |
39 | import jav ax.managem ent.Listen erNotFound Exception; | |
40 | import jav ax.managem ent.MBeanE xception; | |
41 | import jav ax.managem ent.MBeanI nfo; | |
42 | import jav ax.managem ent.MBeanR egistratio nException ; | |
43 | import jav ax.managem ent.MBeanS erver; | |
44 | import jav ax.managem ent.NotCom pliantMBea nException ; | |
45 | import jav ax.managem ent.Notifi cationFilt er; | |
46 | import jav ax.managem ent.Notifi cationList ener; | |
47 | import jav ax.managem ent.Object Instance; | |
48 | import jav ax.managem ent.Object Name; | |
49 | import jav ax.managem ent.Operat ionsExcept ion; | |
50 | import jav ax.managem ent.QueryE xp; | |
51 | import jav ax.managem ent.Reflec tionExcept ion; | |
52 | import jav ax.managem ent.loadin g.ClassLoa derReposit ory; | |
53 | import jav ax.managem ent.remote .MBeanServ erForwarde r; | |
54 | ||
55 | /** | |
56 | * <p>An o bject of t his class implements the MBean Server int erface | |
57 | * and, fo r each of its method s, calls a n appropri ate checki ng method | |
58 | * and the n forwards the reque st to a wr apped MBea nServer ob ject. The | |
59 | * checkin g method m ay throw a RuntimeEx ception if the opera tion is | |
60 | * not all owed; in t his case t he request is not fo rwarded to the | |
61 | * wrapped object.</ p> | |
62 | * | |
63 | * <p>A ty pical use of this cl ass is to insert it between a connector server | |
64 | * such as the RMI c onnector a nd the MBe anServer w ith which the connec tor | |
65 | * is asso ciated. R equests fr om the con nector cli ent can th en be filt ered | |
66 | * and tho se operati ons that a re not all owed, or n ot allowed in a part icular | |
67 | * context , can be r ejected by throwing a <code>Se curityExce ption</cod e> | |
68 | * in the correspond ing <code> check*</co de> method .</p> | |
69 | * | |
70 | * <p>This is an abs tract clas s, because in its im plementati on none of | |
71 | * the che cking meth ods does a nything. To be usef ul, it mus t be | |
72 | * subclas sed and at least one of the ch ecking met hods overr idden to | |
73 | * do some checking. Some or all of the MBeanServ er methods may also | |
74 | * be over ridden, fo r instance if the de fault chec king behav ior is | |
75 | * inappro priate.</p > | |
76 | * | |
77 | * <p>If t here is no SecurityM anager, th en the acc ess contro ller will refuse | |
78 | * to crea te an MBea n that is a ClassLoa der, which includes MLets, or to | |
79 | * execute the metho d addURL o n an MBean that is a n MLet. Th is prevent s | |
80 | * people from openi ng securit y holes un intentiona lly. Other wise, it | |
81 | * would n ot be obvi ous that g ranting wr ite access grants th e ability to | |
82 | * downloa d and exec ute arbitr ary code i n the targ et MBean s erver. Adv anced | |
83 | * users w ho do want the abili ty to use MLets are presumably advanced enough | |
84 | * to hand le policy files and security m anagers.</ p> | |
85 | */ | |
86 | public abs tract clas s MBeanSer verAccessC ontroller | |
87 | im plements M BeanServer Forwarder { | |
88 | ||
89 | public MBeanServ er getMBea nServer() { | |
90 | re turn mbs; | |
91 | } | |
92 | ||
93 | public void setM BeanServer (MBeanServ er mbs) { | |
94 | if (mbs == n ull) | |
95 | throw ne w IllegalA rgumentExc eption("Nu ll MBeanSe rver"); | |
96 | if (this.mbs != null) | |
97 | throw ne w IllegalA rgumentExc eption("MB eanServer object alr eady " + | |
98 | "in itialized" ); | |
99 | th is.mbs = m bs; | |
100 | } | |
101 | ||
102 | /** | |
103 | * Che ck if the caller can do read o perations. This meth od does | |
104 | * not hing if so , otherwis e throws S ecurityExc eption. | |
105 | */ | |
106 | protec ted abstra ct void ch eckRead(); | |
107 | ||
108 | /** | |
109 | * Che ck if the caller can do write operations . This me thod does | |
110 | * not hing if so , otherwis e throws S ecurityExc eption. | |
111 | */ | |
112 | protec ted abstra ct void ch eckWrite() ; | |
113 | ||
114 | /** | |
115 | * Che ck if the caller can create th e named cl ass. The default | |
116 | * imp lementatio n of this method cal ls {@link #checkWrit e()}. | |
117 | */ | |
118 | protec ted void c heckCreate (String cl assName) { | |
119 | ch eckWrite() ; | |
120 | } | |
121 | ||
122 | /** | |
123 | * Che ck if the caller can unregiste r the name d MBean. The defaul t | |
124 | * imp lementatio n of this method cal ls {@link #checkWrit e()}. | |
125 | */ | |
126 | protec ted void c heckUnregi ster(Objec tName name ) { | |
127 | ch eckWrite() ; | |
128 | } | |
129 | ||
130 | //---- ---------- ---------- ---------- ---------- | |
131 | //---- ---------- ---------- ---------- ---------- | |
132 | // | |
133 | // Imp lementatio n of the M BeanServer interface | |
134 | // | |
135 | //---- ---------- ---------- ---------- ---------- | |
136 | //---- ---------- ---------- ---------- ---------- | |
137 | ||
138 | /** | |
139 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
140 | * wra pped objec t. | |
141 | */ | |
142 | public void addN otificatio nListener( ObjectName name, | |
143 | Notificati onListener listener, | |
144 | Notificati onFilter f ilter, | |
145 | Object han dback) | |
146 | th rows Insta nceNotFoun dException { | |
147 | ch eckRead(); | |
148 | ge tMBeanServ er().addNo tification Listener(n ame, liste ner, | |
149 | f ilter, han dback); | |
150 | } | |
151 | ||
152 | /** | |
153 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
154 | * wra pped objec t. | |
155 | */ | |
156 | public void addN otificatio nListener( ObjectName name, | |
157 | ObjectName listener, | |
158 | Notificati onFilter f ilter, | |
159 | Object han dback) | |
160 | th rows Insta nceNotFoun dException { | |
161 | ch eckRead(); | |
162 | ge tMBeanServ er().addNo tification Listener(n ame, liste ner, | |
163 | f ilter, han dback); | |
164 | } | |
165 | ||
166 | /** | |
167 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
168 | * wra pped objec t. | |
169 | */ | |
170 | public ObjectIns tance crea teMBean(St ring class Name, Obje ctName nam e) | |
171 | th rows | |
172 | Re flectionEx ception, | |
173 | In stanceAlre adyExistsE xception, | |
174 | MB eanRegistr ationExcep tion, | |
175 | MB eanExcepti on, | |
176 | No tCompliant MBeanExcep tion { | |
177 | ch eckCreate( className) ; | |
178 | Se curityMana ger sm = S ystem.getS ecurityMan ager(); | |
179 | if (sm == nu ll) { | |
180 | Object o bject = ge tMBeanServ er().insta ntiate(cla ssName); | |
181 | checkCla ssLoader(o bject); | |
182 | return g etMBeanSer ver().regi sterMBean( object, na me); | |
183 | } else { | |
184 | return g etMBeanSer ver().crea teMBean(cl assName, n ame); | |
185 | } | |
186 | } | |
187 | ||
188 | /** | |
189 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
190 | * wra pped objec t. | |
191 | */ | |
192 | public ObjectIns tance crea teMBean(St ring class Name, Obje ctName nam e, | |
193 | Ob ject param s[], Strin g signatur e[]) | |
194 | th rows | |
195 | Re flectionEx ception, | |
196 | In stanceAlre adyExistsE xception, | |
197 | MB eanRegistr ationExcep tion, | |
198 | MB eanExcepti on, | |
199 | No tCompliant MBeanExcep tion { | |
200 | ch eckCreate( className) ; | |
201 | Se curityMana ger sm = S ystem.getS ecurityMan ager(); | |
202 | if (sm == nu ll) { | |
203 | Object o bject = ge tMBeanServ er().insta ntiate(cla ssName, | |
204 | par ams, | |
205 | sig nature); | |
206 | checkCla ssLoader(o bject); | |
207 | return g etMBeanSer ver().regi sterMBean( object, na me); | |
208 | } else { | |
209 | return g etMBeanSer ver().crea teMBean(cl assName, n ame, | |
210 | pa rams, sign ature); | |
211 | } | |
212 | } | |
213 | ||
214 | /** | |
215 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
216 | * wra pped objec t. | |
217 | */ | |
218 | public ObjectIns tance crea teMBean(St ring class Name, | |
219 | Ob jectName n ame, | |
220 | Ob jectName l oaderName) | |
221 | th rows | |
222 | Re flectionEx ception, | |
223 | In stanceAlre adyExistsE xception, | |
224 | MB eanRegistr ationExcep tion, | |
225 | MB eanExcepti on, | |
226 | No tCompliant MBeanExcep tion, | |
227 | In stanceNotF oundExcept ion { | |
228 | ch eckCreate( className) ; | |
229 | Se curityMana ger sm = S ystem.getS ecurityMan ager(); | |
230 | if (sm == nu ll) { | |
231 | Object o bject = ge tMBeanServ er().insta ntiate(cla ssName, | |
232 | loa derName); | |
233 | checkCla ssLoader(o bject); | |
234 | return g etMBeanSer ver().regi sterMBean( object, na me); | |
235 | } else { | |
236 | return g etMBeanSer ver().crea teMBean(cl assName, n ame, loade rName); | |
237 | } | |
238 | } | |
239 | ||
240 | /** | |
241 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
242 | * wra pped objec t. | |
243 | */ | |
244 | public ObjectIns tance crea teMBean(St ring class Name, | |
245 | Ob jectName n ame, | |
246 | Ob jectName l oaderName, | |
247 | Ob ject param s[], | |
248 | St ring signa ture[]) | |
249 | th rows | |
250 | Re flectionEx ception, | |
251 | In stanceAlre adyExistsE xception, | |
252 | MB eanRegistr ationExcep tion, | |
253 | MB eanExcepti on, | |
254 | No tCompliant MBeanExcep tion, | |
255 | In stanceNotF oundExcept ion { | |
256 | ch eckCreate( className) ; | |
257 | Se curityMana ger sm = S ystem.getS ecurityMan ager(); | |
258 | if (sm == nu ll) { | |
259 | Object o bject = ge tMBeanServ er().insta ntiate(cla ssName, | |
260 | loa derName, | |
261 | par ams, | |
262 | sig nature); | |
263 | checkCla ssLoader(o bject); | |
264 | return g etMBeanSer ver().regi sterMBean( object, na me); | |
265 | } else { | |
266 | return g etMBeanSer ver().crea teMBean(cl assName, n ame, loade rName, | |
267 | pa rams, sign ature); | |
268 | } | |
269 | } | |
270 | ||
271 | /** | |
272 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
273 | * wra pped objec t. | |
274 | */ | |
275 | @Depre cated | |
276 | public ObjectInp utStream d eserialize (ObjectNam e name, by te[] data) | |
277 | th rows Insta nceNotFoun dException , Operatio nsExceptio n { | |
278 | ch eckRead(); | |
279 | re turn getMB eanServer( ).deserial ize(name, data); | |
280 | } | |
281 | ||
282 | /** | |
283 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
284 | * wra pped objec t. | |
285 | */ | |
286 | @Depre cated | |
287 | public ObjectInp utStream d eserialize (String cl assName, b yte[] data ) | |
288 | th rows Opera tionsExcep tion, Refl ectionExce ption { | |
289 | ch eckRead(); | |
290 | re turn getMB eanServer( ).deserial ize(classN ame, data) ; | |
291 | } | |
292 | ||
293 | /** | |
294 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
295 | * wra pped objec t. | |
296 | */ | |
297 | @Depre cated | |
298 | public ObjectInp utStream d eserialize (String cl assName, | |
299 | ObjectNam e loaderNa me, | |
300 | byte[] da ta) | |
301 | th rows | |
302 | In stanceNotF oundExcept ion, | |
303 | Op erationsEx ception, | |
304 | Re flectionEx ception { | |
305 | ch eckRead(); | |
306 | re turn getMB eanServer( ).deserial ize(classN ame, loade rName, dat a); | |
307 | } | |
308 | ||
309 | /** | |
310 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
311 | * wra pped objec t. | |
312 | */ | |
313 | public Object ge tAttribute (ObjectNam e name, St ring attri bute) | |
314 | th rows | |
315 | MB eanExcepti on, | |
316 | At tributeNot FoundExcep tion, | |
317 | In stanceNotF oundExcept ion, | |
318 | Re flectionEx ception { | |
319 | ch eckRead(); | |
320 | re turn getMB eanServer( ).getAttri bute(name, attribute ); | |
321 | } | |
322 | ||
323 | /** | |
324 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
325 | * wra pped objec t. | |
326 | */ | |
327 | public Attribute List getAt tributes(O bjectName name, Stri ng[] attri butes) | |
328 | th rows Insta nceNotFoun dException , Reflecti onExceptio n { | |
329 | ch eckRead(); | |
330 | re turn getMB eanServer( ).getAttri butes(name , attribut es); | |
331 | } | |
332 | ||
333 | /** | |
334 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
335 | * wra pped objec t. | |
336 | */ | |
337 | public ClassLoad er getClas sLoader(Ob jectName l oaderName) | |
338 | th rows Insta nceNotFoun dException { | |
339 | ch eckRead(); | |
340 | re turn getMB eanServer( ).getClass Loader(loa derName); | |
341 | } | |
342 | ||
343 | /** | |
344 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
345 | * wra pped objec t. | |
346 | */ | |
347 | public ClassLoad er getClas sLoaderFor (ObjectNam e mbeanNam e) | |
348 | th rows Insta nceNotFoun dException { | |
349 | ch eckRead(); | |
350 | re turn getMB eanServer( ).getClass LoaderFor( mbeanName) ; | |
351 | } | |
352 | ||
353 | /** | |
354 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
355 | * wra pped objec t. | |
356 | */ | |
357 | public ClassLoad erReposito ry getClas sLoaderRep ository() { | |
358 | ch eckRead(); | |
359 | re turn getMB eanServer( ).getClass LoaderRepo sitory(); | |
360 | } | |
361 | ||
362 | /** | |
363 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
364 | * wra pped objec t. | |
365 | */ | |
366 | public String ge tDefaultDo main() { | |
367 | ch eckRead(); | |
368 | re turn getMB eanServer( ).getDefau ltDomain() ; | |
369 | } | |
370 | ||
371 | /** | |
372 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
373 | * wra pped objec t. | |
374 | */ | |
375 | public String[] getDomains () { | |
376 | ch eckRead(); | |
377 | re turn getMB eanServer( ).getDomai ns(); | |
378 | } | |
379 | ||
380 | /** | |
381 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
382 | * wra pped objec t. | |
383 | */ | |
384 | public Integer g etMBeanCou nt() { | |
385 | ch eckRead(); | |
386 | re turn getMB eanServer( ).getMBean Count(); | |
387 | } | |
388 | ||
389 | /** | |
390 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
391 | * wra pped objec t. | |
392 | */ | |
393 | public MBeanInfo getMBeanI nfo(Object Name name) | |
394 | th rows | |
395 | In stanceNotF oundExcept ion, | |
396 | In trospectio nException , | |
397 | Re flectionEx ception { | |
398 | ch eckRead(); | |
399 | re turn getMB eanServer( ).getMBean Info(name) ; | |
400 | } | |
401 | ||
402 | /** | |
403 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
404 | * wra pped objec t. | |
405 | */ | |
406 | public ObjectIns tance getO bjectInsta nce(Object Name name) | |
407 | th rows Insta nceNotFoun dException { | |
408 | ch eckRead(); | |
409 | re turn getMB eanServer( ).getObjec tInstance( name); | |
410 | } | |
411 | ||
412 | /** | |
413 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
414 | * wra pped objec t. | |
415 | */ | |
416 | public Object in stantiate( String cla ssName) | |
417 | th rows Refle ctionExcep tion, MBea nException { | |
418 | ch eckCreate( className) ; | |
419 | re turn getMB eanServer( ).instanti ate(classN ame); | |
420 | } | |
421 | ||
422 | /** | |
423 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
424 | * wra pped objec t. | |
425 | */ | |
426 | public Object in stantiate( String cla ssName, | |
427 | Object par ams[], | |
428 | String sig nature[]) | |
429 | th rows Refle ctionExcep tion, MBea nException { | |
430 | ch eckCreate( className) ; | |
431 | re turn getMB eanServer( ).instanti ate(classN ame, param s, signatu re); | |
432 | } | |
433 | ||
434 | /** | |
435 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
436 | * wra pped objec t. | |
437 | */ | |
438 | public Object in stantiate( String cla ssName, Ob jectName l oaderName) | |
439 | th rows Refle ctionExcep tion, MBea nException , Instance NotFoundEx ception { | |
440 | ch eckCreate( className) ; | |
441 | re turn getMB eanServer( ).instanti ate(classN ame, loade rName); | |
442 | } | |
443 | ||
444 | /** | |
445 | * Cal l <code>ch eckCreate( className) </code>, t hen forwar d this met hod to the | |
446 | * wra pped objec t. | |
447 | */ | |
448 | public Object in stantiate( String cla ssName, Ob jectName l oaderName, | |
449 | Object par ams[], Str ing signat ure[]) | |
450 | th rows Refle ctionExcep tion, MBea nException , Instance NotFoundEx ception { | |
451 | ch eckCreate( className) ; | |
452 | re turn getMB eanServer( ).instanti ate(classN ame, loade rName, | |
453 | params , signatur e); | |
454 | } | |
455 | ||
456 | /** | |
457 | * Cal l <code>ch eckWrite() </code>, t hen forwar d this met hod to the | |
458 | * wra pped objec t. | |
459 | */ | |
460 | public Object in voke(Objec tName name , String o perationNa me, | |
461 | Objec t params[] , String s ignature[] ) | |
462 | th rows | |
463 | In stanceNotF oundExcept ion, | |
464 | MB eanExcepti on, | |
465 | Re flectionEx ception { | |
466 | ch eckWrite() ; | |
467 | ch eckMLetMet hods(name, operation Name); | |
468 | re turn getMB eanServer( ).invoke(n ame, opera tionName, params, si gnature); | |
469 | } | |
470 | ||
471 | /** | |
472 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
473 | * wra pped objec t. | |
474 | */ | |
475 | public boolean i sInstanceO f(ObjectNa me name, S tring clas sName) | |
476 | th rows Insta nceNotFoun dException { | |
477 | ch eckRead(); | |
478 | re turn getMB eanServer( ).isInstan ceOf(name, className ); | |
479 | } | |
480 | ||
481 | /** | |
482 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
483 | * wra pped objec t. | |
484 | */ | |
485 | public boolean i sRegistere d(ObjectNa me name) { | |
486 | ch eckRead(); | |
487 | re turn getMB eanServer( ).isRegist ered(name) ; | |
488 | } | |
489 | ||
490 | /** | |
491 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
492 | * wra pped objec t. | |
493 | */ | |
494 | public Set<Objec tInstance> queryMBea ns(ObjectN ame name, QueryExp q uery) { | |
495 | ch eckRead(); | |
496 | re turn getMB eanServer( ).queryMBe ans(name, query); | |
497 | } | |
498 | ||
499 | /** | |
500 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
501 | * wra pped objec t. | |
502 | */ | |
503 | public Set<Objec tName> que ryNames(Ob jectName n ame, Query Exp query) { | |
504 | ch eckRead(); | |
505 | re turn getMB eanServer( ).queryNam es(name, q uery); | |
506 | } | |
507 | ||
508 | /** | |
509 | * Cal l <code>ch eckWrite() </code>, t hen forwar d this met hod to the | |
510 | * wra pped objec t. | |
511 | */ | |
512 | public ObjectIns tance regi sterMBean( Object obj ect, Objec tName name ) | |
513 | th rows | |
514 | In stanceAlre adyExistsE xception, | |
515 | MB eanRegistr ationExcep tion, | |
516 | No tCompliant MBeanExcep tion { | |
517 | ch eckWrite() ; | |
518 | re turn getMB eanServer( ).register MBean(obje ct, name); | |
519 | } | |
520 | ||
521 | /** | |
522 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
523 | * wra pped objec t. | |
524 | */ | |
525 | public void remo veNotifica tionListen er(ObjectN ame name, | |
526 | Notific ationListe ner listen er) | |
527 | th rows Insta nceNotFoun dException , Listener NotFoundEx ception { | |
528 | ch eckRead(); | |
529 | ge tMBeanServ er().remov eNotificat ionListene r(name, li stener); | |
530 | } | |
531 | ||
532 | /** | |
533 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
534 | * wra pped objec t. | |
535 | */ | |
536 | public void remo veNotifica tionListen er(ObjectN ame name, | |
537 | Notific ationListe ner listen er, | |
538 | Notific ationFilte r filter, | |
539 | Object handback) | |
540 | th rows Insta nceNotFoun dException , Listener NotFoundEx ception { | |
541 | ch eckRead(); | |
542 | ge tMBeanServ er().remov eNotificat ionListene r(name, li stener, | |
543 | filter, handback); | |
544 | } | |
545 | ||
546 | /** | |
547 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
548 | * wra pped objec t. | |
549 | */ | |
550 | public void remo veNotifica tionListen er(ObjectN ame name, | |
551 | ObjectN ame listen er) | |
552 | th rows Insta nceNotFoun dException , Listener NotFoundEx ception { | |
553 | ch eckRead(); | |
554 | ge tMBeanServ er().remov eNotificat ionListene r(name, li stener); | |
555 | } | |
556 | ||
557 | /** | |
558 | * Cal l <code>ch eckRead()< /code>, th en forward this meth od to the | |
559 | * wra pped objec t. | |
560 | */ | |
561 | public void remo veNotifica tionListen er(ObjectN ame name, | |
562 | ObjectN ame listen er, | |
563 | Notific ationFilte r filter, | |
564 | Object handback) | |
565 | th rows Insta nceNotFoun dException , Listener NotFoundEx ception { | |
566 | ch eckRead(); | |
567 | ge tMBeanServ er().remov eNotificat ionListene r(name, li stener, | |
568 | filter, handback); | |
569 | } | |
570 | ||
571 | /** | |
572 | * Cal l <code>ch eckWrite() </code>, t hen forwar d this met hod to the | |
573 | * wra pped objec t. | |
574 | */ | |
575 | public void setA ttribute(O bjectName name, Attr ibute attr ibute) | |
576 | th rows | |
577 | In stanceNotF oundExcept ion, | |
578 | At tributeNot FoundExcep tion, | |
579 | In validAttri buteValueE xception, | |
580 | MB eanExcepti on, | |
581 | Re flectionEx ception { | |
582 | ch eckWrite() ; | |
583 | ge tMBeanServ er().setAt tribute(na me, attrib ute); | |
584 | } | |
585 | ||
586 | /** | |
587 | * Cal l <code>ch eckWrite() </code>, t hen forwar d this met hod to the | |
588 | * wra pped objec t. | |
589 | */ | |
590 | public Attribute List setAt tributes(O bjectName name, | |
591 | A ttributeLi st attribu tes) | |
592 | th rows Insta nceNotFoun dException , Reflecti onExceptio n { | |
593 | ch eckWrite() ; | |
594 | re turn getMB eanServer( ).setAttri butes(name , attribut es); | |
595 | } | |
596 | ||
597 | /** | |
598 | * Cal l <code>ch eckUnregis ter()</cod e>, then f orward thi s method t o the | |
599 | * wra pped objec t. | |
600 | */ | |
601 | public void unre gisterMBea n(ObjectNa me name) | |
602 | th rows Insta nceNotFoun dException , MBeanReg istrationE xception { | |
603 | ch eckUnregis ter(name); | |
604 | ge tMBeanServ er().unreg isterMBean (name); | |
605 | } | |
606 | ||
607 | //---- ---------- -- | |
608 | // PRI D A N E S M T ODS | |
609 | //---- ---------- -- | |
610 | ||
611 | privat e void che ckClassLoa der(Object object) { | |
612 | if (object i nstanceof ClassLoade r) | |
613 | throw ne w Security Exception( "Access de nied! Crea ting an " + | |
614 | "MBean tha t is a Cla ssLoader " + | |
615 | "is forbid den unless a securit y " + | |
616 | "manager i s installe d."); | |
617 | } | |
618 | ||
619 | privat e void che ckMLetMeth ods(Object Name name, String op eration) | |
620 | throws InstanceN otFoundExc eption { | |
621 | // Check if security m anager ins talled | |
622 | Se curityMana ger sm = S ystem.getS ecurityMan ager(); | |
623 | if (sm != nu ll) { | |
624 | return; | |
625 | } | |
626 | // Check for addURL an d getMBean sFromURL m ethods | |
627 | if (!operati on.equals( "addURL") && | |
628 | !ope ration.equ als("getMB eansFromUR L")) { | |
629 | return; | |
630 | } | |
631 | // Check if MBean is i nstance of MLet | |
632 | if (!getMBea nServer(). isInstance Of(name, | |
633 | "jav ax.managem ent.loadin g.MLet")) { | |
634 | return; | |
635 | } | |
636 | // Throw sec urity exce ption | |
637 | if (operatio n.equals(" addURL")) { // addUR L | |
638 | throw ne w Security Exception( "Access de nied! MLet method ad dURL " + | |
639 | "cannot be invoked u nless a se curity man ager is in stalled.") ; | |
640 | } else { // getMBeansF romURL | |
641 | // Wheth er or not calling ge tMBeansFro mURL is al lowed is c ontrolled | |
642 | // by th e value of the "jmx. remote.x.m let.allow. getMBeansF romURL" | |
643 | // syste m property . If the v alue of th is propert y is true, calling | |
644 | // the M Let's getM BeansFromU RL method is allowed . The defa ult value | |
645 | // for t his proper ty is fals e. | |
646 | final St ring propN ame = "jmx .remote.x. mlet.allow .getMBeans FromURL"; | |
647 | GetPrope rtyAction propAction = new Get PropertyAc tion(propN ame); | |
648 | String p ropValue = AccessCon troller.do Privileged (propActio n); | |
649 | boolean allowGetMB eansFromUR L = "true" .equalsIgn oreCase(pr opValue); | |
650 | if (!all owGetMBean sFromURL) { | |
651 | thro w new Secu rityExcept ion("Acces s denied! MLet metho d " + | |
652 | "getMB eansFromUR L cannot b e invoked unless a " + | |
653 | "secur ity manage r is insta lled or th e system p roperty " + | |
654 | "-Djmx .remote.x. mlet.allow .getMBeans FromURL=tr ue " + | |
655 | "is sp ecified.") ; | |
656 | } | |
657 | } | |
658 | } | |
659 | ||
660 | //---- ---------- ---- | |
661 | // PRI VATE VARIA BLES | |
662 | //---- ---------- ---- | |
663 | ||
664 | privat e MBeanSer ver mbs; | |
665 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.