You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by ri...@apache.org on 2007/02/01 20:19:26 UTC

svn commit: r502345 - /incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java

Author: rickmcguire
Date: Thu Feb  1 12:19:25 2007
New Revision: 502345

URL: http://svn.apache.org/viewvc?view=rev&rev=502345
Log:
YOKO-282 Improve the formatting of information from IORDump.

Full dump of the CSI_SEC_MECH information has been implemented. 


Modified:
    incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java

Modified: incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java?view=diff&rev=502345&r1=502344&r2=502345
==============================================================================
--- incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java (original)
+++ incubator/yoko/trunk/core/src/main/java/org/apache/yoko/orb/OB/IORUtil.java Thu Feb  1 12:19:25 2007
@@ -16,8 +16,183 @@
  */
 
 package org.apache.yoko.orb.OB;
+import org.omg.IOP.TaggedComponent;
 
 public final class IORUtil {
+    private static String describeCSISecMechList(org.omg.IOP.TaggedComponent component) {
+        String result = "";
+        byte[] coct = component.component_data;
+        int len = component.component_data.length;
+        org.apache.yoko.orb.OCI.Buffer buf = new org.apache.yoko.orb.OCI.Buffer(
+                coct, len);
+        org.apache.yoko.orb.CORBA.InputStream in = new org.apache.yoko.orb.CORBA.InputStream(
+                buf, 0, false);
+        in._OB_readEndian();
+        org.omg.CSIIOP.CompoundSecMechList info = org.omg.CSIIOP.CompoundSecMechListHelper.read(in);
+        
+        result += "CSI Security Mechanism List Components:\n"; 
+        result += "    stateful: " + info.stateful + "\n"; 
+        result += "    mechanism_list:\n"; 
+        for (int i = 0; i < info.mechanism_list.length; i++) {
+            org.omg.CSIIOP.CompoundSecMech mech = info.mechanism_list[i]; 
+            result += "        target_requires: " + describeTransportFlags(mech.target_requires) + "\n"; 
+            if (mech.transport_mech != null) {
+                if (mech.transport_mech.tag == org.omg.CSIIOP.TAG_NULL_TAG.value) {
+                    result += "            Null Transport\n"; 
+                } else if (mech.transport_mech.tag == org.omg.CSIIOP.TAG_TLS_SEC_TRANS.value) {
+                    result += describeTLS_SEC_TRANS(mech.transport_mech); 
+                } else if (mech.transport_mech.tag == org.omg.CSIIOP.TAG_SECIOP_SEC_TRANS.value) {
+                    result += describeSECIOP_SEC_TRANS(mech.transport_mech); 
+                }
+            }
+            
+            if (mech.as_context_mech != null) {
+                result += "            as_context_mech:\n"; 
+                result += "                supports: " + describeTransportFlags(mech.as_context_mech.target_supports) + "\n"; 
+                result += "                requires: " + describeTransportFlags(mech.as_context_mech.target_requires) + "\n"; 
+                result += "                client_authentication_mech: " + format_octets(mech.as_context_mech.client_authentication_mech) + "\n"; 
+                result += "                target_name: " + format_octets(mech.as_context_mech.target_name) + "\n"; 
+            }
+            
+            if (mech.sas_context_mech != null) {
+                result += "            sas_context_mech:\n"; 
+                result += "                supports: " + describeTransportFlags(mech.sas_context_mech.target_supports) + "\n"; 
+                result += "                requires: " + describeTransportFlags(mech.sas_context_mech.target_requires) + "\n"; 
+                result += "                privilege_authorities:\n";
+                for (i = 0; i < mech.sas_context_mech.privilege_authorities.length; i++) {
+                    org.omg.CSIIOP.ServiceConfiguration auth = mech.sas_context_mech.privilege_authorities[i];
+                    result += "                    syntax: " + auth.syntax + "\n"; 
+                    result += "                    name: " + format_octets(auth.name) + "\n"; 
+                }
+                result += "                supported_naming_mechanisms:\n";
+                for (i = 0; i < mech.sas_context_mech.supported_naming_mechanisms.length; i++) {
+                    result += "                    " + format_octets(mech.sas_context_mech.supported_naming_mechanisms[i]) + "\n"; 
+                }
+                result += "                supported_identity_type: " + describeIdentityToken(mech.sas_context_mech.supported_identity_types) + "\n";
+            }
+        }
+        return result; 
+    }
+    
+    
+    private static String describeTransportFlags(int flag) {
+        String result = "";
+
+        if ((org.omg.CSIIOP.NoProtection.value & flag) != 0) {
+            result += "NoProtection ";
+        }
+        if ((org.omg.CSIIOP.Integrity.value & flag) != 0) {
+            result += "Integrity ";
+        }
+        if ((org.omg.CSIIOP.Confidentiality.value & flag) != 0) {
+            result += "Confidentiality ";
+        }
+        if ((org.omg.CSIIOP.DetectReplay.value & flag) != 0) {
+            result += "DetectReplay ";
+        }
+        if ((org.omg.CSIIOP.DetectMisordering.value & flag) != 0) {
+            result += "DetectMisordering ";
+        }
+        if ((org.omg.CSIIOP.EstablishTrustInTarget.value & flag) != 0) {
+            result += "EstablishTrustInTarget ";
+        }
+        if ((org.omg.CSIIOP.EstablishTrustInClient.value & flag) != 0) {
+            result += "EstablishTrustInClient ";
+        }
+        if ((org.omg.CSIIOP.NoDelegation.value & flag) != 0) {
+            result += "NoDelegation ";
+        }
+        if ((org.omg.CSIIOP.SimpleDelegation.value & flag) != 0) {
+            result += "SimpleDelegation ";
+        }
+        if ((org.omg.CSIIOP.CompositeDelegation.value & flag) != 0) {
+            result += "CompositeDelegation ";
+        }
+        if ((org.omg.CSIIOP.IdentityAssertion.value & flag) != 0) {
+            result += "IdentityAssertion ";
+        }
+        if ((org.omg.CSIIOP.DelegationByClient.value & flag) != 0) {
+            result += "DelegationByClient ";
+        }
+        
+        return result; 
+    }
+    
+    
+    private static String describeIdentityToken(int flag) {
+        
+        if (flag == org.omg.CSI.ITTAbsent.value) {
+            return "Absent"; 
+        }
+        
+        String result = "";
+
+        if ((org.omg.CSI.ITTAnonymous.value & flag) != 0) {
+            result += "Anonymous ";
+        }
+        if ((org.omg.CSI.ITTPrincipalName.value & flag) != 0) {
+            result += "PrincipalName ";
+        }
+        if ((org.omg.CSI.ITTX509CertChain.value & flag) != 0) {
+            result += "X509CertChain ";
+        }
+        if ((org.omg.CSI.ITTDistinguishedName.value & flag) != 0) {
+            result += "DistinguishedName ";
+        }
+        
+        return result; 
+    }
+    
+    private static String describeTLS_SEC_TRANS(org.omg.IOP.TaggedComponent component) {
+        String result = "";
+        byte[] coct = component.component_data;
+        int len = component.component_data.length;
+        org.apache.yoko.orb.OCI.Buffer buf = new org.apache.yoko.orb.OCI.Buffer(
+                coct, len);
+        org.apache.yoko.orb.CORBA.InputStream in = new org.apache.yoko.orb.CORBA.InputStream(
+                buf, 0, false);
+        in._OB_readEndian();
+        org.omg.CSIIOP.TLS_SEC_TRANS info = org.omg.CSIIOP.TLS_SEC_TRANSHelper.read(in);
+        
+        result += "        TLS_SEC_TRANS component:\n"; 
+        result += "            target_supports: " + describeTransportFlags(info.target_supports) + "\n"; 
+        result += "            target_requires: " + describeTransportFlags(info.target_requires) + "\n"; 
+        result += "            addresses:\n"; 
+        for (int i = 0; i < info.addresses.length; i++) {
+            result += "                host_name: " + info.addresses[i].host_name + "\n"; 
+            result += "                port: " + info.addresses[i].port + "\n"; 
+        }
+        
+        return result; 
+    }
+    
+    private static String describeSECIOP_SEC_TRANS(org.omg.IOP.TaggedComponent component) {
+        String result = "";
+        byte[] coct = component.component_data;
+        int len = component.component_data.length;
+        org.apache.yoko.orb.OCI.Buffer buf = new org.apache.yoko.orb.OCI.Buffer(
+                coct, len);
+        org.apache.yoko.orb.CORBA.InputStream in = new org.apache.yoko.orb.CORBA.InputStream(
+                buf, 0, false);
+        in._OB_readEndian();
+        org.omg.CSIIOP.SECIOP_SEC_TRANS info = org.omg.CSIIOP.SECIOP_SEC_TRANSHelper.read(in);
+        
+        result += "        SECIOP_SEC_TRANS component:\n"; 
+        result += "            target_supports: " + describeTransportFlags(info.target_supports) + "\n"; 
+        result += "            target_requires: " + describeTransportFlags(info.target_requires) + "\n"; 
+        result += "            mech_oid: " + format_octets(info.mech_oid) + "\n"; 
+        result += "            target_name: " + format_octets(info.target_name) + "\n"; 
+        result += "            addresses:\n"; 
+        for (int i = 0; i < info.addresses.length; i++) {
+            result += "                host_name: " + info.addresses[i].host_name + "\n"; 
+            result += "                port: " + info.addresses[i].port + "\n"; 
+        }
+        
+        return result; 
+    }
+    
+    
+    
     private static String describeCodeSets(org.omg.IOP.TaggedComponent component) {
         String result = "";
         byte[] coct = component.component_data;
@@ -121,6 +296,13 @@
     //
     // Convert an octet buffer into human-friendly data dump
     //
+    public static String dump_octets(byte[] oct) {
+        return dump_octets(oct, 0, oct.length); 
+    }
+
+    //
+    // Convert an octet buffer into human-friendly data dump
+    //
     public static String dump_octets(byte[] oct, int offset, int count) {
         final int inc = 8;
 
@@ -159,6 +341,36 @@
     }
 
     //
+    // Convert an octet buffer into a single-line readable data dump. 
+    //
+    public static String format_octets(byte[] oct) {
+        return format_octets(oct, 0, oct.length); 
+    }
+
+    //
+    // Convert an octet buffer into a single-line readable data dump. 
+    //
+    public static String format_octets(byte[] oct, int offset, int count) {
+
+        StringBuffer result = new StringBuffer((count - offset) * 8);
+        result.append('"'); 
+
+        for (int i = offset; i < offset + count; i++) {
+            int n = (int) oct[i] & 0xff;
+            if (n >= 32 && n <= 127) {
+                result.append((char)n); 
+            }
+            else {
+                result.append('?'); 
+            }
+        }
+
+        result.append('"'); 
+
+        return result.toString();
+    }
+
+    //
     // Produce a human-friendly description of an IOR tagged component
     //
     public static String describe_component(
@@ -243,8 +455,7 @@
             break;
 
         case org.omg.IOP.TAG_CSI_SEC_MECH_LIST.value:
-            result = describeGenericComponent(component,
-                    "TAG_CSI_SEC_MECH_LIST");
+            result = describeCSISecMechList(component);
             break;
 
         case org.omg.IOP.TAG_OTS_POLICY.value: