javacommons/gcfprotocols/socket/socket/javasrc/com/nokia/mj/impl/gcf/protocol/socket/SocketPermissionImpl.java
branchRCL_3
changeset 83 26b2b12093af
parent 71 d5e927d5853b
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
    23 import java.security.PermissionCollection;
    23 import java.security.PermissionCollection;
    24 import com.nokia.mj.impl.security.utils.SecurityPromptMessage;
    24 import com.nokia.mj.impl.security.utils.SecurityPromptMessage;
    25 
    25 
    26 public class SocketPermissionImpl extends PermissionBase
    26 public class SocketPermissionImpl extends PermissionBase
    27 {
    27 {
    28     /**
       
    29      * Constants for identifying the target/uri of connection: client or server
       
    30      */
       
    31      static String CLIENT_TARGET = "socket://*";
       
    32      static String SERVER_TARGET = "socket://";
       
    33 
       
    34      private String iTarget;
       
    35 
    28 
    36     /**
    29     /**
    37      * Returns the question (as localized text) associated with the security
    30      * Returns the question (as localized text) associated with the security
    38      * prompt
    31      * prompt
    39      *
    32      *
    41      */
    34      */
    42 
    35 
    43     public SocketPermissionImpl(String uri)
    36     public SocketPermissionImpl(String uri)
    44     {
    37     {
    45         super(uri);
    38         super(uri);
    46         iTarget = uri;
       
    47     }
    39     }
    48 
    40 
    49     public String getSecurityPromptQuestion(int aInteractionMode)
    41     public String getSecurityPromptQuestion(int aInteractionMode)
    50     {
    42     {
    51         // either provide own localized text
    43         // either provide own localized text
    61 
    53 
    62     }
    54     }
    63 
    55 
    64     public String toString()
    56     public String toString()
    65     {
    57     {
    66         if (SERVER_TARGET.equals(iTarget))
       
    67         {
       
    68             return "javax.microedition.io.Connector.serversocket";
       
    69         }
       
    70         return "javax.microedition.io.Connector.socket";
    58         return "javax.microedition.io.Connector.socket";
    71     }
    59     }
    72 
    60 
    73     public boolean implies(Permission p)
    61     public boolean implies(Permission p)
    74     {
    62     {
    75         if (p instanceof SocketPermissionImpl)
    63         if (p instanceof SocketPermissionImpl)
    76         {
    64         {
    77             SocketPermissionImpl o = (SocketPermissionImpl)p;
    65             return true;
    78             if ((iTarget != null && iTarget.equals(o.getTarget()))
       
    79                 || (iTarget == null && o.getTarget() == null))
       
    80             {
       
    81                 return true;
       
    82             }
       
    83         }
    66         }
    84         return false;
    67         return false;
    85     }
    68     }
    86 
    69 
    87     public boolean equals(Object obj)
    70     public boolean equals(Object obj)
   102     public PermissionCollection newPermissionCollection()
    85     public PermissionCollection newPermissionCollection()
   103     {
    86     {
   104         return null;
    87         return null;
   105     }
    88     }
   106 
    89 
   107     String getTarget()
       
   108     {
       
   109         return iTarget;
       
   110     }
       
   111 }
    90 }