private void parseName(StringTokenizer st,boolean peer){
  List vals=new ArrayList(2);
  outer:   while (true) {
    String cls;
    do {
      if (!st.hasMoreTokens()) {
        break outer;
      }
      cls=st.nextToken();
    }
 while (cls.equals(" "));
    if (!peer && cls.equalsIgnoreCase("peer")) {
      parseName(st,true);
      break;
    }
    if (cls.equals("*")) {
      if (peer) {
        throw new IllegalArgumentException("peer class cannot be *");
      }
      cls=null;
      vals=null;
    }
    String nm;
    do {
      if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException("missing name after class");
      }
      nm=st.nextToken();
    }
 while (nm.equals(" "));
    if (!nm.startsWith("\"")) {
      throw new IllegalArgumentException("name must be in quotes");
    }
    while (!nm.endsWith("\"")) {
      if (!st.hasMoreTokens()) {
        throw new IllegalArgumentException("name must be in quotes");
      }
      nm=nm + st.nextToken();
    }
    if (nm.equals("\"*\"")) {
      if (peer) {
        throw new IllegalArgumentException("peer name cannot be \"*\"");
      }
      if (cls == null) {
        continue;
      }
      nm=null;
    }
 else     if (cls == null) {
      throw new IllegalArgumentException("class cannot be * unless name is \"*\"");
    }
 else {
      nm=nm.substring(1,nm.length() - 1);
    }
    if (vals != null) {
      for (int i=vals.size(); i > 0; ) {
        String onm=(String)vals.get(--i);
        String ocls=(String)vals.get(--i);
        if (cls.equals(ocls)) {
          if (onm == null || (onm != null && onm.equals(nm))) {
            continue outer;
          }
 else           if (nm == null) {
            vals.remove(i);
            vals.remove(i);
          }
        }
      }
      vals.add(cls);
      vals.add(nm);
    }
  }
  String[] res=null;
  if (vals != null) {
    if (vals.isEmpty()) {
      throw new IllegalArgumentException("target name is missing elements");
    }
    res=(String[])vals.toArray(new String[vals.size()]);
  }
  if (peer) {
    this.peer=res;
  }
 else {
    this.me=res;
  }
}

private void parseName ( StringTokenizer st , boolean peer ) { List vals = new ArrayList ( 2 ) ; outer : while ( true ) { String cls ; do { if ( ! st . hasMoreTokens ( ) ) { break outer ; } cls = st . nextToken ( ) ; } while ( cls . equals ( " " ) ) ; if ( ! peer && cls . equalsIgnoreCase ( "peer" ) ) { parseName ( st , true ) ; break ; } if ( cls . equals ( "*" ) ) { if ( peer ) { throw new IllegalArgumentException ( "peer class cannot be *" ) ; } cls = null ; vals = null ; } String nm ; do { if ( ! st . hasMoreTokens ( ) ) { throw new IllegalArgumentException ( "missing name after class" ) ; } nm = st . nextToken ( ) ; } while ( nm . equals ( " " ) ) ; if ( ! nm . startsWith ( "\"" ) ) { throw new IllegalArgumentException ( "name must be in quotes" ) ; } while ( ! nm . endsWith ( "\"" ) ) { if ( ! st . hasMoreTokens ( ) ) { throw new IllegalArgumentException ( "name must be in quotes" ) ; } nm = nm + st . nextToken ( ) ; } if ( nm . equals ( "\"*\"" ) ) { if ( peer ) { throw new IllegalArgumentException ( "peer name cannot be \"*\"" ) ; } if ( cls == null ) { continue ; } nm = null ; } else if ( cls == null ) { throw new IllegalArgumentException ( "class cannot be * unless name is \"*\"" ) ; } else { nm = nm . substring ( 1 , nm . length ( ) - 1 ) ; } if ( vals != null ) { for ( int i = vals . size ( ) ; i > 0 ; ) { String onm = ( String ) vals . get ( -- i ) ; String ocls = ( String ) vals . get ( -- i ) ; if ( cls . equals ( ocls ) ) { if ( onm == null || ( onm != null && onm . equals ( nm ) ) ) { continue outer ; } else if ( nm == null ) { vals . remove ( i ) ; vals . remove ( i ) ; } } } vals . add ( cls ) ; vals . add ( nm ) ; } } String [ ] res = null ; if ( vals != null ) { if ( vals . isEmpty ( ) ) { throw new IllegalArgumentException ( "target name is missing elements" ) ; } res = ( String [ ] ) vals . toArray ( new String [ vals . size ( ) ] ) ; } if ( peer ) { this . peer = res ; } else { this . me = res ; } }
parses what ' s left of the target name in the specified tokenizer , and initializes the transient fields . peer is false when parsing the local principals , true when parsing the peer principals .
