< prev index next >

test/jdk/javax/management/security/AuthorizationTest.java

Print this page
rev 51731 : imported patch 8210732


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8058865
  27  * @summary Checks various authentication behavior from remote jmx client
  28  * @author Olivier Lagneau
  29  * @modules java.management.rmi
  30  * @library /lib/testlibrary
  31  * @library /test/lib
  32  * @compile Simple.java
  33  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials
  34  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException
  35  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username6 -Dpassword=password6 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  36  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials
  37  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username3 -Dpassword=password3 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedGetException
  38  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username5 -Dpassword=password5 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  39  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username6 -Dpassword=password6 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  40  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials
  41  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException
  42  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username3 -Dpassword=password3 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  43  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username4 -Dpassword=password4 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedGetException -expectedSetException
  44  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username5 -Dpassword=password5 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  45  */
  46 
  47 import java.io.File;
  48 import java.util.Map ;
  49 import java.util.HashMap ;
  50 import java.util.List;


 160 
 161         JMXServiceURL addr = cs.getAddress();
 162 
 163         System.out.println("AuthorizationTest::createServerSide: Done.") ;
 164 
 165         return addr;
 166     }
 167 
 168     /*
 169      * Creating command-line for running subprocess JVM:
 170      *
 171      * JVM command line is like:
 172      * {test_jdk}/bin/java {defaultopts} -cp {test.class.path} {testopts} main
 173      *
 174      * {defaultopts} are the default java options set by the framework.
 175      *
 176      */
 177     private List<String> buildCommandLine(String args[]) {
 178         List<String> opts = new ArrayList<>();
 179         opts.add(JDKToolFinder.getJDKTool("java"));
 180         opts.addAll(Arrays.asList(jdk.testlibrary.Utils.getTestJavaOpts()));
 181 
 182         String usernameValue = System.getProperty(USERNAME_PROPERTY);
 183         if (usernameValue != null) {
 184             opts.add("-D" + USERNAME_PROPERTY + "=" + usernameValue);
 185         }
 186         String passwordValue = System.getProperty(PASSWORD_PROPERTY);
 187         if (passwordValue != null) {
 188             opts.add("-D" + PASSWORD_PROPERTY + "=" + passwordValue);
 189         }
 190 
 191         opts.add("-cp");
 192         opts.add(System.getProperty("test.class.path", "test.class.path"));
 193         opts.add(CLIENT_CLASS_MAIN);
 194         opts.addAll(Arrays.asList(args));
 195         return opts;
 196     }
 197 
 198     /**
 199      * Runs AuthorizationTest$ClientSide with the passed options and redirects
 200      * subprocess standard I/O to the current (parent) process. This provides a




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8058865
  27  * @summary Checks various authentication behavior from remote jmx client
  28  * @author Olivier Lagneau
  29  * @modules java.management.rmi

  30  * @library /test/lib
  31  * @compile Simple.java
  32  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials
  33  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException
  34  * @run main/othervm/timeout=300 -DDEBUG_STANDARD -Dusername=username6 -Dpassword=password6 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  35  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials
  36  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username3 -Dpassword=password3 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedGetException
  37  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username5 -Dpassword=password5 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  38  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username6 -Dpassword=password6 AuthorizationTest -server -mapType x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  39  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username1 -Dpassword=password1 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials
  40  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username2 -Dpassword=password2 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedSetException -expectedInvokeException
  41  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username3 -Dpassword=password3 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  42  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username4 -Dpassword=password4 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedGetException -expectedSetException
  43  * @run main/othervm/timeout=300/policy=java.policy.authorization -DDEBUG_STANDARD -Dusername=username5 -Dpassword=password5 AuthorizationTest -server -mapType x.access.file;x.password.file -populate -client -mapType credentials -expectedCreateException -expectedGetException -expectedSetException -expectedInvokeException
  44  */
  45 
  46 import java.io.File;
  47 import java.util.Map ;
  48 import java.util.HashMap ;
  49 import java.util.List;


 159 
 160         JMXServiceURL addr = cs.getAddress();
 161 
 162         System.out.println("AuthorizationTest::createServerSide: Done.") ;
 163 
 164         return addr;
 165     }
 166 
 167     /*
 168      * Creating command-line for running subprocess JVM:
 169      *
 170      * JVM command line is like:
 171      * {test_jdk}/bin/java {defaultopts} -cp {test.class.path} {testopts} main
 172      *
 173      * {defaultopts} are the default java options set by the framework.
 174      *
 175      */
 176     private List<String> buildCommandLine(String args[]) {
 177         List<String> opts = new ArrayList<>();
 178         opts.add(JDKToolFinder.getJDKTool("java"));
 179         opts.addAll(Arrays.asList(jdk.test.lib.Utils.getTestJavaOpts()));
 180 
 181         String usernameValue = System.getProperty(USERNAME_PROPERTY);
 182         if (usernameValue != null) {
 183             opts.add("-D" + USERNAME_PROPERTY + "=" + usernameValue);
 184         }
 185         String passwordValue = System.getProperty(PASSWORD_PROPERTY);
 186         if (passwordValue != null) {
 187             opts.add("-D" + PASSWORD_PROPERTY + "=" + passwordValue);
 188         }
 189 
 190         opts.add("-cp");
 191         opts.add(System.getProperty("test.class.path", "test.class.path"));
 192         opts.add(CLIENT_CLASS_MAIN);
 193         opts.addAll(Arrays.asList(args));
 194         return opts;
 195     }
 196 
 197     /**
 198      * Runs AuthorizationTest$ClientSide with the passed options and redirects
 199      * subprocess standard I/O to the current (parent) process. This provides a


< prev index next >