corba/src/share/classes/com/sun/corba/se/impl/naming/namingutil/CorbalocURL.java
author ohair
Tue, 25 May 2010 15:52:11 -0700
changeset 5555 b2b5ed3f0d0d
parent 4 02bb8761fcce
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     1
/*
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     2
 * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
02bb8761fcce Initial load
duke
parents:
diff changeset
     4
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
02bb8761fcce Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4
02bb8761fcce Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    10
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
02bb8761fcce Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
02bb8761fcce Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
02bb8761fcce Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
02bb8761fcce Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
02bb8761fcce Initial load
duke
parents:
diff changeset
    16
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
02bb8761fcce Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
02bb8761fcce Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
02bb8761fcce Initial load
duke
parents:
diff changeset
    20
 *
5555
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b2b5ed3f0d0d 6943119: Rebrand source copyright notices
ohair
parents: 4
diff changeset
    23
 * questions.
4
02bb8761fcce Initial load
duke
parents:
diff changeset
    24
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    25
02bb8761fcce Initial load
duke
parents:
diff changeset
    26
package com.sun.corba.se.impl.naming.namingutil;
02bb8761fcce Initial load
duke
parents:
diff changeset
    27
02bb8761fcce Initial load
duke
parents:
diff changeset
    28
import java.util.*;
02bb8761fcce Initial load
duke
parents:
diff changeset
    29
02bb8761fcce Initial load
duke
parents:
diff changeset
    30
import com.sun.corba.se.spi.logging.CORBALogDomains ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    31
import com.sun.corba.se.impl.logging.NamingSystemException ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    32
02bb8761fcce Initial load
duke
parents:
diff changeset
    33
/**
02bb8761fcce Initial load
duke
parents:
diff changeset
    34
 *  The corbaloc: URL definitions from the -ORBInitDef and -ORBDefaultInitDef's
02bb8761fcce Initial load
duke
parents:
diff changeset
    35
 *  will be parsed and converted to  this object. This object is capable of
02bb8761fcce Initial load
duke
parents:
diff changeset
    36
 *  storing multiple  Host profiles as defined in the CorbaLoc grammer.
02bb8761fcce Initial load
duke
parents:
diff changeset
    37
 *
02bb8761fcce Initial load
duke
parents:
diff changeset
    38
 *  @author  Hemanth
02bb8761fcce Initial load
duke
parents:
diff changeset
    39
 */
02bb8761fcce Initial load
duke
parents:
diff changeset
    40
public class CorbalocURL extends INSURLBase
02bb8761fcce Initial load
duke
parents:
diff changeset
    41
{
02bb8761fcce Initial load
duke
parents:
diff changeset
    42
    static NamingSystemException wrapper = NamingSystemException.get(
02bb8761fcce Initial load
duke
parents:
diff changeset
    43
        CORBALogDomains.NAMING_READ ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
    44
02bb8761fcce Initial load
duke
parents:
diff changeset
    45
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
    46
     * This constructor parses the URL and initializes all the variables. Once
02bb8761fcce Initial load
duke
parents:
diff changeset
    47
     * the URL Object is constructed it is immutable. URL parameter is a
02bb8761fcce Initial load
duke
parents:
diff changeset
    48
     * corbaloc: URL string with 'corbaloc:' prefix stripped.
02bb8761fcce Initial load
duke
parents:
diff changeset
    49
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
    50
    public CorbalocURL( String aURL ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    51
        String url = aURL;
02bb8761fcce Initial load
duke
parents:
diff changeset
    52
02bb8761fcce Initial load
duke
parents:
diff changeset
    53
        if( url != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    54
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
    55
                // First Clean the URL Escapes if there are any
02bb8761fcce Initial load
duke
parents:
diff changeset
    56
                url = Utility.cleanEscapes( url );
02bb8761fcce Initial load
duke
parents:
diff changeset
    57
            } catch( Exception e ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    58
                // There is something wrong with the URL escapes used
02bb8761fcce Initial load
duke
parents:
diff changeset
    59
                // so throw an exception
02bb8761fcce Initial load
duke
parents:
diff changeset
    60
                badAddress( e );
02bb8761fcce Initial load
duke
parents:
diff changeset
    61
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
    62
            int endIndex = url.indexOf( '/' );
02bb8761fcce Initial load
duke
parents:
diff changeset
    63
            if( endIndex == -1 ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    64
                // If there is no '/' then the endIndex is at the end of the URL
02bb8761fcce Initial load
duke
parents:
diff changeset
    65
                endIndex = url.length();
02bb8761fcce Initial load
duke
parents:
diff changeset
    66
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
    67
            // _REVISIT_: Add a testcase to check 'corbaloc:/'
02bb8761fcce Initial load
duke
parents:
diff changeset
    68
            if( endIndex == 0 )  {
02bb8761fcce Initial load
duke
parents:
diff changeset
    69
                // The url starts with a '/', it's an error
02bb8761fcce Initial load
duke
parents:
diff changeset
    70
                badAddress( null );
02bb8761fcce Initial load
duke
parents:
diff changeset
    71
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
    72
            // Anything between corbaloc: and / is the host,port information
02bb8761fcce Initial load
duke
parents:
diff changeset
    73
            // of the server where the Service Object is located
02bb8761fcce Initial load
duke
parents:
diff changeset
    74
            StringTokenizer endpoints = new StringTokenizer(
02bb8761fcce Initial load
duke
parents:
diff changeset
    75
                url.substring( 0, endIndex ), "," );
02bb8761fcce Initial load
duke
parents:
diff changeset
    76
            // NOTE:
02bb8761fcce Initial load
duke
parents:
diff changeset
    77
            // There should be atleast one token, because there are checks
02bb8761fcce Initial load
duke
parents:
diff changeset
    78
            // to make sure that there is host information before the
02bb8761fcce Initial load
duke
parents:
diff changeset
    79
            // delimiter '/'. So no need to explicitly check for number of
02bb8761fcce Initial load
duke
parents:
diff changeset
    80
            // tokens != 0
02bb8761fcce Initial load
duke
parents:
diff changeset
    81
            while( endpoints.hasMoreTokens( ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    82
                String endpointInfo = endpoints.nextToken();
02bb8761fcce Initial load
duke
parents:
diff changeset
    83
                IIOPEndpointInfo iiopEndpointInfo = null;
02bb8761fcce Initial load
duke
parents:
diff changeset
    84
                if( endpointInfo.startsWith( "iiop:" ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    85
                    iiopEndpointInfo = handleIIOPColon( endpointInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
    86
                } else if( endpointInfo.startsWith( "rir:" ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    87
                    handleRIRColon( endpointInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
    88
                    rirFlag = true;
02bb8761fcce Initial load
duke
parents:
diff changeset
    89
                } else if( endpointInfo.startsWith( ":" ) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    90
                    iiopEndpointInfo = handleColon( endpointInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
    91
                } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
    92
                    // Right now we are not allowing any other protocol
02bb8761fcce Initial load
duke
parents:
diff changeset
    93
                    // other than iiop:, rir: so raise exception indicating
02bb8761fcce Initial load
duke
parents:
diff changeset
    94
                    // that the URL is malformed
02bb8761fcce Initial load
duke
parents:
diff changeset
    95
                    badAddress( null );
02bb8761fcce Initial load
duke
parents:
diff changeset
    96
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
    97
                if ( rirFlag == false ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
    98
                    // Add the Host information if RIR flag is set,
02bb8761fcce Initial load
duke
parents:
diff changeset
    99
                    // If RIR is set then it means use the internal Boot
02bb8761fcce Initial load
duke
parents:
diff changeset
   100
                    // Strap protocol for Key String resolution
02bb8761fcce Initial load
duke
parents:
diff changeset
   101
                    if( theEndpointInfo == null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   102
                        theEndpointInfo = new java.util.ArrayList( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   103
                    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   104
                    theEndpointInfo.add( iiopEndpointInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
   105
                }
02bb8761fcce Initial load
duke
parents:
diff changeset
   106
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   107
            // If there is something after corbaloc:endpointInfo/
02bb8761fcce Initial load
duke
parents:
diff changeset
   108
            // then that is the keyString
02bb8761fcce Initial load
duke
parents:
diff changeset
   109
            if( url.length() > (endIndex + 1) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   110
                theKeyString = url.substring( endIndex + 1 );
02bb8761fcce Initial load
duke
parents:
diff changeset
   111
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   112
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   113
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   114
02bb8761fcce Initial load
duke
parents:
diff changeset
   115
02bb8761fcce Initial load
duke
parents:
diff changeset
   116
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   117
     *  A Utility method to throw BAD_PARAM exception to signal malformed
02bb8761fcce Initial load
duke
parents:
diff changeset
   118
     *  INS URL.
02bb8761fcce Initial load
duke
parents:
diff changeset
   119
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   120
    private void badAddress( java.lang.Throwable e )
02bb8761fcce Initial load
duke
parents:
diff changeset
   121
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   122
        throw wrapper.insBadAddress( e ) ;
02bb8761fcce Initial load
duke
parents:
diff changeset
   123
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   124
02bb8761fcce Initial load
duke
parents:
diff changeset
   125
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   126
     *  If there is 'iiop:' token in the URL, this method will parses
02bb8761fcce Initial load
duke
parents:
diff changeset
   127
     *  and  validates that host and port information.
02bb8761fcce Initial load
duke
parents:
diff changeset
   128
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   129
    private IIOPEndpointInfo handleIIOPColon( String iiopInfo )
02bb8761fcce Initial load
duke
parents:
diff changeset
   130
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   131
         // Check the iiop syntax
02bb8761fcce Initial load
duke
parents:
diff changeset
   132
         iiopInfo = iiopInfo.substring( NamingConstants.IIOP_LENGTH  );
02bb8761fcce Initial load
duke
parents:
diff changeset
   133
         return handleColon( iiopInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
   134
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   135
02bb8761fcce Initial load
duke
parents:
diff changeset
   136
02bb8761fcce Initial load
duke
parents:
diff changeset
   137
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   138
     * This is to handle the case of host information with no 'iiop:' prefix.
02bb8761fcce Initial load
duke
parents:
diff changeset
   139
     * instead if ':' is specified then iiop is assumed.
02bb8761fcce Initial load
duke
parents:
diff changeset
   140
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   141
    private IIOPEndpointInfo handleColon( String iiopInfo ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   142
         // String after ":"
02bb8761fcce Initial load
duke
parents:
diff changeset
   143
         iiopInfo = iiopInfo.substring( 1 );
02bb8761fcce Initial load
duke
parents:
diff changeset
   144
         String hostandport = iiopInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
   145
         // The format can be 1.2@<host>:<port>
02bb8761fcce Initial load
duke
parents:
diff changeset
   146
         StringTokenizer tokenizer = new StringTokenizer( iiopInfo, "@" );
02bb8761fcce Initial load
duke
parents:
diff changeset
   147
         IIOPEndpointInfo iiopEndpointInfo = new IIOPEndpointInfo( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   148
         int tokenCount = tokenizer.countTokens( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   149
         // There can be 1 or 2 tokens with '@' as the delimiter
02bb8761fcce Initial load
duke
parents:
diff changeset
   150
         //  - if there is only 1 token then there is no GIOP version
02bb8761fcce Initial load
duke
parents:
diff changeset
   151
         //    information.  A Default GIOP version of 1.2 is used.
02bb8761fcce Initial load
duke
parents:
diff changeset
   152
         //  - if there are 2 tokens then there is GIOP version is specified
02bb8761fcce Initial load
duke
parents:
diff changeset
   153
         //  - if there are no tokens or more than 2 tokens, then that's an
02bb8761fcce Initial load
duke
parents:
diff changeset
   154
         //    error
02bb8761fcce Initial load
duke
parents:
diff changeset
   155
         if( ( tokenCount == 0 )
02bb8761fcce Initial load
duke
parents:
diff changeset
   156
           ||( tokenCount > 2 ))
02bb8761fcce Initial load
duke
parents:
diff changeset
   157
         {
02bb8761fcce Initial load
duke
parents:
diff changeset
   158
             badAddress( null );
02bb8761fcce Initial load
duke
parents:
diff changeset
   159
         }
02bb8761fcce Initial load
duke
parents:
diff changeset
   160
         if( tokenCount == 2 ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   161
            // There is VersionInformation after iiop:
02bb8761fcce Initial load
duke
parents:
diff changeset
   162
            String version     = tokenizer.nextToken( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   163
            int dot = version.indexOf('.');
02bb8761fcce Initial load
duke
parents:
diff changeset
   164
            // There is a version without ., which means
02bb8761fcce Initial load
duke
parents:
diff changeset
   165
            // Malformed list
02bb8761fcce Initial load
duke
parents:
diff changeset
   166
            if (dot == -1) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   167
                badAddress( null );
02bb8761fcce Initial load
duke
parents:
diff changeset
   168
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   169
            try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   170
                iiopEndpointInfo.setVersion(
02bb8761fcce Initial load
duke
parents:
diff changeset
   171
                    Integer.parseInt( version.substring( 0, dot )),
02bb8761fcce Initial load
duke
parents:
diff changeset
   172
                    Integer.parseInt( version.substring(dot+1)) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   173
                hostandport = tokenizer.nextToken( );
02bb8761fcce Initial load
duke
parents:
diff changeset
   174
            } catch( Throwable e ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   175
                badAddress( e );
02bb8761fcce Initial load
duke
parents:
diff changeset
   176
            }
02bb8761fcce Initial load
duke
parents:
diff changeset
   177
         }
02bb8761fcce Initial load
duke
parents:
diff changeset
   178
         try {
02bb8761fcce Initial load
duke
parents:
diff changeset
   179
           // A Hack to differentiate IPV6 address
02bb8761fcce Initial load
duke
parents:
diff changeset
   180
           // from IPV4 address, Current Resolution
02bb8761fcce Initial load
duke
parents:
diff changeset
   181
           // is to use [ ] to differentiate ipv6 host
02bb8761fcce Initial load
duke
parents:
diff changeset
   182
           int squareBracketBeginIndex = hostandport.indexOf ( '[' );
02bb8761fcce Initial load
duke
parents:
diff changeset
   183
           if( squareBracketBeginIndex != -1 ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   184
               // ipv6Host should be enclosed in
02bb8761fcce Initial load
duke
parents:
diff changeset
   185
               // [ ], if not it will result in a
02bb8761fcce Initial load
duke
parents:
diff changeset
   186
               // BAD_PARAM exception
02bb8761fcce Initial load
duke
parents:
diff changeset
   187
               String ipv6Port = getIPV6Port( hostandport );
02bb8761fcce Initial load
duke
parents:
diff changeset
   188
               if( ipv6Port != null ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   189
                   iiopEndpointInfo.setPort( Integer.parseInt( ipv6Port ));
02bb8761fcce Initial load
duke
parents:
diff changeset
   190
               }
02bb8761fcce Initial load
duke
parents:
diff changeset
   191
               iiopEndpointInfo.setHost( getIPV6Host( hostandport ));
02bb8761fcce Initial load
duke
parents:
diff changeset
   192
               return iiopEndpointInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
   193
           }
02bb8761fcce Initial load
duke
parents:
diff changeset
   194
           tokenizer = new StringTokenizer( hostandport, ":" );
02bb8761fcce Initial load
duke
parents:
diff changeset
   195
           // There are three possible cases here
02bb8761fcce Initial load
duke
parents:
diff changeset
   196
           // 1. Host and Port is explicitly specified by using ":" as a
02bb8761fcce Initial load
duke
parents:
diff changeset
   197
           //    a separator
02bb8761fcce Initial load
duke
parents:
diff changeset
   198
           // 2. Only Host is specified without the port
02bb8761fcce Initial load
duke
parents:
diff changeset
   199
           // 3. HostAndPort info is null
02bb8761fcce Initial load
duke
parents:
diff changeset
   200
           if( tokenizer.countTokens( ) == 2 ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   201
               // Case 1: There is Host and Port Info
02bb8761fcce Initial load
duke
parents:
diff changeset
   202
               iiopEndpointInfo.setHost( tokenizer.nextToken( ) );
02bb8761fcce Initial load
duke
parents:
diff changeset
   203
               iiopEndpointInfo.setPort( Integer.parseInt(
02bb8761fcce Initial load
duke
parents:
diff changeset
   204
                   tokenizer.nextToken( )));
02bb8761fcce Initial load
duke
parents:
diff changeset
   205
           } else {
02bb8761fcce Initial load
duke
parents:
diff changeset
   206
               if( ( hostandport != null )
02bb8761fcce Initial load
duke
parents:
diff changeset
   207
                 &&( hostandport.length() != 0 ) )
02bb8761fcce Initial load
duke
parents:
diff changeset
   208
               {
02bb8761fcce Initial load
duke
parents:
diff changeset
   209
                   // Case 2: Only Host is specified. iiopEndpointInfo is
02bb8761fcce Initial load
duke
parents:
diff changeset
   210
                   // initialized to use the default INS port, if no port is
02bb8761fcce Initial load
duke
parents:
diff changeset
   211
                   // specified
02bb8761fcce Initial load
duke
parents:
diff changeset
   212
                   iiopEndpointInfo.setHost( hostandport );
02bb8761fcce Initial load
duke
parents:
diff changeset
   213
               }
02bb8761fcce Initial load
duke
parents:
diff changeset
   214
               // Case 3: If no Host and Port info is provided then we use the
02bb8761fcce Initial load
duke
parents:
diff changeset
   215
               // the default LocalHost and INSPort. iiopEndpointInfo is
02bb8761fcce Initial load
duke
parents:
diff changeset
   216
               // already initialized with this info.
02bb8761fcce Initial load
duke
parents:
diff changeset
   217
           }
02bb8761fcce Initial load
duke
parents:
diff changeset
   218
       } catch( Throwable e ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   219
           // Any kind of Exception is bad here.
02bb8761fcce Initial load
duke
parents:
diff changeset
   220
           // Possible causes: A Number Format exception because port info is
02bb8761fcce Initial load
duke
parents:
diff changeset
   221
           // malformed
02bb8761fcce Initial load
duke
parents:
diff changeset
   222
           badAddress( e );
02bb8761fcce Initial load
duke
parents:
diff changeset
   223
       }
02bb8761fcce Initial load
duke
parents:
diff changeset
   224
       Utility.validateGIOPVersion( iiopEndpointInfo );
02bb8761fcce Initial load
duke
parents:
diff changeset
   225
       return iiopEndpointInfo;
02bb8761fcce Initial load
duke
parents:
diff changeset
   226
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   227
02bb8761fcce Initial load
duke
parents:
diff changeset
   228
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   229
     *  Validate 'rir:' case.
02bb8761fcce Initial load
duke
parents:
diff changeset
   230
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   231
    private void handleRIRColon( String rirInfo )
02bb8761fcce Initial load
duke
parents:
diff changeset
   232
    {
02bb8761fcce Initial load
duke
parents:
diff changeset
   233
        if( rirInfo.length() != NamingConstants.RIRCOLON_LENGTH ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   234
            badAddress( null );
02bb8761fcce Initial load
duke
parents:
diff changeset
   235
        }
02bb8761fcce Initial load
duke
parents:
diff changeset
   236
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   237
02bb8761fcce Initial load
duke
parents:
diff changeset
   238
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   239
      * Returns an IPV6 Port that is after [<ipv6>]:. There is no validation
02bb8761fcce Initial load
duke
parents:
diff changeset
   240
      * done here, if it is an incorrect port then the request through
02bb8761fcce Initial load
duke
parents:
diff changeset
   241
      * this URL results in a COMM_FAILURE, otherwise malformed list will
02bb8761fcce Initial load
duke
parents:
diff changeset
   242
      * result in BAD_PARAM exception thrown in checkcorbalocGrammer.
02bb8761fcce Initial load
duke
parents:
diff changeset
   243
      */
02bb8761fcce Initial load
duke
parents:
diff changeset
   244
     private String getIPV6Port( String endpointInfo )
02bb8761fcce Initial load
duke
parents:
diff changeset
   245
     {
02bb8761fcce Initial load
duke
parents:
diff changeset
   246
         int squareBracketEndIndex = endpointInfo.indexOf ( ']' );
02bb8761fcce Initial load
duke
parents:
diff changeset
   247
         // If there is port information, then it has to be after ] bracket
02bb8761fcce Initial load
duke
parents:
diff changeset
   248
         // indexOf returns the count from the index of zero as the base, so
02bb8761fcce Initial load
duke
parents:
diff changeset
   249
         // equality check requires squareBracketEndIndex + 1.
02bb8761fcce Initial load
duke
parents:
diff changeset
   250
         if( (squareBracketEndIndex + 1) != (endpointInfo.length( )) ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   251
             if( endpointInfo.charAt( squareBracketEndIndex + 1 ) != ':' ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   252
                  throw new RuntimeException(
02bb8761fcce Initial load
duke
parents:
diff changeset
   253
                      "Host and Port is not separated by ':'" );
02bb8761fcce Initial load
duke
parents:
diff changeset
   254
             }
02bb8761fcce Initial load
duke
parents:
diff changeset
   255
             // PortInformation  should be after ']:' delimiter
02bb8761fcce Initial load
duke
parents:
diff changeset
   256
             // If there is an exception then it will be caught in
02bb8761fcce Initial load
duke
parents:
diff changeset
   257
             // checkcorbaGrammer method and rethrown as BAD_PARAM
02bb8761fcce Initial load
duke
parents:
diff changeset
   258
             return endpointInfo.substring( squareBracketEndIndex + 2 );
02bb8761fcce Initial load
duke
parents:
diff changeset
   259
         }
02bb8761fcce Initial load
duke
parents:
diff changeset
   260
         return null;
02bb8761fcce Initial load
duke
parents:
diff changeset
   261
     }
02bb8761fcce Initial load
duke
parents:
diff changeset
   262
02bb8761fcce Initial load
duke
parents:
diff changeset
   263
02bb8761fcce Initial load
duke
parents:
diff changeset
   264
     /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   265
      * Returns an IPV6 Host that is inside [ ] tokens. There is no validation
02bb8761fcce Initial load
duke
parents:
diff changeset
   266
      * done here, if it is an incorrect IPV6 address then the request through
02bb8761fcce Initial load
duke
parents:
diff changeset
   267
      * this URL results in a COMM_FAILURE, otherwise malformed list will
02bb8761fcce Initial load
duke
parents:
diff changeset
   268
      * result in BAD_PARAM exception thrown in checkcorbalocGrammer.
02bb8761fcce Initial load
duke
parents:
diff changeset
   269
      */
02bb8761fcce Initial load
duke
parents:
diff changeset
   270
     private String getIPV6Host( String endpointInfo ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   271
          // ipv6Host should be enclosed in
02bb8761fcce Initial load
duke
parents:
diff changeset
   272
          // [ ], if not it will result in a
02bb8761fcce Initial load
duke
parents:
diff changeset
   273
          // BAD_PARAM exception
02bb8761fcce Initial load
duke
parents:
diff changeset
   274
          int squareBracketEndIndex = endpointInfo.indexOf ( ']' );
02bb8761fcce Initial load
duke
parents:
diff changeset
   275
          // get the host between [ ]
02bb8761fcce Initial load
duke
parents:
diff changeset
   276
          String ipv6Host = endpointInfo.substring( 1, squareBracketEndIndex  );
02bb8761fcce Initial load
duke
parents:
diff changeset
   277
          return ipv6Host;
02bb8761fcce Initial load
duke
parents:
diff changeset
   278
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   279
02bb8761fcce Initial load
duke
parents:
diff changeset
   280
    /**
02bb8761fcce Initial load
duke
parents:
diff changeset
   281
     * Will be true only in CorbanameURL class.
02bb8761fcce Initial load
duke
parents:
diff changeset
   282
     */
02bb8761fcce Initial load
duke
parents:
diff changeset
   283
    public boolean isCorbanameURL( ) {
02bb8761fcce Initial load
duke
parents:
diff changeset
   284
        return false;
02bb8761fcce Initial load
duke
parents:
diff changeset
   285
    }
02bb8761fcce Initial load
duke
parents:
diff changeset
   286
02bb8761fcce Initial load
duke
parents:
diff changeset
   287
02bb8761fcce Initial load
duke
parents:
diff changeset
   288
}