javacommons/gcfprotocols/socket/socket/javasrc/com/nokia/mj/impl/gcf/protocol/socket/SocketPermissionImpl.java
branchRCL_3
changeset 27 d5e927d5853b
parent 26 2455ef1f5bbc
--- a/javacommons/gcfprotocols/socket/socket/javasrc/com/nokia/mj/impl/gcf/protocol/socket/SocketPermissionImpl.java	Wed Sep 01 12:33:18 2010 +0100
+++ b/javacommons/gcfprotocols/socket/socket/javasrc/com/nokia/mj/impl/gcf/protocol/socket/SocketPermissionImpl.java	Tue Sep 14 21:06:50 2010 +0300
@@ -25,6 +25,13 @@
 
 public class SocketPermissionImpl extends PermissionBase
 {
+    /**
+     * Constants for identifying the target/uri of connection: client or server
+     */
+     static String CLIENT_TARGET = "socket://*";
+     static String SERVER_TARGET = "socket://";
+
+     private String iTarget;
 
     /**
      * Returns the question (as localized text) associated with the security
@@ -36,6 +43,7 @@
     public SocketPermissionImpl(String uri)
     {
         super(uri);
+        iTarget = uri;
     }
 
     public String getSecurityPromptQuestion(int aInteractionMode)
@@ -55,6 +63,10 @@
 
     public String toString()
     {
+        if (SERVER_TARGET.equals(iTarget))
+        {
+            return "javax.microedition.io.Connector.serversocket";
+        }
         return "javax.microedition.io.Connector.socket";
     }
 
@@ -62,7 +74,12 @@
     {
         if (p instanceof SocketPermissionImpl)
         {
-            return true;
+            SocketPermissionImpl o = (SocketPermissionImpl)p;
+            if ((iTarget != null && iTarget.equals(o.getTarget()))
+                || (iTarget == null && o.getTarget() == null))
+            {
+                return true;
+            }
         }
         return false;
     }
@@ -87,4 +104,8 @@
         return null;
     }
 
+    String getTarget()
+    {
+        return iTarget;
+    }
 }
\ No newline at end of file