Abstract:
A computer program product is for use with a computer system that executes methods. Scope permission setting computer readable program code includes access request reception computer readable program code for receiving a request from a first method, executing at a first security level, to be dynamically empowered to access methods to be executed at a second security level, wherein the second security level is higher than the first security level. Dynamic capability activation computer readable program code is responsive to the access request reception code and includes static capability determination computer readable program code for determining if the first method is statically capable of accessing security methods generally and dynamic capability indication computer readable program code, responsive to the static capability determination code, for indicating in the activation record for the first method that the first method has been dynamically empowered to access security methods generally. Dynamic capability determination computer readable code, responsive to a request by the first method to access a particular security method, is for determining whether the activation record created for the first method includes an indication that the first method is capable of accessing security methods generally.

Description:
COPYRIGHT NOTICE 
     A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. 
     TECHNICAL FIELD 
     The present invention relates to security for Java systems and, in particular, to a method by which Java methods may gain access to restricted resources of a Java system. 
     BACKGROUND 
     Java is an object-oriented language that provides for building &#34;applets&#34; (pieces of networked software included, for example, in hyper-text markup language documents) and standalone applications. Java software consists of objects, where every &#34;object&#34; belongs to a &#34;class&#34;. A class defines a template for the object. That is, from a class definition, multiple objects can be instantiated. Each instance of an object retains its own internal states (e.g., states of local variables) and interfaces. 
     Referring to FIG. 1, the Java methods are typically executed on a local computer (e.g., local client #1 150a; local client #2 150b; and local client #3 150c), connected to a server computer 102 of a computer network 100 (such as the internet). The server computer 102 has its own storage 104, and the local computer also has its own storage (e.g., local client #1 150a has local storage 154a; local client #2 150b has local storage 154b; and local client #3 150c has local storage 154c). 
     Class definitions are loaded into a Java system executing on the local computer using a class loader. (The discussion will use local client #1 150a as an example local computer.) When a new class is loaded into the Java system executing on the local computer 150a of the network 100, the class is associated with either the local computer 150a, or with the network 100 generally. Typically, objects of classes associated with the local computer 150a are located on the local hard drive 154a, and their classes are accessed without a class loader. Objects of classes accessed without a class loader have &#34;superpowers&#34; that allow these objects unrestricted access to the resources of the local computer 150a. A significant resource of the local computer 150a to which these objects have access is the file system on the local hard drive 154a. 
     This is in contrast to objects whose classes are loaded via a universal resource locator (URL) definition (even those classes on the local hard drive loaded via a URL that includes &#34;file://&#34;), whose access privileges are regulated by the AppletSecurity class of the Java system. The AppletSecurity class is a class that throws an exception when Java security policy has been violated. Specifically, classes that are loaded via the Java &#34;class path&#34; (i.e., located in the local file system at a location defined by the CLASSPATH environment variable) are loaded without a class loader, and objects of these classes have unrestricted access. As a result, the objects of classes accessed via the CLASSPATH may accidentally subvert the Java security policy. Many (if not all) of the Java &#34;system library&#34; classes are located via the CLASSPATH environment variable. By contrast, objects of classes loaded via a universal resource locator, or &#34;URL&#34;, do not have these superpowers. 
     The task of ensuring that the classes accessed via the CLASSPATH environment variable do not violate the Java security policy, even if only accidentally, is an ergonomic nightmare. Not only must the &#34;security&#34; code (i.e., code that accesses important system resources) be checked for violations but, code that calls the &#34;security&#34; code must also be checked. 
     SUMMARY 
     In accordance with the present invention, a computer program product is provided for use with a computer system that executes methods. The computer program product includes scope permission setting computer readable program code means. 
     The scope permission setting computer readable program means includes access request reception computer readable program code means for receiving a request from a first method, executing at a first security level, to be dynamically empowered to access methods to be executed at a second security level, wherein the second security level is higher than the first security level. 
     Dynamic capability activation computer readable program code means is provided, responsive to the access request reception code means. The dynamic capability activation computer readable program code means includes static capability determination computer readable program code means for determining if the first method is statically capable of accessing security methods to be executed at at least a second security level. The dynamic capability activation computer readable program code means further includes dynamic capability indication computer readable program code means, responsive to the static capability determination code means, for indicating in the activation record for the first method that the first method has been dynamically empowered to access security methods generally. 
     Dynamic capability determination computer readable code means is provided, responsive to a request by the first method to access a particular security method, for determining whether the activation record created for the first method includes an indication that the first method is capable of accessing security methods generally. 
    
    
     BRIEF DESCRIPTION OF THE FIGURES 
     FIG. 1 illustrates how Java methods are distributed and executed in computer network. 
     FIG. 2 illustrates steps taken by a method to activate &#34;superpowers&#34; powers. 
     FIG. 3 illustrates steps taken by Java security code when a method attempts to access restricted resources. 
     FIG. 4 illustrates a calling sequence of various Java methods. 
    
    
     DETAILED DESCRIPTION 
     In accordance with the invention, objects of classes loaded from the hard drive of a local client computer, after being found via the CLASSPATH are not automatically given superpowers to access restricted resources. Rather, objects of these classes are must proactively request superpowers. In accordance with the invention, objects of classes loaded via the CLASSPATH must &#34;activate&#34; their superpowers in a specific stack frame (that is, within a particular instantiation of a method object) by indicating in the stack frame for the method object that the method object has been empowered to access restricted resources. That is, an object of a class loaded via the CLASSPATH can be likened to &#34;Clark Kent&#34;. A &#34;Clark Kent&#34; method object becomes a &#34;Superman&#34; method object when it indicates in its stack frame that it has activated its &#34;superpowers&#34;. Another analogy is that method objects of classes loaded via the CLASSPATH are allowed to carry guns, but they are no longer required to carry the guns loaded and cocked at all times. 
     From a programmer&#39;s perspective, this is a vast improvement, in that it is much less likely that an applet will include a security flaw. From a security audit perspective, it is now possible to &#34;grep&#34; for code that, when executed, will cause an indication in the stack frame for the method that the method has activated its superpowers. By contrast, &#34;wimpy&#34; method objects have been loaded via a &#34;URL&#34; and can never attain superpower status. 
     In accordance with a preferred embodiment of the invention, an object of a class may &#34;inherit&#34; superpowers from its caller, rather than having to explicitly activate its own superpowers. This facilitates the writing of code for objects that can work both on behalf of classes loaded via the CLASSPATH (e.g., system classes) and also on behalf of applet classes. Thus, the Java security system in accordance with the preferred embodiment of the invention, rather than asking just if a method that requests access to restricted resources is superpowered, also checks to see if the method is potentially superpowered. If so, the Java security system checks the stack frames of methods further up in the calling thread of the method that requests access to restricted resources. 
     The preferred embodiment thus protects against &#34;luring&#34; attacks, where an attacker method object may lure an innocent (and superpowered) thread into calling an attacker&#39;s code. In accordance with the preferred embodiment of the invention, the attacker&#39;s code would be considered to be &#34;wimpy&#34; applet code that could never be superpowered and, hence, would neutralize any powers that were indicated in the caller&#39;s stack frame. 
     Details of an embodiment of the invention are now discussed with reference to FIGS. 2 through 4. FIG. 2 is a flow chart illustrating steps to be taken by a method object to activate its superpowers powers (analogous to Clark Kent entering the phone booth and donning his cape). The flow chart begins at step S202. At step S204, the system record for the class of the calling method is inspected to determine if the system record includes an indication that the calling method is a &#34;Clark Kent&#34; method (i.e., potentially superpowered by virtue of having been loaded without a class loader). If not, at step S206, an exception is thrown. (Alternately, the method may just return.) If it is found at step S204 that the system record for the class of a calling method includes an indication that the calling method is a &#34;Clark Kent&#34; method, then at step S208 a dynamic indication that the calling method now has superpowers is set on the activation record (i.e. in the stack frame) of the calling method. At step S210, the procedure ends. 
     FIG. 3 is a flow chart that illustrates the procedure followed by the Java security code, in accordance with the preferred embodiment of the invention, when a method attempts to access restricted resources. The procedure starts at step S302. At step S304, a current --  method variable is set equal to the calling method. At step S306, the system record for the class to which the method pointed to by current --  method belongs is inspected to see if it indicates that the method is a &#34;Clark Kent&#34; method. If not, then the method is a &#34;wimp&#34; method and an exception is thrown at step S308. Otherwise, the activation record (stack frame) of the method pointed to by current --  method is inspected to determine if it includes a dynamic indication that the method has superpowers. If so, at step S312, access is allowed to the restricted resources. If not, the procedure continues at step S318. (Step S314, which handles top-of-stack processing, will be discussed later.) At step S318, the current --  method variable is set to point to the method that called the current --  method. Then, steps S306 and S310 are repeated until either an exception is thrown at step S308, access is allowed at step S312, or the top of the stack is reached at step S314. 
     Five example executions of the procedure shown in FIG. 3 are now discussed with reference to FIG. 4 and Tables 1A and 1B. FIG. 4 illustrates a situation whereby a method A has been called. Method A calls method B, and method B calls method C. Method C is requesting access to restricted resources. Referring now to Table 1A, example 1 shown therein is discussed. The column &#34;S&#34; indicates whether the method belongs to a class that has a static capability to access restricted system resources (i.e., is a &#34;Clark Kent&#34; class). The column &#34;D&#34; indicates whether the stack frame of the method, at the time method C has requested access to restricted resources, has a dynamic indication that it is able to access restricted resources (i.e., is a &#34;Superman&#34; method). &#34;Y&#34; stands for yes; &#34;N&#34; stands for no; and &#34;DC&#34; stands for &#34;don&#39;t care&#34;. In Example 1, method C is both statically empowered to access restricted resources, and the stack frame of method C includes a dynamic indication that method C is allowed to access restricted resources. That is, method C started out as a &#34;Clark Kent&#34; method, and at some point became a fully-activated &#34;Superman&#34; method. Thus, for example 1, the procedural flow of FIG. 3 is as follows. The procedure starts at step S302. At step S304, current --  method is set to be equal to method C. At step S306, the result is yes, so method C is allowed access to the restricted resource. 
     In example 2, method C is a &#34;wimp&#34; method. That is, there is no indication in the system record for the class to which method C belongs that method C may ever access restricted resources. Thus, when the procedure in the flow chart of FIG. 3 is followed, for example 2, the answer at step S306 is no. Thus, an exception is thrown at step 308. 
     In example 3, method C is a &#34;Clark Kent&#34; method, but the stack frame of method C does not include an indication that method C has been given superpowers. Method B, also, is a &#34;Clark Kent&#34; method. The stack frame of method B includes a dynamic indication that method B is currently enabled to access restricted resources. Thus, when the procedure of FIG. 3 is followed for example 3, the answer at step S306 for method C is yes. Thus, execution continues at S310. The answer at step S310 for method C is no. Thus, disregarding the top-of-stack processing at step S314, processing continues at step S318 where the current --  method variable is set to method B. At step S306 for method B, the answer is yes. Thus, processing continues at step S310. At step S310 for method B, the answer is yes. Thus, processing continues at step S312, where access to the restricted resources is allowed. 
     In example 4, since the system record for the class to which method C belongs includes a static indication that method C may access restricted resources, method C is a &#34;Clark Kent&#34; method. However, the activation record of method C does not include an indication that the power to access restricted resources have been activated. Method B, also, is a &#34;Clark Kent&#34; method, but neither does the activation record of method B include an indication that the powers to access restricted resources has been activated for method B. Method A in example 5 is a &#34;wimp&#34; method, since the system record for the class to which method A belongs does not include an indication that method A can access restricted resources. 
     Thus, when the procedure in the flow chart of FIG. 3 is followed for example 5, at step S304 current --  method is set to method C. At step S306 for method C, the answer is yes. At step S310 for method C, the answer is no. Then, at step S318, the current --  method variable is set to method B. At step S306 for method B, the answer is yes. At step S310 for method B, the answer is no. Thus, processing continues at step S318 where the current --  method variable is set to method A. At step S306 for method A, the answer is no. Thus, processing continues at step S308, where an exception is thrown. 
     This patent application includes a software appendix which is attached hereto as Appendix A. Appendix A discloses a preferred embodiment for implementing the security method described above. Appendix A is herein incorporated as an integral part of this disclosure. 
     In summary, in accordance with the present invention, a general philosophy of the &#34;Principle of Least Privilege&#34; has been adhered to. The idea is that for secure systems, all actors should be kept at the least possible power level (i.e., there is no reason to grant an actor immense powers when trivial tasks are all that will be performed by the actor). The issues surrounding this principle is that an attacker will often try to subvert the mission of a piece of code. Specifically, attackers will often give out of range values, and hope to cause a piece of code to perform tasks that the author never intended to perform. This Principle of Least Privilege combats such subversive attacks by trying to avoid the possession of powers, and hence reducing the window of vulnerability. Simply put, a program is only susceptible to significant subversion while it possesses significant powers. 
     In accordance with the invention, there are two ways that power is restricted: a) a temporal restriction; and b) a lexical restriction. The fact that the power is only turned on for some portion of the execution of a method (while the stack annotation is activated) implies that the attacker has a small temporal window to implement a subversive attack. The fact that the powers are discarded automatically at the completion of the function call (as a result of the stack annotation) ensures that the duration is very restricted. The fact that there are only a few physical (lexical) lines of code where large powers are possessed, means that the region of code that can be attacked, and hence that must be scrutinized and defended, is very small. Again the fact that privileges are discarded at the function termination automatically ensures that the critical code segment cannot proceed beyond the lexical end of the function. Together those two elements significantly lessen the amount of unnecessary privilege possessed by a program. 
     In accordance with further embodiments, the principle of least privilege is applied to a &#34;capability model&#34;. Individual capabilities are allowed to be granted in &#34;signed classes&#34;. For example, permission can be granted to write files, without granting permission to read files. Permission can be granted to make network connections, without granting permission to interrogate system properties (e.g., current user id; current directory; etc.). In short, the capabilities granted to a piece of code can be restricted to an arbitrary subset of all possible privileges. Significantly, which classes get which capabilities is determined by the &#34;signing&#34; and need not be assigned strictly on the basis of being loaded across a network (via a URL) versus being loaded from a local file system without a class loader. Again, all the temporal and lexical restrictions discussed above may apply. 
     A particular implementation is provided as Appendix B. Appendix B is herein incorporated as an integral portion of this disclosure. 
     
         APPENDIX A   -  The following is the native implementation of that function. This    Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. function walks up the Java stack, looking at each stack frame (after    bypassing some initial number of frames). At each level, it checks to    see if the frame has been &#34;enabled&#34; for the specific privilege. If it   The following is a little helper function that is used to combine has,   then the routine is done, and it returns cleanly. If the frame     multiple privs into a single result. It is used when we find has not been annotated with an ALLOW marking, then it considers   something on the stack that has multiple principals, and some are whether the frame *could* have made the annotation. This test is doneallowed access, and other are perchance forbidden, and we need to see by examining the Principal associated with the stack frame. If the    what it all adds up to. principal could not have empowered (annotated)   the current frame, then    the function terminates abruptly by throwing an exception. Lastly, if   &gt; /** there was no decisive reason to terminate the scan at that level, the   &gt; * add( ) method takes two perms and returns a new perm that has the routine continues up the stack frames.   &gt; * following rules.   &gt; * Minor comments below . . .   &gt; * ALLOWED + ALLOWED = ALLOWED  1 + 1 =  1                              &gt; * ALLOWED + BLANK = ALLOWED  1 + 2 = 1   &gt; * BLANK + BLANK = BLANK  2 + 2 =  2 &gt; /*** public native checkPrivilegeEnabled (Lnetscape/security/Target;  I)V ***/   &gt; * ALLOWED + FORBIDDEN = FORBIDDEN  1 + 0 = 0 &gt; JRI.sub.--  PUBLIC.sub.--  API(jbool)                                                 &gt; * BLANK + FORBIDDEN = FORBIDDEN  2 + 0 = 0 &gt; native.sub.-- netscape.sub.-- security.sub.-- PrivilegeManager.sub.--  checkPrivilegeEnabled(            &gt; * FORBIDDEN + FORBIDDEN = FORBIDDEN    0 + 0 =  0 &gt; JRIEnv* env,                                               &gt; * &gt; struct netscape.sub.-- security.sub.--  PrivilegeManager* self,            &gt; * &gt; jobjectArray targetAry,    &gt; */   &gt; jint taregtAry is the array of targets that we are checking for enablement   &gt; add.sub.-- Privileges(jint perm 1, jint perm2) on the stack.     &gt; {   &gt; if(perm1 &lt;  perm2) return perm 1; &gt; jint callerDepth,                  &gt; return perm 2;   &gt; } callerDepth is the number of stack frames to skip (it brings us back   &gt;  to the frame where the real check call was done).   &gt; . . .   &gt;  &gt; structjava.sub.-- lang.sub.--  Object *data,                        The most recent name for the method of checking to see what is on the To handle parameterized targets, we always pass in a piece of data to   stack is netscape.security.PrivilegeManager.checkPrivilegeEnabled( ). hand to the targets (in case it needs it to make a decision).   &gt; jbool throwException) &gt;&gt; privilege.sub.-- clazz = JRI.sub.--  FindClass(env,                  There are two possible interfaces. When   we fail, we could either &gt; classname.sub.-- netscape.sub.--  security.sub.--  Privilege);                                              return a boolean FALSE, or we can throw an exception. This last &gt; target.sub.-- clazz = JRI.sub.-- FindClass(env, classname.sub.-- netscape.sub.-- security.sub.--  Target);                                                  argument tells us what the caller wants us to do. &gt; noOfTargets = JRI.sub.-- GetObjectArrayLength(env, targetAry);    &gt;   &gt; {   &gt; ExecEnv *ee; Next we prepare to iterate up through the stack frames.   &gt; struct netscape.sub.-- security.sub.--  Target *target;                &gt; structjavaframe *frame, frame.sub.-- buf; &gt; for (frame = ee-&gt;current.sub.-- frame ; frame !=  0;) {             &gt; struct netscape.sub.-- security.sub.--  PrivilegeTable *annotation;   &gt; struct netscape.sub.-- security.sub.-- Privilege *privilege; We ignore &#34;fake frames&#34; that don&#39;t correspond to actual java method     &gt; jobjectArray prinAry; calls . . .   &gt; ClassClass *cb;   &gt; intdepth = 0; &gt; if (frame-&gt;current.sub.-- method !=  0) {              &gt; jintperm;   &gt; jint scopePerm; We only start inquiring once we&#39;ve skipped a few frames . . .   &gt; jint prinPerm;   &gt; int saw.sub.-- non.sub.-- system.sub.-- code = 0; &gt; if (depth &gt;= callerDepth) {   &gt; struct java.sub.-- lang.sub.-- Class* privilege.sub.-- clazz;    &gt; struct java.sub.-- lang.sub.-- Class* target.sub.-- clazz; Finally we are going to do some checking. We&#39;ll have to combine the  &gt; int noOfTargets; results from all the targets in our array of targets. If we find a   &gt; int idx; FORBID for any of them, then we&#39;ll end up quitting.     &gt;    &gt; scopePerm = netscape.sub.-- security.sub.-- Privilege.sub.-- BLANK;   We start with some internal error checking. &gt; prinPerm =  netscape.sub.-- security.sub.-- Privilege.sub.--  BLANK;                  &gt; if(!targetAry) { Run the check across all the   targets in our array . . .   &gt; JRI.sub.--  ThrowNew(env,                                              &gt; class.sub.-  - java.sub.-- lang.sub.-- NullPointerException(env), &gt; for (idx = 0; idx &lt;  noOfTargets; idx++) {                                               &gt; &#34;internal error - null target array?&#34;); &gt; jref target.sub.-- jref = JRI.sub.--  GetObjectArrayElement(env,                                     &gt; return   (jbool)FALSE; &gt; targetAry, idx);   &gt; } &gt; target = (netscape.sub.-- security.sub.--  Target *)/*XXX*/target.sub.--  jref;                                      &gt; ee = EE( ); &gt; if(!target) {   &gt; jri.sub.-- initialize(env); &gt; JRI.sub.--  ThrowNew(env,                &gt; class.sub.-- java.sub.-- lang.sub.-- NullPointerException(env), &gt; annotation = (struct netscape.sub.-- security.sub.--  PrivilegeTable *)                                         &gt; &#34;internal error - a null target in the Array&#34;); &gt;  frame-&gt;annotation;               &gt; return (jbool)FALSE; &gt; /*   &gt; } &gt; * If there isn&#39;t a annotation, then we assume the default      &gt; * value of blank and avoid allocating a new annotation.  Now we&#39;ll look at details for one specific target . . . &gt; */   &gt; /* The above means we treat a missing annotation as if it were BLANK. This   &gt; frame-&gt;annotation holds PrivilegeTable, describing saves a lot of wasted allocation of empty annotation objects.   &gt; * the scope privileges of this frame. We&#39;ll check   &gt; * if it permits the target, and if so, we just return. &gt; if (annotati  on) {   &gt; * If it forbids the target, we&#39;l1 throw an exception,   &gt; * and return. If it&#39;s blank, things get funny. A real annotation contains a list of privs for each target . . . to lets   &gt; * see what this annotation has to say about the target we&#39;re considering . . .   &gt; * In the blank case, we need to continue walking up   &gt; * the stack, looking for a non-blank privilege. To &gt; privilege = netscape.sub.-- security.sub.-- PrivilegeTable.sub.-- get.sub.-- 1(env,   &gt; * prevent &#34;luring&#34; attacks, these blank frames must &gt; annotation,&gt; * have the ability that they *could have requested* &gt; target); &gt; * privilege, but actually didn&#39;t. This property &gt; if (exceptionOcc  urred(ee)) {   &gt; *insures that we don&#39;t have a non-permitted (attacker) &gt; return(jbool  )FALSE;   &gt; * class somewhere in the call chain between the request &gt; }   &gt; * for scope privilege and the chedk for privilege. &gt; sysAssert(privil  ege);   &gt; */ &gt; perm = netscape.sub.-- security.sub.-- Privilege.sub.-- getPermission(env,   &gt; &gt; privilege);   &gt; cb = fieldclass(&amp;frame-&gt;current.sub.--  method-&gt;fb); &gt; sysAssert(!exceptionOccurred(ee));   &gt; /*   &gt; * no Class associated with stack frame? hmm . . . Here we tally this   priv, in addition to what we have so far . . .   &gt; /*   &gt; if(cb == NULL) { &gt; scopePerm = add.sub.--  Privileges(perm, scopePerm);   &gt; JRI.sub.--  ThrowNew(env, &gt; }                                          &gt; class.sub.-  - java.sub.-- lang.sub.--  NullPointerException(env),                     &gt; &#34;internal error - no class for stack frame?&#34;); While we&#39;re here . . . lets also consider if this class *could* have   &gt; return(jbool)FALSE; empowered itself . . . so lets see what principal  s are associated with   &gt; } this class . . .   &gt;   &gt; prinAry =  cbPrincipalAry(cb); &gt; }                                     &gt; if(prinAry   !=  NULL) {                                                              &gt; privilege = but if we found a FORBIDDEN annotation (i.e., a scopePermissi  on) . . .   &gt; netscape.sub.-- security.sub.-- Target.sub.-- checkPrivilegeEnabled(   &gt; env,target,prinAry,data); &gt; if ((scopePerm == netscape.sub.-- security.sub.-- Privilege.sub.--  FORBIDDEN) ∥                    &gt; if (exceptionOccurred(ee)) {   &gt; return (jbool)FALSE; then we should stop.   &gt; } OR similarly . . . if we saw some non-system code (we&#39;re extra friendly   &gt; sysAssert(privilege); to system code) and the principal didn&#39;t have the potential to ALLOW   &gt; perm = netscape.sub.-- security.sub.-- Privilege.sub.--  getPermission(env, the annotation, . . . then again we should stop . . .   &gt; privilege);   &gt; sysAssert(!exceptionOccurred(ee)); &gt;  (saw.sub.-- non.sub.-- system.sub.--  code &amp;&amp;                                                     &gt; scopePerm   = add.sub.-- Privileges(perm, scopePerm); &gt; (prinPerm !=  netscape.sub.-- security.sub.-- Privilege.sub.--  ALLOWED))) {            &gt;   &gt; perm = . . . but stop with a failure mode of either an exception or a return.   netscape.sub.-- security.sub.-- PrivilegeManager.sub.--  getPrincipalPrivilege.sub.--  1(env,self,target,prin                      Ary); &gt; if (throwException)   &gt; sysAssert(!exceptionOccurred(ee)); &gt; JRI.sub.-- ThrowNew(env,      &gt; class.sub.-- netscape.sub.-- security.sub.--  ForbiddenTargetException(env),   . . . and lets tally that result into information about all the &gt; &#34;access to target forbidden&#34;);   principals and their permissions . . . &gt; return (jbool)FALSE;   &gt; }   &gt; prinPerm = add.sub.--  Prvileges(perm, prinPerm); &gt; }                  &gt; saw.sub.-- non.sub.--   system.sub.-- code =  1;                                                 &gt; } Finally, if we get here, then we should continue scanning up the stack   &gt; } frame. There is some subtlety here to deal with JIT&#39;ed code, whichrequires special faked-up stack frames . . . but these next few lines get   Whew. We&#39;re done scanning all the targets, so no we decide whether to us to the next effective stack of the call chain.   continue the stack scan or to just return.   &gt; frame = frame-&gt;current.sub.--  method-&gt;fb.access &amp;                     &gt; if (scopePerm ==  netscape.sub.-- security.sub.-- Privilege.sub.-- ALLOWED) { ACC.sub.-- MACHINE.sub.--  COMPILED?                                                   &gt; CompiledFr  amePrev(frame, &amp;frame.sub.--  buf): frame-&gt;prev;                          If we found an ALLOWED annotation . . . we&#39;re golden . . . &gt; depth++;   &gt; }  else {                                                              &gt; return (jbool)TRUE; &gt; frame =  frame-&gt;prev;                                &gt; } (   &gt; } &gt; JRIEnv* env,&gt; structnetscape.sub.-- security.sub.-- PrivilegeManager* self,  Finally, if we run out of call-stack frames, we fail as though the   &gt; jint callerDepth)   permission was disabled. &gt; {    &gt; #ifedefXP.sub.--  MAC                                                 &gt; /* &gt; #pragma unused (self)   &gt; * If we get here, there is no non-blank capability on the stack, &gt; #endif   &gt; * and there is no ClassLoader, thus give privilege for now &gt;     &gt; */ &gt; struct javaframe *frame, frame.sub.--  buf;                &gt; if(saw.sub.-- non.sub.-- system.sub.-- code) { &gt; ClassClass  *cb;                                                           &gt; if(throwException) &gt; int depth =  0;                                       &gt; JRI.sub.-- ThrowNew(env, &gt;    &gt; class.sub.-- netscape.sub.-- security.sub.--  ForbiddenTargetException(env), &gt; jri.sub.--  initialize(env);             &gt; &#34;access to target forbidden&#34;); &gt;     &gt; } ═ for(frame = EE( )-&gt;current.sub.-- frame; frame !=0;) {   &gt; JRI.sub.-- ThrowNew(env, &gt; if(Frame-&gt;current.sub.-- method != 0) {    &gt; class.sub.-- netscape.sub.-- security.sub.--  No ClassLoaderException(env), &gt; if(depth &gt;=  callerdepth) {               &gt; &#34;no class loader and no PrivilegeTable&#34;);   &gt; cb = fieldclass(&amp;frame-&gt;current.sub.--  method-&gt;fb);                   &gt; return(jbool)FALSE; &gt; /*   &gt; } &gt; * no Class associated with stack frame?  hmm . . .                 &gt;  &gt; */&gt; if(cb ==  NULL) {                                                    The following   is a helper function that pulls a list of all the &gt; JRI.sub.-- ThrowNew(env,   Principals from the stack. It is called &#34;Unsafe&#34; because the caller &gt; class.sub.-- java.sub.-- lang.sub.--  NullPointerException(env),           is given the actual arrays . . . which means the caller *could* change &gt; &#34;internal error - no class for stack frame?&#34;);   this list (gulp). As a result, we only pass around this &#34;unsafe&#34; &gt; return NULL;   version within the class, and NEVER hand it back to Joe-Average user. &gt; }   It is a private helper function. &gt; /*    &gt; /* If there is a class loader, then there should be a Princiapl &gt; /*** private native getClassPrincipalsFromStackUnsafe &gt; */    *I([Lnetscape/security/Principal; ***/ &gt; if (cbLoader(cb) &amp;&amp; (cbPrincipalAry(cb) ==  NULL) {                                            &gt; JRI.sub.-- PUBLIC.sub.-- API(jref) &gt; JRI.sub.--  ThrowNew(env,                        &gt; &gt; class.sub.-- netscape.sub.-- security.sub.--  ForbiddenTargetException(env),                            native.sub.--   netscape.sub.-- security.sub.-- PrivilegeManager.sub.--  getClassPrincipalsFromStackUnsafe &gt; &#34;internal error - no Principal for stack frame?&#34;);   &gt; return NULL; &gt; struct netscape.sub.-- security.sub.--  PrivilegeManager* self,   &gt; } &gt; structjava.sub.-- lang.sub.--  Class *a)                           &gt; return cbPrincipalAry(cb); &gt; {&gt; } &gt; #ifdef XP.sub.--  MAC                                            &gt; frame =  frame-&gt;current.sub.-- method-&gt;fb.access &amp; &gt; #pragma unused (self)   ACC.sub.-- MACHINE.sub.--  COMPILED? &gt; #endif                       &gt; CompiledFramePrev(frame, &amp;frame.sub.--  buf) : frame-&gt;prev; &gt;                                       &gt; depth++; &gt; ClassClass  *cb;                                                         &gt; } else {   &gt;   &gt; frame = frame-&gt;prev; &gt; jri.sub.--  initialize(env);                    &gt; } &gt;   &gt; } &gt; if((a == NULL) ∥ ((cb = unhand((HClass *)a)) == NULL)) {   &gt; /* &gt; JRI.sub.--  ThrowNew(env,                                         &gt; * if we got here, the callerDepth was probably longer than the stack &gt; class.sub.-- java.sub.-- lang.sub.--  NullPointerException(env),                        &gt; */ &gt; &#34;internal error - no class block for Principal?&#34;);   &gt; JRI.sub.--  ThrowNew(env, &gt; return NULL;                               &gt; class.sub.-  - java.sub.-- lang.sub.--  IndexOutOfBoundsException(env), &gt; }            &gt; &#34;getClassPrincipalsFrom  Stack stack callerDepth greater than stack &gt;   depth&#34;); &gt; /*   &gt; returnNULL; &gt; * If there is a class loader, then there should be a Principal   &gt; } &gt; */   &gt;  &gt; if (cbLoader(cb) &amp;&amp; (cbPrincipalAry(cb) ==  NULL)) {                &gt; JRI.sub.--  ThrowNew(env,                       Here is another private helper function that accesses the internals of &gt; class.sub.-- netscape.sub.-- security.sub.--  ForbiddenTargetException(env),                            a class, and gets a list of principals. The last method scanned the &gt; &#34;internal error   - no Principal for stack frame?&#34;);   entire stack, and returned an array with one list for each stack &gt; return NULL;   frame. This is the lower-level helper that just looks at a class, and &gt; }   gets the list of principals for the class (again . . . unsafe . . . but &gt; return cbPrincipalAry(cb);   private). &gt; }    &gt;   &gt; /*** private native getClassPrincipalsUnsafe (I)[Lnetscape/security/P  rincipal;   ***/ Stack annotations are stored as &#34;PriviligeTable&#34;. The following gets   &gt; JRI.sub.-- PUBLIC.sub.-- API(jref) the actual annotation from the stack. This is an unsafe method (to   &gt; native.sub.-- netscape.sub.-- secunty.sub.-- PrivilegeManager.sub.--   getClassPrincipalsUnsafe( much exposure to the caller to change the values), but it is only used   &gt; JRIEnv* env, privately.   netscape.sub.-- security.sub.-- PrivilegeTable.sub.-- new(env, JRI.sub.--  FindClass(env,                                                 &gt; /* * *   private native getPrivilegeTableFromStackUnsafe classname.sub.-- netscape.sub.-- security.sub.--  PrivilegeTable));                         (I)Lnetscape/security/Privileg  eTable; ***/ &gt; if (exceptionOccurred(ee)) {   &gt; JRI.sub.-- PUBLIC.sub.-- API(struct netscape.sub.-- security.sub.-- PrivilegeTable *) &gt; /*   &gt;  &gt; * no memory?!??!  return NULL, and let our                          native.sub.-- netscape.sub.-- security.sub.-- PrivilegeManager.sub.--  getPrivilegeTableFromStackUnsafe( &gt; * parent deal with the exception&gt; JRIEnv* env, &gt; * /   &gt; struct netscape.sub.-- security.sub.-- PrivilegeManager* self, &gt; return NULL;   &gt; jint callerDepth, &gt; }   &gt; jbool createIfNull) &gt; sysAssert(privilege !=  NULL);                   &gt; { &gt; if (frame-&gt;current.sub.--  method-&gt;fb.access &amp;   &gt; #ifdefXP.sub.-- MAC ACC.sub.-- MACHINE.sub.--  COMPILED) {             &gt; #pragma unused (self) &gt; SetCompiledFrameAnnota  tion(frame, privilege);   &gt; #endif &gt; }  else {                                                     &gt; &gt; frame-&gt;an  nnotation =  privilege;                                                   &gt; structjav  aframe *frame, frame.sub.--  buf; &gt; }                                     &gt; int depth = 0; &gt; return (struct netscape.sub.-- security.sub.--  PrivilegeTable *)                 &gt; ExecEnv *ee; &gt; (privilege);     &gt; &gt; }  else {                                                     &gt; jri.sub.--   initialize(env); &gt; return (struct netscape.sub.-- security.sub.-- PrivilegeTable *)   &gt; &gt; (frame-&gt;annotation);   &gt; ee =  EE( ); &gt; }                                                       &gt; &gt; }   &gt; for (frame =ee-&gt;current.sub.-- frame; frame != 0 ;) { &gt; frame = frame-&gt;current.sub.--  method-&gt;fb.access &amp;                                 &gt; if (frame-&gt;current  .sub.-- method != 0) { ACC.sub.-- MACHINE.sub.--  COMPILED?               &gt; if (depth &gt;=  callerDepth) { &gt; CompiledFramePrev(frame, &amp;frame.sub.--  buf) : frame-&gt;prev;   &gt; /* &gt; depth++;   &gt; * it&#39;s possible for the annotation to be NULL, meaning &gt; } else {&gt; * nobody&#39;s ever asked for it before. The correct &gt; frame = frame -&gt;  prev; &gt; * response is to create a new PrivilegeTable (with &gt; }   &gt; * default &#34;blank forever&#34;  privileges), assign that &gt; }                &gt; * to the annotation, and return it. &gt; /*   &gt; */ &gt; * if we got here, the callerDepth was probably longer than the stack   &gt; if(createIfNull &amp;&amp; (frame-&gt;annotation ==  NULL)) { &gt; */                &gt; JHandle * privilege = (JHandle *) &gt; JRI.sub.--  ThrowNew(env,                                                  &gt; class.sub.-- java.sub.-- lang.sub.-- IndexOutOfBoundsException(env), &gt; }   &gt; &#34;getPrivilegeTableFromStack stack callerDepth greater than stack &gt; /* XXX: End of hack for Beta */   depth&#34;); &gt;   &gt;   &gt; return NULL; The next few functions have to do with calls to the underlying crypto   &gt; } API, and are really not significant to the patent work.   &gt;    &gt; extern JRI.sub.-- PUBLIC.sub.--  API(jint)                            The following comment says it all.   IT was put in to support some &gt; native.sub.-- netscape.sub.--  security.sub.-- Principal.sub.--  getZigPtr(                              beta2 test code, which disables   a pile of security checking, but &gt; JRIEnv* env,   allows developers to get to play with the features before the complete   &gt; struct netscape.sub.-- security.sub.--  Principal* self;               UI and crypto structure is coded. &gt; struct java.sub.-- lang.sub.--  Class *cl                                   &gt; )   &gt; /* XXX: Hack for Beta2 */ &gt; {   &gt; static int (*IsJavaSecurityEnabledCallback)( ); &gt; #ifdef XP.sub.-- MAC   &gt;  &gt; #pragma unused (self)   &gt; JRI.sub.-- PUBLIC.sub.--  API(void) &gt; #endif                           &gt; setIsJavaSecurityEnabledC  allback(int (*fp)( )) &gt;   &gt; { &gt; ClassClass  *cb;                                                   &gt; IsJavaSecurityE  nabledCallback =  fp; &gt;                                                   &gt; } &gt; if ((cl == NULL) ∥ ((cb unhand((HClass *)cl)) ==  NULL)) {                &gt; &gt; return(jint)0;   &gt; JRI.sub.-- PUBLIC.sub.--  API(jbool) &gt; }                               &gt; native.sub.--  netscape.sub.-- security.sub.-- PrivilegeManager.sub.--  getJavaSecurityEnabled( &gt;   &gt; JRIEnv* env, &gt; return (jint)cbZigPtr(cb),   &gt; struct netscape.sub.-- security.sub.-- PrivilegeManager* self) &gt; }    &gt; { &gt;   &gt; #ifdefXP.sub.--  MAC &gt;                                                 &gt; #pragma unused (self) &gt; static int (*signatureAttributeCallback)(int attrib, void *zig,   void *data, void   &gt; #endif **result, unsigned long *length);   &gt; if (!IsJavaSecurityEnabledCallback) { &gt;   &gt; return (jbool)TRUE; &gt; JRI.sub.-- PUBLIC.sub.--  API(void)              &gt; } &gt; setSignatureAttributeCallback(int (*fp)(int   attrib, void *zig, void *data, void   &gt; **result, unsigned long *length))   &gt; return (jbool)IsJavaSecurityEnabledCallback( ); &gt; {   &gt; signatureAttributeCallback =  fp;                                      &gt; }   &gt;   &gt; extern JRI.sub.-- PUBLIC.sub.-- API(structjava.sub.-- lang.sub.-- String *)   &gt; native.sub.-- netscape.sub.-- security.sub.-- Principal.sub.-- getCertAttribute(   &gt; JRIEnV* env,   &gt; struct netscape.sub.-- security.sub.--  Principal* self,               &gt; jint zig.sub.--  arg,                    &gt; jint attrib,   &gt; jbyteArray finger.sub.--  print                                        &gt; )   &gt; {   &gt; #ifdef XP.sub.--  MAC                                                  &gt; #pragma unused (self)   &gt; #endif   &gt;   &gt; void* zig = (void *)zig.sub.--  arg;                                   &gt; char *result;   &gt; unsigned long length;   &gt; void *data = (void *)JRI.sub.--  GetByteArrayElements(env, finger.sub.--  print);                          &gt;   &gt; if ((zig.sub.-- arg == 0) ∥ (!signatureAttributeCallback)) {   &gt; return JRI.sub.--  NewStringUTF(env, &#34;&#34;, 0);                           &gt; }   &gt;   &gt; if (signatureAttributeCallback(attrib, zig, data, (void **)&amp;result,   &gt; &amp;length) &lt;  0) {                                                       &gt; JRI.sub.--   ThrowNew(env,   &gt; class.sub.-- netscape.sub.-- security.sub.--  ForbiddenTargetException(env),   &gt; &#34;invalid ceritficate fingerprint&#34;);   &gt; return JRI.sub.--  NewStringUTF(env, &#34;&#34;, 0);                           &gt; }   &gt; return JRI.sub.--  NewStringUTF(env, result, length);                  &gt; }