1. /*
  2. * @(#)file PermissionImpl.java
  3. * @(#)author Sun Microsystems, Inc.
  4. * @(#)version 4.10
  5. * @(#)date 04/09/15
  6. *
  7. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  8. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  9. *
  10. */
  11. package com.sun.jmx.snmp.IPAcl;
  12. import java.io.Serializable;
  13. /**
  14. * Permission is represented as a String.
  15. *
  16. * @see java.security.acl.Permission
  17. * @version 4.10 12/19/03
  18. * @author Sun Microsystems, Inc
  19. */
  20. class PermissionImpl implements java.security.acl.Permission, Serializable {
  21. private String perm = null;
  22. /**
  23. * Constructs a permission.
  24. *
  25. * @param s the string representing the permission.
  26. */
  27. public PermissionImpl(String s) {
  28. perm = s;
  29. }
  30. public int hashCode() {
  31. return super.hashCode();
  32. }
  33. /**
  34. * Returns true if the object passed matches the permission represented in.
  35. *
  36. * @param p the Permission object to compare with.
  37. * @return true if the Permission objects are equal, false otherwise.
  38. */
  39. public boolean equals(Object p){
  40. if (p instanceof PermissionImpl){
  41. return perm.equals(((PermissionImpl)p).getString());
  42. } else {
  43. return false;
  44. }
  45. }
  46. /**
  47. * Prints a string representation of this permission.
  48. *
  49. * @return a string representation of this permission.
  50. */
  51. public String toString(){
  52. return perm.toString();
  53. }
  54. /**
  55. * Prints the permission.
  56. *
  57. * @return a string representation of this permission.
  58. */
  59. public String getString(){
  60. return perm;
  61. }
  62. }