107. EPMO Open Source Coordination Office Redaction File Detail Report

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.

107.1 Files compared

# 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\internal ServerNotifForwarder.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\internal ServerNotifForwarder.java Wed Sep 12 16:26:10 2018 UTC

107.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1010
Changed 1 2
Inserted 0 0
Removed 0 0

107.3 Comparison options

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

107.4 Active regular expressions

No regular expressions were active.

107.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 200 2, 2013, 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.int ernal;
  27  
  28   import com .sun.jmx.r emote.secu rity.Notif icationAcc essControl ler;
  29   import com .sun.jmx.r emote.util .ClassLogg er;
  30   import com .sun.jmx.r emote.util .EnvHelp;
  31   import jav a.io.IOExc eption;
  32   import jav a.security .AccessCon trolContex t;
  33   import jav a.security .AccessCon troller;
  34   import jav a.security .Privilege dActionExc eption;
  35   import jav a.security .Privilege dException Action;
  36   import jav a.util.Arr ayList;
  37   import jav a.util.Col lections;
  38   import jav a.util.Has hMap;
  39   import jav a.util.Has hSet;
  40   import jav a.util.Lis t;
  41   import jav a.util.Map ;
  42   import jav a.util.Set ;
  43   import jav ax.managem ent.Instan ceNotFound Exception;
  44   import jav ax.managem ent.Listen erNotFound Exception;
  45   import jav ax.managem ent.MBeanP ermission;
  46   import jav ax.managem ent.MBeanS erver;
  47   import jav ax.managem ent.MBeanS erverDeleg ate;
  48   import jav ax.managem ent.MBeanS erverNotif ication;
  49   import jav ax.managem ent.Notifi cation;
  50   import jav ax.managem ent.Notifi cationBroa dcaster;
  51   import jav ax.managem ent.Notifi cationFilt er;
  52   import jav ax.managem ent.Object Instance;
  53   import jav ax.managem ent.Object Name;
  54   import jav ax.managem ent.remote .Notificat ionResult;
  55   import jav ax.managem ent.remote .TargetedN otificatio n;
  56   import jav ax.managem ent.Malfor medObjectN ameExcepti on;
  57   import jav ax.securit y.auth.Sub ject;
  58  
  59   public cla ss ServerN otifForwar der {
  60  
  61  
  62       public  ServerNot ifForwarde r(MBeanSer ver mbeanS erver,
  63                                      Map<Stri ng, ?> env ,
  64                                      Notifica tionBuffer  notifBuff er,
  65                                      String c onnectionI d) {
  66           th is.mbeanSe rver = mbe anServer;
  67           th is.notifBu ffer = not ifBuffer;
  68           th is.connect ionId = co nnectionId ;
  69           co nnectionTi meout = En vHelp.getS erverConne ctionTimeo ut(env);
  70  
  71           St ring strin gBoolean =  (String)  env.get("j mx.remote. x.check.no tification .emission" );
  72           ch eckNotific ationEmiss ion = EnvH elp.comput eBooleanFr omString(  stringBool ean );
  73           no tification AccessCont roller =
  74                    EnvH elp.getNot ificationA ccessContr oller(env) ;
  75       }
  76  
  77       public  Integer a ddNotifica tionListen er(final O bjectName  name,
  78           fi nal Notifi cationFilt er filter)
  79           th rows Insta nceNotFoun dException , IOExcept ion {
  80  
  81           if  (logger.t raceOn())  {
  82                logger.t race("addN otificatio nListener" ,
  83                    "Add  a listene r at " + n ame);
  84           }
  85  
  86           ch eckState() ;
  87  
  88           //  Explicitl y check MB eanPermiss ion for ad dNotificat ionListene r
  89           //
  90           ch eckMBeanPe rmission(n ame, "addN otificatio nListener" );
  91           if  (notifica tionAccess Controller  != null)  {
  92                notifica tionAccess Controller .addNotifi cationList ener(
  93                    conn ectionId,  name, getS ubject());
  94           }
  95           tr y {
  96                boolean  instanceOf  =
  97                AccessCo ntroller.d oPrivilege d(
  98                         new Privil egedExcept ionAction< Boolean>()  {
  99                             public  Boolean r un() throw s Instance NotFoundEx ception {
  100                                 re turn mbean Server.isI nstanceOf( name, broa dcasterCla ss);
  101                             }
  102                });
  103                if (!ins tanceOf) {
  104                    thro w new Ille galArgumen tException ("The spec ified MBea n [" +
  105                         name + "]  is not a "  +
  106                         "Notificat ionBroadca ster " +
  107                         "object.") ;
  108                }
  109           }  catch (Pri vilegedAct ionExcepti on e) {
  110                throw (I nstanceNot FoundExcep tion) extr actExcepti on(e);
  111           }
  112  
  113           fi nal Intege r id = get ListenerID ();
  114  
  115           //  6238731:  set the de fault doma in if no d omain is s et.
  116           Ob jectName n n = name;
  117           if  (name.get Domain() = = null ||  name.getDo main().equ als("")) {
  118                try {
  119                    nn =  ObjectNam e.getInsta nce(mbeanS erver.getD efaultDoma in(),
  120                                                   name.g etKeyPrope rtyList()) ;
  121                } catch  (Malformed ObjectName Exception  mfoe) {
  122                    // i mpossible,  but...
  123                    IOEx ception io e = new IO Exception( mfoe.getMe ssage());
  124                    ioe. initCause( mfoe);
  125                    thro w ioe;
  126                }
  127           }
  128  
  129           sy nchronized  (listener Map) {
  130                IdAndFil ter idaf =  new IdAnd Filter(id,  filter);
  131                Set<IdAn dFilter> s et = liste nerMap.get (nn);
  132                // Tread  carefully  because i f set.size () == 1 it  may be th e
  133                // Colle ctions.sin gleton we  make here,  which is  unmodifiab le.
  134                if (set  == null)
  135                    set  = Collecti ons.single ton(idaf);
  136                else {
  137                    if ( set.size()  == 1)
  138                         set = new  HashSet<Id AndFilter> (set);
  139                    set. add(idaf);
  140                }
  141                listener Map.put(nn , set);
  142           }
  143  
  144           re turn id;
  145       }
  146  
  147       public  void remo veNotifica tionListen er(ObjectN ame name,
  148           In teger[] li stenerIDs)
  149           th rows Excep tion {
  150  
  151           if  (logger.t raceOn())  {
  152                logger.t race("remo veNotifica tionListen er",
  153                    "Rem ove some l isteners f rom " + na me);
  154           }
  155  
  156           ch eckState() ;
  157  
  158           //  Explicitl y check MB eanPermiss ion for re moveNotifi cationList ener
  159           //
  160           ch eckMBeanPe rmission(n ame, "remo veNotifica tionListen er");
  161           if  (notifica tionAccess Controller  != null)  {
  162                notifica tionAccess Controller .removeNot ificationL istener(
  163                    conn ectionId,  name, getS ubject());
  164           }
  165  
  166           Ex ception re  = null;
  167           fo r (int i =  0 ; i < l istenerIDs .length ;  i++) {
  168                try {
  169                    remo veNotifica tionListen er(name, l istenerIDs [i]);
  170                } catch  (Exception  e) {
  171                    // G ive back t he first e xception
  172                    //
  173                    if ( re != null ) {
  174                         re = e;
  175                    }
  176                }
  177           }
  178           if  (re != nu ll) {
  179                throw re ;
  180           }
  181       }
  182  
  183       public  void remo veNotifica tionListen er(ObjectN ame name,  Integer li stenerID)
  184       throws
  185           In stanceNotF oundExcept ion,
  186           Li stenerNotF oundExcept ion,
  187           IO Exception  {
  188  
  189           if  (logger.t raceOn())  {
  190                logger.t race("remo veNotifica tionListen er",
  191                    "Rem ove the li stener " +  listenerI D + " from  " + name) ;
  192           }
  193  
  194           ch eckState() ;
  195  
  196           if  (name !=  null && !n ame.isPatt ern()) {
  197                if (!mbe anServer.i sRegistere d(name)) {
  198                    thro w new Inst anceNotFou ndExceptio n("The MBe an " + nam e +
  199                         " is not r egistered. ");
  200                }
  201           }
  202  
  203           sy nchronized  (listener Map) {
  204                // Tread  carefully  because i f set.size () == 1 it  may be a
  205                // Colle ctions.sin gleton, wh ich is unm odifiable.
  206                Set<IdAn dFilter> s et = liste nerMap.get (name);
  207                IdAndFil ter idaf =  new IdAnd Filter(lis tenerID, n ull);
  208                if (set  == null ||  !set.cont ains(idaf) )
  209                    thro w new List enerNotFou ndExceptio n("Listene r not foun d");
  210                if (set. size() ==  1)
  211                    list enerMap.re move(name) ;
  212                else
  213                    set. remove(ida f);
  214           }
  215       }
  216  
  217       /* Thi s is the o bject that  will appl y our filt ering to c andidate
  218        * not ifications .  First o f all, if  there are  no listene rs for the
  219        * Obj ectName th at the not ification  is coming  from, we g o no furth er.
  220        * The n, for eac h listener , we must  apply the  correspond ing filter  (if any)
  221        * and  ignore th e listener  if the fi lter rejec ts.  Final ly, we app ly
  222        * som e access c hecks whic h may also  reject th e listener .
  223        *
  224        * A g iven notif ication ma y trigger  several li steners on  the same  MBean,
  225        * whi ch is why  listenerMa p is a Map <ObjectNam e, Set<IdA ndFilter>>  and
  226        * why  we add th e found no tification s to a sup plied List  rather th an
  227        * jus t returnin g a boolea n.
  228        */
  229       privat e final No tifForward erBufferFi lter buffe rFilter =  new NotifF orwarderBu fferFilter ();
  230  
  231       final  class Noti fForwarder BufferFilt er impleme nts Notifi cationBuff erFilter {
  232           pu blic void  apply(List <TargetedN otificatio n> targete dNotifs,
  233                               Obje ctName sou rce, Notif ication no tif) {
  234                // We pr oceed in t wo stages  here, to a void holdi ng the lis tenerMap
  235                // lock  while invo king the f ilters (wh ich are us er code).
  236                final Id AndFilter[ ] candidat es;
  237                synchron ized (list enerMap) {
  238                    fina l Set<IdAn dFilter> s et = liste nerMap.get (source);
  239                    if ( set == nul l) {
  240                         logger.deb ug("buffer Filter", " no listene rs for thi s name");
  241                         return;
  242                    }
  243                    cand idates = n ew IdAndFi lter[set.s ize()];
  244                    set. toArray(ca ndidates);
  245                }
  246                // We do n't synchr onize on t argetedNot ifs, becau se it is a  local
  247                // varia ble of our  caller an d no other  thread ca n see it.
  248                for (IdA ndFilter i daf : cand idates) {
  249                    fina l Notifica tionFilter  nf = idaf .getFilter ();
  250                    if ( nf == null  || nf.isN otificatio nEnabled(n otif)) {
  251                         logger.deb ug("buffer Filter", " filter mat ches");
  252                         final Targ etedNotifi cation tn  =
  253                                 ne w Targeted Notificati on(notif,  idaf.getId ());
  254                         if (allowN otificatio nEmission( source, tn ))
  255                             target edNotifs.a dd(tn);
  256                    }
  257                }
  258           }
  259       };
  260  
  261       public  Notificat ionResult  fetchNotif s(long sta rtSequence Number,
  262           lo ng timeout ,
  263           in t maxNotif ications)  {
  264           if  (logger.t raceOn())  {
  265                logger.t race("fetc hNotifs",  "Fetching  notificati ons, the "  +
  266                    "sta rtSequence Number is  " + startS equenceNum ber +
  267                    ", t he timeout  is " + ti meout +
  268                    ", t he maxNoti fications  is " + max Notificati ons);
  269           }
  270  
  271           No tification Result nr;
  272           fi nal long t  = Math.mi n(connecti onTimeout,  timeout);
  273           tr y {
  274                nr = not ifBuffer.f etchNotifi cations(bu fferFilter ,
  275                    star tSequenceN umber,
  276                    t, m axNotifica tions);
  277                snoopOnU nregister( nr);
  278           }  catch (Int erruptedEx ception ir e) {
  279                nr = new  Notificat ionResult( 0L, 0L, ne w Targeted Notificati on[0]);
  280           }
  281  
  282           if  (logger.t raceOn())  {
  283                logger.t race("fetc hNotifs",  "Forwardin g the noti fs: "+nr);
  284           }
  285  
  286           re turn nr;
  287       }
  288  
  289       // The  standard  RMI connec tor client  will regi ster a lis tener on t he MBeanSe rverDelega te
  290       // in  order to b e told whe n MBeans a re unregis tered.  We  snoop on  fetched no tification s
  291       // so  that we ca n know too , and remo ve the cor responding  entry fro m the list enerMap.
  292       // See  6957378.
  293       privat e void sno opOnUnregi ster(Notif icationRes ult nr) {
  294           Li st<IdAndFi lter> copy  = null;
  295           sy nchronized  (listener Map) {
  296                Set<IdAn dFilter> d elegateSet  = listene rMap.get(M BeanServer Delegate.D ELEGATE_NA ME);
  297                if (dele gateSet ==  null || d elegateSet .isEmpty() ) {
  298                    retu rn;
  299                }
  300                copy = n ew ArrayLi st<>(deleg ateSet);
  301           }
  302  
  303           fo r (Targete dNotificat ion tn : n r.getTarge tedNotific ations())  {
  304                Integer  id = tn.ge tListenerI D();
  305                for (IdA ndFilter i daf : copy ) {
  306                    if ( idaf.id ==  id) {
  307                         // This is  a notific ation from  the MBean ServerDele gate.
  308                         Notificati on n = tn. getNotific ation();
  309                         if (n inst anceof MBe anServerNo tification  &&
  310                                 n. getType(). equals(MBe anServerNo tification .UNREGISTR ATION_NOTI FICATION))  {
  311                             MBeanS erverNotif ication mb sn = (MBea nServerNot ification)  n;
  312                             Object Name gone  = mbsn.get MBeanName( );
  313                             synchr onized (li stenerMap)  {
  314                                 li stenerMap. remove(gon e);
  315                             }
  316                         }
  317                    }
  318                }
  319           }
  320       }
  321  
  322       public  void term inate() {
  323           if  (logger.t raceOn())  {
  324                logger.t race("term inate", "B e called." );
  325           }
  326  
  327           sy nchronized (terminati onLock) {
  328                if (term inated) {
  329                    retu rn;
  330                }
  331  
  332                terminat ed = true;
  333  
  334                synchron ized(liste nerMap) {
  335                    list enerMap.cl ear();
  336                }
  337           }
  338  
  339           if  (logger.t raceOn())  {
  340                logger.t race("term inate", "T erminated. ");
  341           }
  342       }
  343  
  344       //---- ---------- --
  345         // PRI D A N E S M   T   ODS
  346       //---- ---------- --
  347  
  348       privat e Subject  getSubject () {
  349           re turn Subje ct.getSubj ect(Access Controller .getContex t());
  350       }
  351  
  352       privat e void che ckState()  throws IOE xception {
  353           sy nchronized (terminati onLock) {
  354                if (term inated) {
  355                    thro w new IOEx ception("T he connect ion has be en termina ted.");
  356                }
  357           }
  358       }
  359  
  360       privat e Integer  getListene rID() {
  361           sy nchronized (listenerC ounterLock ) {
  362                return l istenerCou nter++;
  363           }
  364       }
  365  
  366       /**
  367        * Exp licitly ch eck the MB eanPermiss ion for
  368        * the  current a ccess cont rol contex t.
  369        */
  370       public  final voi d checkMBe anPermissi on(
  371                final Ob jectName n ame, final  String ac tions)
  372                throws I nstanceNot FoundExcep tion, Secu rityExcept ion {
  373           ch eckMBeanPe rmission(m beanServer ,name,acti ons);
  374       }
  375  
  376       static  void chec kMBeanPerm ission(
  377                final MB eanServer  mbs, final  ObjectNam e name, fi nal String  actions)
  378                throws I nstanceNot FoundExcep tion, Secu rityExcept ion {
  379  
  380           Se curityMana ger sm = S ystem.getS ecurityMan ager();
  381           if  (sm != nu ll) {
  382                AccessCo ntrolConte xt acc = A ccessContr oller.getC ontext();
  383                ObjectIn stance oi;
  384                try {
  385                    oi =  AccessCon troller.do Privileged (
  386                         new Privil egedExcept ionAction< ObjectInst ance>() {
  387                             public  ObjectIns tance run( )
  388                             throws  InstanceN otFoundExc eption {
  389                                 re turn mbs.g etObjectIn stance(nam e);
  390                             }
  391                    });
  392                } catch  (Privilege dActionExc eption e)  {
  393                    thro w (Instanc eNotFoundE xception)  extractExc eption(e);
  394                }
  395                String c lassname =  oi.getCla ssName();
  396                MBeanPer mission pe rm = new M BeanPermis sion(
  397                    clas sname,
  398                    null ,
  399                    name ,
  400                    acti ons);
  401                sm.check Permission (perm, acc );
  402           }
  403       }
  404  
  405       /**
  406        * Che ck if the  caller has  the right  to get th e followin g notifica tions.
  407        */
  408       privat e boolean  allowNotif icationEmi ssion(Obje ctName nam e,
  409                                                     Targ etedNotifi cation tn)  {
  410           tr y {
  411                if (chec kNotificat ionEmissio n) {
  412                    chec kMBeanPerm ission(nam e, "addNot ificationL istener");
  413                }
  414                if (noti ficationAc cessContro ller != nu ll) {
  415                    noti ficationAc cessContro ller.fetch Notificati on(
  416                             connec tionId, na me, tn.get Notificati on(), getS ubject());
  417                }
  418                return t rue;
  419           }  catch (Sec urityExcep tion e) {
  420                if (logg er.debugOn ()) {
  421                    logg er.debug(" fetchNotif s", "Notif ication "  +
  422                             tn.get Notificati on() + " n ot forward ed: the "  +
  423                             "calle r didn't h ave the re quired acc ess rights ");
  424                }
  425                return f alse;
  426           }  catch (Exc eption e)  {
  427                if (logg er.debugOn ()) {
  428                    logg er.debug(" fetchNotif s", "Notif ication "  +
  429                             tn.get Notificati on() + " n ot forward ed: " +
  430                             "got a n unexpect ed excepti on: " + e) ;
  431                }
  432                return f alse;
  433           }
  434       }
  435  
  436       /**
  437        * Ite rate until  we extrac t the real  exception
  438        * fro m a stack  of Privile gedActionE xceptions.
  439        */
  440       privat e static E xception e xtractExce ption(Exce ption e) {
  441           wh ile (e ins tanceof Pr ivilegedAc tionExcept ion) {
  442                e = ((Pr ivilegedAc tionExcept ion)e).get Exception( );
  443           }
  444           re turn e;
  445       }
  446  
  447       privat e static c lass IdAnd Filter {
  448           pr ivate Inte ger id;
  449           pr ivate Noti ficationFi lter filte r;
  450  
  451           Id AndFilter( Integer id , Notifica tionFilter  filter) {
  452                this.id  = id;
  453                this.fil ter = filt er;
  454           }
  455  
  456           In teger getI d() {
  457                return t his.id;
  458           }
  459  
  460           No tification Filter get Filter() {
  461                return t his.filter ;
  462           }
  463  
  464           @O verride
  465           pu blic int h ashCode()  {
  466                return i d.hashCode ();
  467           }
  468  
  469           @O verride
  470           pu blic boole an equals( Object o)  {
  471                return ( (o instanc eof IdAndF ilter) &&
  472                         ((IdAndFil ter) o).ge tId().equa ls(getId() ));
  473           }
  474       }
  475  
  476  
  477       //---- ---------- ----
  478       // PRI VATE VARIA BLES
  479       //---- ---------- ----
  480  
  481       privat e MBeanSer ver mbeanS erver;
  482  
  483       privat e final St ring conne ctionId;
  484  
  485       privat e final lo ng connect ionTimeout ;
  486  
  487       privat e static i nt listene rCounter =  0;
  488       privat e final st atic int[]  listenerC ounterLock  = new int [0];
  489  
  490       privat e Notifica tionBuffer  notifBuff er;
  491       privat e final Ma p<ObjectNa me, Set<Id AndFilter> > listener Map =
  492                new Hash Map<Object Name, Set< IdAndFilte r>>();
  493  
  494       privat e boolean  terminated  = false;
  495       privat e final in t[] termin ationLock  = new int[ 0];
  496  
  497       static  final Str ing broadc asterClass  =
  498           No tification Broadcaste r.class.ge tName();
  499  
  500       privat e final bo olean chec kNotificat ionEmissio n;
  501  
  502       privat e final No tification AccessCont roller not ificationA ccessContr oller;
  503  
  504       privat e static f inal Class Logger log ger =
  505           ne w ClassLog ger("javax .managemen t.remote.m isc", "Ser verNotifFo rwarder");
  506   }