/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @author Danny Hendler
* @author Gary Ellison
* @bug 4244271
* @summary New policy sometimes has no effect with no indication given
*/
/*
The test should be given the following permissions:
grant codeBase "file:testPath" {
permission java.security.SecurityPermission "setPolicy";
permission java.security.SecurityPermission "getPolicy";
};
*/
public class TestDynamicPolicy {
try {
//
} catch(Exception e) {
throw e;
}
}
// A security manager must be installed
throw new
Exception("Test must be run with a security manager installed");
// Instantiate and set the new policy
// Verify that policy has been set
throw new Exception("Policy was not set!!");
// now see this class can access user.name
throw new
Exception("Test was able to read user.name prior to refresh!");
}
// Now, make policy allow reading user.name
// now I should be able to read it
usr = getUserName();
throw new
Exception("Test was unable to read user.name after refresh!");
}
// Now, take away permission to read user.name
// now I should not be able to read it
usr = getUserName();
throw new
Exception("Test was able to read user.name following 2nd refresh!");
}
}
try {
} catch (Exception e) {
}
return usr;
}
}