368 * Used by the PropertyPermissionCollection
369 *
370 * @return the actions mask.
371 */
372 int getMask() {
373 return mask;
374 }
375
376 /**
377 * Returns a new PermissionCollection object for storing
378 * PropertyPermission objects.
379 *
380 * @return a new PermissionCollection object suitable for storing
381 * PropertyPermissions.
382 */
383 @Override
384 public PermissionCollection newPermissionCollection() {
385 return new PropertyPermissionCollection();
386 }
387
388
389 private static final long serialVersionUID = 885438825399942851L;
390
391 /**
392 * WriteObject is called to save the state of the PropertyPermission
393 * to a stream. The actions are serialized, and the superclass
394 * takes care of the name.
395 */
396 private synchronized void writeObject(java.io.ObjectOutputStream s)
397 throws IOException
398 {
399 // Write out the actions. The superclass takes care of the name
400 // call getActions to make sure actions field is initialized
401 if (actions == null)
402 getActions();
403 s.defaultWriteObject();
404 }
405
406 /**
407 * readObject is called to restore the state of the PropertyPermission from
408 * a stream.
409 */
410 private synchronized void readObject(java.io.ObjectInputStream s)
411 throws IOException, ClassNotFoundException
412 {
413 // Read in the action, then initialize the rest
414 s.defaultReadObject();
415 init(getMask(actions));
416 }
417 }
418
419 /**
420 * A PropertyPermissionCollection stores a set of PropertyPermission
421 * permissions.
422 *
423 * @see java.security.Permission
424 * @see java.security.Permissions
425 * @see java.security.PermissionCollection
426 *
427 *
428 * @author Roland Schemers
429 *
579 // at the top (all_allowed), so we just return false
580 return false;
581 }
582
583 /**
584 * Returns an enumeration of all the PropertyPermission objects in the
585 * container.
586 *
587 * @return an enumeration of all the PropertyPermission objects.
588 */
589 @Override
590 @SuppressWarnings("unchecked")
591 public Enumeration<Permission> elements() {
592 /**
593 * Casting to rawtype since Enumeration<PropertyPermission>
594 * cannot be directly cast to Enumeration<Permission>
595 */
596 return (Enumeration)perms.elements();
597 }
598
599 private static final long serialVersionUID = 7015263904581634791L;
600
601 // Need to maintain serialization interoperability with earlier releases,
602 // which had the serializable field:
603 //
604 // Table of permissions.
605 //
606 // @serial
607 //
608 // private Hashtable permissions;
609 /**
610 * @serialField permissions java.util.Hashtable
611 * A table of the PropertyPermissions.
612 * @serialField all_allowed boolean
613 * boolean saying if "*" is in the collection.
614 */
615 private static final ObjectStreamField[] serialPersistentFields = {
616 new ObjectStreamField("permissions", Hashtable.class),
617 new ObjectStreamField("all_allowed", Boolean.TYPE),
618 };
619
620 /**
621 * @serialData Default fields.
622 */
623 /*
624 * Writes the contents of the perms field out as a Hashtable for
625 * serialization compatibility with earlier releases. all_allowed
626 * unchanged.
627 */
628 private void writeObject(ObjectOutputStream out) throws IOException {
629 // Don't call out.defaultWriteObject()
630
631 // Copy perms into a Hashtable
632 Hashtable<String, Permission> permissions =
633 new Hashtable<>(perms.size()*2);
634 permissions.putAll(perms);
635
636 // Write out serializable fields
637 ObjectOutputStream.PutField pfields = out.putFields();
638 pfields.put("all_allowed", all_allowed);
639 pfields.put("permissions", permissions);
640 out.writeFields();
641 }
642
643 /*
644 * Reads in a Hashtable of PropertyPermissions and saves them in the
645 * perms field. Reads in all_allowed.
646 */
647 private void readObject(ObjectInputStream in)
648 throws IOException, ClassNotFoundException
649 {
650 // Don't call defaultReadObject()
651
652 // Read in serialized fields
653 ObjectInputStream.GetField gfields = in.readFields();
654
655 // Get all_allowed
656 all_allowed = gfields.get("all_allowed", false);
657
658 // Get permissions
659 @SuppressWarnings("unchecked")
660 Hashtable<String, PropertyPermission> permissions =
661 (Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
662 perms = new ConcurrentHashMap<>(permissions.size()*2);
663 perms.putAll(permissions);
664 }
665 }
|
368 * Used by the PropertyPermissionCollection
369 *
370 * @return the actions mask.
371 */
372 int getMask() {
373 return mask;
374 }
375
376 /**
377 * Returns a new PermissionCollection object for storing
378 * PropertyPermission objects.
379 *
380 * @return a new PermissionCollection object suitable for storing
381 * PropertyPermissions.
382 */
383 @Override
384 public PermissionCollection newPermissionCollection() {
385 return new PropertyPermissionCollection();
386 }
387
388 @java.io.Serial
389 private static final long serialVersionUID = 885438825399942851L;
390
391 /**
392 * WriteObject is called to save the state of the PropertyPermission
393 * to a stream. The actions are serialized, and the superclass
394 * takes care of the name.
395 */
396 @java.io.Serial
397 private synchronized void writeObject(java.io.ObjectOutputStream s)
398 throws IOException
399 {
400 // Write out the actions. The superclass takes care of the name
401 // call getActions to make sure actions field is initialized
402 if (actions == null)
403 getActions();
404 s.defaultWriteObject();
405 }
406
407 /**
408 * readObject is called to restore the state of the PropertyPermission from
409 * a stream.
410 */
411 @java.io.Serial
412 private synchronized void readObject(java.io.ObjectInputStream s)
413 throws IOException, ClassNotFoundException
414 {
415 // Read in the action, then initialize the rest
416 s.defaultReadObject();
417 init(getMask(actions));
418 }
419 }
420
421 /**
422 * A PropertyPermissionCollection stores a set of PropertyPermission
423 * permissions.
424 *
425 * @see java.security.Permission
426 * @see java.security.Permissions
427 * @see java.security.PermissionCollection
428 *
429 *
430 * @author Roland Schemers
431 *
581 // at the top (all_allowed), so we just return false
582 return false;
583 }
584
585 /**
586 * Returns an enumeration of all the PropertyPermission objects in the
587 * container.
588 *
589 * @return an enumeration of all the PropertyPermission objects.
590 */
591 @Override
592 @SuppressWarnings("unchecked")
593 public Enumeration<Permission> elements() {
594 /**
595 * Casting to rawtype since Enumeration<PropertyPermission>
596 * cannot be directly cast to Enumeration<Permission>
597 */
598 return (Enumeration)perms.elements();
599 }
600
601 @java.io.Serial
602 private static final long serialVersionUID = 7015263904581634791L;
603
604 // Need to maintain serialization interoperability with earlier releases,
605 // which had the serializable field:
606 //
607 // Table of permissions.
608 //
609 // @serial
610 //
611 // private Hashtable permissions;
612 /**
613 * @serialField permissions java.util.Hashtable
614 * A table of the PropertyPermissions.
615 * @serialField all_allowed boolean
616 * boolean saying if "*" is in the collection.
617 */
618 private static final ObjectStreamField[] serialPersistentFields = {
619 new ObjectStreamField("permissions", Hashtable.class),
620 new ObjectStreamField("all_allowed", Boolean.TYPE),
621 };
622
623 /**
624 * @serialData Default fields.
625 */
626 /*
627 * Writes the contents of the perms field out as a Hashtable for
628 * serialization compatibility with earlier releases. all_allowed
629 * unchanged.
630 */
631 @java.io.Serial
632 private void writeObject(ObjectOutputStream out) throws IOException {
633 // Don't call out.defaultWriteObject()
634
635 // Copy perms into a Hashtable
636 Hashtable<String, Permission> permissions =
637 new Hashtable<>(perms.size()*2);
638 permissions.putAll(perms);
639
640 // Write out serializable fields
641 ObjectOutputStream.PutField pfields = out.putFields();
642 pfields.put("all_allowed", all_allowed);
643 pfields.put("permissions", permissions);
644 out.writeFields();
645 }
646
647 /*
648 * Reads in a Hashtable of PropertyPermissions and saves them in the
649 * perms field. Reads in all_allowed.
650 */
651 @java.io.Serial
652 private void readObject(ObjectInputStream in)
653 throws IOException, ClassNotFoundException
654 {
655 // Don't call defaultReadObject()
656
657 // Read in serialized fields
658 ObjectInputStream.GetField gfields = in.readFields();
659
660 // Get all_allowed
661 all_allowed = gfields.get("all_allowed", false);
662
663 // Get permissions
664 @SuppressWarnings("unchecked")
665 Hashtable<String, PropertyPermission> permissions =
666 (Hashtable<String, PropertyPermission>)gfields.get("permissions", null);
667 perms = new ConcurrentHashMap<>(permissions.size()*2);
668 perms.putAll(permissions);
669 }
670 }
|