122. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:04 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.

122.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\jndi\dns DnsContextFactory.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\jndi\dns DnsContextFactory.java Wed Sep 12 16:27:25 2018 UTC

122.2 Comparison summary

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

122.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

122.4 Active regular expressions

No regular expressions were active.

122.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 200 0, 2011, 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.jndi .dns;
  27  
  28  
  29   import jav a.net.Malf ormedURLEx ception;
  30   import jav a.util.Arr ayList;
  31   import jav a.util.Has htable;
  32   import jav a.util.Lis t;
  33  
  34   import jav ax.naming. *;
  35   import jav ax.naming. spi.*;
  36  
  37   import com .sun.jndi. toolkit.ur l.UrlUtil;
  38   import sun .net.dns.R esolverCon figuration ;       //  available  since 1.4 .1
  39  
  40  
  41   /**
  42    * A DnsCo ntextFacto ry serves  as the ini tial conte xt factory  for DNS.
  43    *
  44    * <p> Whe n an initi al context  is being  created, t he environ ment
  45    * propert y "java.na ming.provi der.url" s hould cont ain a DNS  pseudo-URL
  46    * (see Dn sUrl) or a  space-sep arated lis t of them.   Multiple  URLs must
  47    * all hav e the same  domain va lue.
  48    * If the  property i s not set,  the defau lt "dns:"  is used.
  49    *
  50    * @author  Scott Sel igman
  51    */
  52  
  53  
  54   public cla ss DnsCont extFactory  implement s InitialC ontextFact ory {
  55  
  56       privat e static f inal Strin g DEFAULT_ URL = "dns :";
  57         private st atic final  int DEFAU LT_PORT      
;
  58  
  59  
  60       public  Context g etInitialC ontext(Has htable<?,? > env) thr ows Naming Exception  {
  61           if  (env == n ull) {
  62                env = ne w Hashtabl e<>(5);
  63           }
  64           re turn urlTo Context(ge tInitCtxUr l(env), en v);
  65       }
  66  
  67       public  static Dn sContext g etContext( String dom ain,
  68                                               String[] s ervers, Ha shtable<?, ?> env)
  69                throws N amingExcep tion {
  70           re turn new D nsContext( domain, se rvers, env );
  71       }
  72  
  73       /*
  74        * "ur ls" are us ed to dete rmine the  servers, b ut any dom ain
  75        * com ponents ar e overridd en by "dom ain".
  76        */
  77       public  static Dn sContext g etContext( String dom ain,
  78                                               DnsUrl[] u rls, Hasht able<?,?>  env)
  79                throws N amingExcep tion {
  80  
  81           St ring[] ser vers = ser versForUrl s(urls);
  82           Dn sContext c tx = getCo ntext(doma in, server s, env);
  83           if  (platform ServersUse d(urls)) {
  84                ctx.setP roviderUrl (construct ProviderUr l(domain,  servers));
  85           }
  86           re turn ctx;
  87       }
  88  
  89       /*
  90        * Pub lic for us e by produ ct test su ite.
  91        */
  92       public  static bo olean plat formServer sAvailable () {
  93           re turn !filt erNameServ ers(
  94                         ResolverCo nfiguratio n.open().n ameservers (), true
  95                    ).is Empty();
  96       }
  97  
  98       privat e static C ontext url ToContext( String url , Hashtabl e<?,?> env )
  99                throws N amingExcep tion {
  100  
  101           Dn sUrl[] url s;
  102           tr y {
  103                urls = D nsUrl.from List(url);
  104           }  catch (Mal formedURLE xception e ) {
  105                throw ne w Configur ationExcep tion(e.get Message()) ;
  106           }
  107           if  (urls.len gth == 0)  {
  108                throw ne w Configur ationExcep tion(
  109                         "Invalid D NS pseudo- URL(s): "  + url);
  110           }
  111           St ring domai n = urls[0 ].getDomai n();
  112  
  113           //  If multip le urls, a ll must ha ve the sam e domain.
  114           fo r (int i =  1; i < ur ls.length;  i++) {
  115                if (!dom ain.equals IgnoreCase (urls[i].g etDomain() )) {
  116                    thro w new Conf igurationE xception(
  117                             "Confl icting dom ains: " +  url);
  118                }
  119           }
  120           re turn getCo ntext(doma in, urls,  env);
  121       }
  122  
  123       /*
  124        * Ret urns all t he servers  specified  in a set  of URLs.
  125        * If  a URL has  no host (o r port), t he servers  configure d on the
  126        * und erlying pl atform are  used if p ossible.   If no conf igured
  127        * ser vers can b e found, t hen fall b ack to the  old behav ior of
  128        * usi ng "localh ost".
  129        * The re must be  at least  one URL.
  130        */
  131       privat e static S tring[] se rversForUr ls(DnsUrl[ ] urls)
  132                throws N amingExcep tion {
  133  
  134           if  (urls.len gth == 0)  {
  135                throw ne w Configur ationExcep tion("DNS  pseudo-URL  required" );
  136           }
  137  
  138           Li st<String>  servers =  new Array List<>();
  139  
  140           fo r (int i =  0; i < ur ls.length;  i++) {
  141                String s erver = ur ls[i].getH ost();
  142                int port  = urls[i] .getPort() ;
  143  
  144                if (serv er == null  && port <  0) {
  145                    // N o server o r port giv en, so loo k to under lying plat form.
  146                    // R esolverCon figuration  does some  limited c aching, so  the
  147                    // f ollowing i s reasonab ly efficie nt even if  called ra pid-fire.
  148                    List <String> p latformSer vers = fil terNameSer vers(
  149                         ResolverCo nfiguratio n.open().n ameservers (), false) ;
  150                    if ( !platformS ervers.isE mpty()) {
  151                         servers.ad dAll(platf ormServers );
  152                         continue;   // on to  next URL ( if any, wh ich is unl ikely)
  153                    }
  154                }
  155  
  156                if (serv er == null ) {
  157                    serv er = "loca lhost";
  158                }
  159                servers. add((port  < 0)
  160                             ? serv er
  161                             : serv er + ":" +  port);
  162           }
  163           re turn serve rs.toArray (new Strin g[servers. size()]);
  164       }
  165  
  166       /*
  167        * Ret urns true  if servers ForUrls(ur ls) would  make use o f servers
  168        * fro m the unde rlying pla tform.
  169        */
  170       privat e static b oolean pla tformServe rsUsed(Dns Url[] urls ) {
  171           if  (!platfor mServersAv ailable())  {
  172                return f alse;
  173           }
  174           fo r (int i =  0; i < ur ls.length;  i++) {
  175                if (urls [i].getHos t() == nul l &&
  176                    urls [i].getPor t() < 0) {
  177                    retu rn true;
  178                }
  179           }
  180           re turn false ;
  181       }
  182  
  183       /*
  184        * Ret urns a val ue for the  PROVIDER_ URL proper ty (space- separated  URL
  185        * Str ings) that  reflects  the given  domain and  servers.
  186        * Eac h server i s of the f orm "serve r[:port]".
  187        * The re must be  at least  one server .
  188        * IPv 6 literal  host names  include d elimiting  brackets.
  189        */
  190       privat e static S tring cons tructProvi derUrl(Str ing domain ,
  191                                                      Str ing[] serv ers) {
  192           St ring path  = "";
  193           if  (!domain. equals("." )) {
  194                try {
  195                    path  = "/" + U rlUtil.enc ode(domain , "ISO-885 9-1");
  196                } catch  (java.io.U nsupported EncodingEx ception e)  {
  197                    // a ssert fals e : "ISO-L atin-1 cha rset unava ilable";
  198                }
  199           }
  200  
  201           St ringBuffer  buf = new  StringBuf fer();
  202           fo r (int i =  0; i < se rvers.leng th; i++) {
  203                if (i >  0) {
  204                    buf. append(' ' );
  205                }
  206                buf.appe nd("dns:// ").append( servers[i] ).append(p ath);
  207           }
  208           re turn buf.t oString();
  209       }
  210  
  211       /*
  212        * Rea ds environ ment to fi nd URL(s)  of initial  context.
  213        * Def ault URL i s "dns:".
  214        */
  215       privat e static S tring getI nitCtxUrl( Hashtable< ?,?> env)  {
  216           St ring url =  (String)  env.get(Co ntext.PROV IDER_URL);
  217           re turn ((url  != null)  ? url : DE FAULT_URL) ;
  218       }
  219  
  220       /**
  221        * Rem oves any D NS server  that's not  permitted  to access
  222        * @pa ram input  the input  server[:po rt] list,  must not b e null
  223        * @pa ram oneIsE nough retu rn output  once there  exists on e ok
  224        * @re turn the f iltered li st, all no n-permitte d input re moved
  225        */
  226       privat e static L ist<String > filterNa meServers( List<Strin g> input,  boolean on eIsEnough)  {
  227           Se curityMana ger securi ty = Syste m.getSecur ityManager ();
  228           if  (security  == null | | input ==  null || i nput.isEmp ty()) {
  229                return i nput;
  230           }  else {
  231                List<Str ing> outpu t = new Ar rayList<>( );
  232                for (Str ing platfo rmServer:  input) {
  233                    int  colon = pl atformServ er.indexOf (':',
  234                             platfo rmServer.i ndexOf(']' ) + 1);
  235  
  236                    int  p = (colon  < 0)
  237                         ? DEFAULT_ PORT
  238                         : Integer. parseInt(
  239                             platfo rmServer.s ubstring(c olon + 1)) ;
  240                    Stri ng s = (co lon < 0)
  241                         ? platform Server
  242                         : platform Server.sub string(0,  colon);
  243                    try  {
  244                         security.c heckConnec t(s, p);
  245                         output.add (platformS erver);
  246                         if (oneIsE nough) {
  247                             return  output;
  248                         }
  249                    } ca tch (Secur ityExcepti on se) {
  250                         continue;
  251                    }
  252                }
  253                return o utput;
  254           }
  255       }
  256   }