23 * questions. 24 */ 25 26 package com.sun.rmi.rmid; 27 28 import java.security.*; 29 import java.io.*; 30 import java.util.*; 31 32 /** 33 * The ExecPermission class represents permission for rmid to execute 34 * a specific command to launch an activation group. An ExecPermission 35 * consists of a pathname of a command to launch an activation group. 36 * <P> 37 * Pathname is the pathname of the file or directory to grant rmid 38 * execute permission. A pathname that ends in "/*" (where "/" is 39 * the file separator character, <code>File.separatorChar</code>) indicates 40 * all the files and directories contained in that directory. A pathname 41 * that ends with "/-" indicates (recursively) all files 42 * and subdirectories contained in that directory. A pathname consisting of 43 * the special token "<<ALL FILES>>" matches <bold>any</bold> file. 44 * <P> 45 * Note: A pathname consisting of a single "*" indicates all the files 46 * in the current directory, while a pathname consisting of a single "-" 47 * indicates all the files in the current directory and 48 * (recursively) all files and subdirectories contained in the current 49 * directory. 50 * <P> 51 * 52 * 53 * @author Ann Wollrath 54 * 55 * @serial exclude 56 */ 57 public final class ExecPermission extends Permission 58 { 59 /** 60 * UID for serialization 61 */ 62 private static final long serialVersionUID = -6208470287358147919L; 63 64 private transient FilePermission fp; 65 66 /** 67 * Creates a new ExecPermission object with the specified path. 68 * <i>path</i> is the pathname of a file or directory. 69 * 70 * <p>A pathname that ends in "/*" (where "/" is 71 * the file separator character, <code>File.separatorChar</code>) indicates 72 * a directory and all the files contained in that directory. A pathname 73 * that ends with "/-" indicates a directory and (recursively) all files 74 * and subdirectories contained in that directory. The special pathname 75 * "<<ALL FILES>>" matches all files. 76 * 77 * <p>A pathname consisting of a single "*" indicates all the files 78 * in the current directory, while a pathname consisting of a single "-" 79 * indicates all the files in the current directory and 80 * (recursively) all files and subdirectories contained in the current 81 * directory. 82 * 83 * @param path the pathname of the file/directory. 84 */ 85 public ExecPermission(String path) { 86 super(path); 87 init(path); 88 } 89 90 /** 91 * Creates a new ExecPermission object with the specified path. 92 * <i>path</i> is the pathname of a file or directory. 93 * 94 * <p>A pathname that ends in "/*" (where "/" is 95 * the file separator character, <code>File.separatorChar</code>) indicates 96 * a directory and all the files contained in that directory. A pathname 97 * that ends with "/-" indicates a directory and (recursively) all files 98 * and subdirectories contained in that directory. The special pathname 99 * "<<ALL FILES>>" matches all files. 100 * 101 * <p>A pathname consisting of a single "*" indicates all the files 102 * in the current directory, while a pathname consisting of a single "-" 103 * indicates all the files in the current directory and 104 * (recursively) all files and subdirectories contained in the current 105 * directory. 106 * 107 * @param path the pathname of the file/directory. 108 * @param actions the action string (unused) 109 */ 110 public ExecPermission(String path, String actions) { 111 this(path); 112 } 113 114 /** 115 * Checks if this ExecPermission object "implies" the specified permission. 116 * <P> 117 * More specifically, this method returns true if:<p> 118 * <ul> 119 * <li> <i>p</i> is an instanceof ExecPermission,<p> and 120 * <li> <i>p</i>'s pathname is implied by this object's 121 * pathname. For example, "/tmp/*" implies "/tmp/foo", since 122 * "/tmp/*" encompasses the "/tmp" directory and all files in that 123 * directory, including the one named "foo". 124 * </ul> 125 * @param p the permission to check against. 126 * 127 * @return true if the specified permission is implied by this object, 128 * false if not. 129 */ 130 public boolean implies(Permission p) { 131 if (!(p instanceof ExecPermission)) 132 return false; 133 134 ExecPermission that = (ExecPermission) p; 135 136 return fp.implies(that.fp); 137 } 138 139 /** 140 * Checks two ExecPermission objects for equality. 141 * Checks that <i>obj</i>'s class is the same as this object's class 142 * and has the same name as this object. 143 * <P> 144 * @param obj the object we are testing for equality with this object. 145 * @return true if <i>obj</i> is an ExecPermission, and has the same 146 * pathname as this ExecPermission object, false otherwise. 147 */ 148 public boolean equals(Object obj) { 149 if (obj == this) 150 return true; 151 152 if (! (obj instanceof ExecPermission)) 153 return false; 154 155 ExecPermission that = (ExecPermission) obj; 156 157 return fp.equals(that.fp); 158 } 159 160 /** 161 * Returns the hash code value for this object. 162 * 163 * @return a hash code value for this object. | 23 * questions. 24 */ 25 26 package com.sun.rmi.rmid; 27 28 import java.security.*; 29 import java.io.*; 30 import java.util.*; 31 32 /** 33 * The ExecPermission class represents permission for rmid to execute 34 * a specific command to launch an activation group. An ExecPermission 35 * consists of a pathname of a command to launch an activation group. 36 * <P> 37 * Pathname is the pathname of the file or directory to grant rmid 38 * execute permission. A pathname that ends in "/*" (where "/" is 39 * the file separator character, <code>File.separatorChar</code>) indicates 40 * all the files and directories contained in that directory. A pathname 41 * that ends with "/-" indicates (recursively) all files 42 * and subdirectories contained in that directory. A pathname consisting of 43 * the special token "{@code <<ALL FILES>>}" matches <b>any</b> file. 44 * <P> 45 * Note: A pathname consisting of a single "*" indicates all the files 46 * in the current directory, while a pathname consisting of a single "-" 47 * indicates all the files in the current directory and 48 * (recursively) all files and subdirectories contained in the current 49 * directory. 50 * 51 * 52 * @author Ann Wollrath 53 * 54 * @serial exclude 55 */ 56 public final class ExecPermission extends Permission 57 { 58 /** 59 * UID for serialization 60 */ 61 private static final long serialVersionUID = -6208470287358147919L; 62 63 private transient FilePermission fp; 64 65 /** 66 * Creates a new ExecPermission object with the specified path. 67 * <i>path</i> is the pathname of a file or directory. 68 * 69 * <p>A pathname that ends in "/*" (where "/" is 70 * the file separator character, <code>File.separatorChar</code>) indicates 71 * a directory and all the files contained in that directory. A pathname 72 * that ends with "/-" indicates a directory and (recursively) all files 73 * and subdirectories contained in that directory. The special pathname 74 * "{@code <<ALL FILES>>}" matches all files. 75 * 76 * <p>A pathname consisting of a single "*" indicates all the files 77 * in the current directory, while a pathname consisting of a single "-" 78 * indicates all the files in the current directory and 79 * (recursively) all files and subdirectories contained in the current 80 * directory. 81 * 82 * @param path the pathname of the file/directory. 83 */ 84 public ExecPermission(String path) { 85 super(path); 86 init(path); 87 } 88 89 /** 90 * Creates a new ExecPermission object with the specified path. 91 * <i>path</i> is the pathname of a file or directory. 92 * 93 * <p>A pathname that ends in "/*" (where "/" is 94 * the file separator character, <code>File.separatorChar</code>) indicates 95 * a directory and all the files contained in that directory. A pathname 96 * that ends with "/-" indicates a directory and (recursively) all files 97 * and subdirectories contained in that directory. The special pathname 98 * "{@code <<ALL FILES>>}" matches all files. 99 * 100 * <p>A pathname consisting of a single "*" indicates all the files 101 * in the current directory, while a pathname consisting of a single "-" 102 * indicates all the files in the current directory and 103 * (recursively) all files and subdirectories contained in the current 104 * directory. 105 * 106 * @param path the pathname of the file/directory. 107 * @param actions the action string (unused) 108 */ 109 public ExecPermission(String path, String actions) { 110 this(path); 111 } 112 113 /** 114 * Checks if this ExecPermission object "implies" the specified permission. 115 * <P> 116 * More specifically, this method returns true if: 117 * <ul> 118 * <li> <i>p</i> is an instanceof ExecPermission, and 119 * <li> <i>p</i>'s pathname is implied by this object's 120 * pathname. For example, "/tmp/*" implies "/tmp/foo", since 121 * "/tmp/*" encompasses the "/tmp" directory and all files in that 122 * directory, including the one named "foo". 123 * </ul> 124 * @param p the permission to check against. 125 * 126 * @return true if the specified permission is implied by this object, 127 * false if not. 128 */ 129 public boolean implies(Permission p) { 130 if (!(p instanceof ExecPermission)) 131 return false; 132 133 ExecPermission that = (ExecPermission) p; 134 135 return fp.implies(that.fp); 136 } 137 138 /** 139 * Checks two ExecPermission objects for equality. 140 * Checks that <i>obj</i>'s class is the same as this object's class 141 * and has the same name as this object. 142 * 143 * @param obj the object we are testing for equality with this object. 144 * @return true if <i>obj</i> is an ExecPermission, and has the same 145 * pathname as this ExecPermission object, false otherwise. 146 */ 147 public boolean equals(Object obj) { 148 if (obj == this) 149 return true; 150 151 if (! (obj instanceof ExecPermission)) 152 return false; 153 154 ExecPermission that = (ExecPermission) obj; 155 156 return fp.equals(that.fp); 157 } 158 159 /** 160 * Returns the hash code value for this object. 161 * 162 * @return a hash code value for this object. |