Example #1
0
  private void init(GSSManagerImpl gssManager, Object appName, Oid appNameType, Oid mech)
      throws GSSException {

    this.gssManager = gssManager;
    this.elements = new HashMap<Oid, GSSNameSpi>(gssManager.getMechs().length);

    if (appName instanceof String) {
      this.appNameStr = (String) appName;
      /*
       * If appNameType is null, then the nametype for this printable
       * string is determined only by interrogating the
       * mechanism. Thus, defer the setting of printableName and
       * printableNameType till later.
       */
      if (appNameType != null) {
        printableName = appNameStr;
        printableNameType = appNameType;
      }
    } else {
      this.appNameBytes = (byte[]) appName;
    }

    this.appNameType = appNameType;

    mechElement = getElement(mech);

    /*
     * printableName will be null if appName was in a byte[] or if
     * appName was in a String but appNameType was null.
     */
    if (printableName == null) {
      printableName = mechElement.toString();
      printableNameType = mechElement.getStringNameType();
    }

    /*
     *  At this point the GSSNameImpl has the following set:
     *   appNameStr or appNameBytes
     *   appNameType (could be null)
     *   printableName
     *   printableNameType
     *   mechElement (which also exists in the hashmap of elements)
     */
  }