equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
52 * a list of one or more comma-separated keywords. The possible keywords are |
52 * a list of one or more comma-separated keywords. The possible keywords are |
53 * "read" and "write". Their meaning is defined as follows: |
53 * "read" and "write". Their meaning is defined as follows: |
54 * |
54 * |
55 * <DL> |
55 * <DL> |
56 * <DT> read |
56 * <DT> read |
57 * <DD> read permission. Allows <code>System.getProperty</code> to |
57 * <DD> read permission. Allows {@code System.getProperty} to |
58 * be called. |
58 * be called. |
59 * <DT> write |
59 * <DT> write |
60 * <DD> write permission. Allows <code>System.setProperty</code> to |
60 * <DD> write permission. Allows {@code System.setProperty} to |
61 * be called. |
61 * be called. |
62 * </DL> |
62 * </DL> |
63 * <P> |
63 * <P> |
64 * The actions string is converted to lowercase before processing. |
64 * The actions string is converted to lowercase before processing. |
65 * <P> |
65 * <P> |
147 * "read" and "write". |
147 * "read" and "write". |
148 * |
148 * |
149 * @param name the name of the PropertyPermission. |
149 * @param name the name of the PropertyPermission. |
150 * @param actions the actions string. |
150 * @param actions the actions string. |
151 * |
151 * |
152 * @throws NullPointerException if <code>name</code> is <code>null</code>. |
152 * @throws NullPointerException if {@code name} is {@code null}. |
153 * @throws IllegalArgumentException if <code>name</code> is empty or if |
153 * @throws IllegalArgumentException if {@code name} is empty or if |
154 * <code>actions</code> is invalid. |
154 * {@code actions} is invalid. |
155 */ |
155 */ |
156 public PropertyPermission(String name, String actions) { |
156 public PropertyPermission(String name, String actions) { |
157 super(name,actions); |
157 super(name,actions); |
158 init(getMask(actions)); |
158 init(getMask(actions)); |
159 } |
159 } |
221 } |
221 } |
222 |
222 |
223 /** |
223 /** |
224 * Returns the hash code value for this object. |
224 * Returns the hash code value for this object. |
225 * The hash code used is the hash code of this permissions name, that is, |
225 * The hash code used is the hash code of this permissions name, that is, |
226 * <code>getName().hashCode()</code>, where <code>getName</code> is |
226 * {@code getName().hashCode()}, where {@code getName} is |
227 * from the Permission superclass. |
227 * from the Permission superclass. |
228 * |
228 * |
229 * @return a hash code value for this object. |
229 * @return a hash code value for this object. |
230 */ |
230 */ |
231 @Override |
231 @Override |
348 |
348 |
349 /** |
349 /** |
350 * Returns the "canonical string representation" of the actions. |
350 * Returns the "canonical string representation" of the actions. |
351 * That is, this method always returns present actions in the following order: |
351 * That is, this method always returns present actions in the following order: |
352 * read, write. For example, if this PropertyPermission object |
352 * read, write. For example, if this PropertyPermission object |
353 * allows both write and read actions, a call to <code>getActions</code> |
353 * allows both write and read actions, a call to {@code getActions} |
354 * will return the string "read,write". |
354 * will return the string "read,write". |
355 * |
355 * |
356 * @return the canonical string representation of the actions. |
356 * @return the canonical string representation of the actions. |
357 */ |
357 */ |
358 @Override |
358 @Override |
383 @Override |
383 @Override |
384 public PermissionCollection newPermissionCollection() { |
384 public PermissionCollection newPermissionCollection() { |
385 return new PropertyPermissionCollection(); |
385 return new PropertyPermissionCollection(); |
386 } |
386 } |
387 |
387 |
388 |
388 @java.io.Serial |
389 private static final long serialVersionUID = 885438825399942851L; |
389 private static final long serialVersionUID = 885438825399942851L; |
390 |
390 |
391 /** |
391 /** |
392 * WriteObject is called to save the state of the PropertyPermission |
392 * WriteObject is called to save the state of the PropertyPermission |
393 * to a stream. The actions are serialized, and the superclass |
393 * to a stream. The actions are serialized, and the superclass |
394 * takes care of the name. |
394 * takes care of the name. |
395 */ |
395 */ |
|
396 @java.io.Serial |
396 private synchronized void writeObject(java.io.ObjectOutputStream s) |
397 private synchronized void writeObject(java.io.ObjectOutputStream s) |
397 throws IOException |
398 throws IOException |
398 { |
399 { |
399 // Write out the actions. The superclass takes care of the name |
400 // Write out the actions. The superclass takes care of the name |
400 // call getActions to make sure actions field is initialized |
401 // call getActions to make sure actions field is initialized |
405 |
406 |
406 /** |
407 /** |
407 * readObject is called to restore the state of the PropertyPermission from |
408 * readObject is called to restore the state of the PropertyPermission from |
408 * a stream. |
409 * a stream. |
409 */ |
410 */ |
|
411 @java.io.Serial |
410 private synchronized void readObject(java.io.ObjectInputStream s) |
412 private synchronized void readObject(java.io.ObjectInputStream s) |
411 throws IOException, ClassNotFoundException |
413 throws IOException, ClassNotFoundException |
412 { |
414 { |
413 // Read in the action, then initialize the rest |
415 // Read in the action, then initialize the rest |
414 s.defaultReadObject(); |
416 s.defaultReadObject(); |
459 * Adds a permission to the PropertyPermissions. The key for the hash is |
461 * Adds a permission to the PropertyPermissions. The key for the hash is |
460 * the name. |
462 * the name. |
461 * |
463 * |
462 * @param permission the Permission object to add. |
464 * @param permission the Permission object to add. |
463 * |
465 * |
464 * @exception IllegalArgumentException - if the permission is not a |
466 * @throws IllegalArgumentException if the permission is not a |
465 * PropertyPermission |
467 * PropertyPermission |
466 * |
468 * |
467 * @exception SecurityException - if this PropertyPermissionCollection |
469 * @throws SecurityException if this PropertyPermissionCollection |
468 * object has been marked readonly |
470 * object has been marked readonly |
469 */ |
471 */ |
470 @Override |
472 @Override |
471 public void add(Permission permission) { |
473 public void add(Permission permission) { |
472 if (! (permission instanceof PropertyPermission)) |
474 if (! (permission instanceof PropertyPermission)) |
594 * cannot be directly cast to Enumeration<Permission> |
596 * cannot be directly cast to Enumeration<Permission> |
595 */ |
597 */ |
596 return (Enumeration)perms.elements(); |
598 return (Enumeration)perms.elements(); |
597 } |
599 } |
598 |
600 |
|
601 @java.io.Serial |
599 private static final long serialVersionUID = 7015263904581634791L; |
602 private static final long serialVersionUID = 7015263904581634791L; |
600 |
603 |
601 // Need to maintain serialization interoperability with earlier releases, |
604 // Need to maintain serialization interoperability with earlier releases, |
602 // which had the serializable field: |
605 // which had the serializable field: |
603 // |
606 // |
623 /* |
626 /* |
624 * Writes the contents of the perms field out as a Hashtable for |
627 * Writes the contents of the perms field out as a Hashtable for |
625 * serialization compatibility with earlier releases. all_allowed |
628 * serialization compatibility with earlier releases. all_allowed |
626 * unchanged. |
629 * unchanged. |
627 */ |
630 */ |
|
631 @java.io.Serial |
628 private void writeObject(ObjectOutputStream out) throws IOException { |
632 private void writeObject(ObjectOutputStream out) throws IOException { |
629 // Don't call out.defaultWriteObject() |
633 // Don't call out.defaultWriteObject() |
630 |
634 |
631 // Copy perms into a Hashtable |
635 // Copy perms into a Hashtable |
632 Hashtable<String, Permission> permissions = |
636 Hashtable<String, Permission> permissions = |
642 |
646 |
643 /* |
647 /* |
644 * Reads in a Hashtable of PropertyPermissions and saves them in the |
648 * Reads in a Hashtable of PropertyPermissions and saves them in the |
645 * perms field. Reads in all_allowed. |
649 * perms field. Reads in all_allowed. |
646 */ |
650 */ |
|
651 @java.io.Serial |
647 private void readObject(ObjectInputStream in) |
652 private void readObject(ObjectInputStream in) |
648 throws IOException, ClassNotFoundException |
653 throws IOException, ClassNotFoundException |
649 { |
654 { |
650 // Don't call defaultReadObject() |
655 // Don't call defaultReadObject() |
651 |
656 |