Ejemplo n.º 1
0
 /**
  * When user provides authfile explicitly using -Xauthfile we throw error otherwise show the
  * mesage by default with -Xdebug flag
  */
 private void error(SAXParseException e) {
   if (giveError) {
     errReceiver.error(e);
   } else {
     errReceiver.debug(e);
   }
 }
Ejemplo n.º 2
0
  private void parseAuth() {
    errReceiver.info(
        new SAXParseException(WscompileMessages.WSIMPORT_READING_AUTH_FILE(authFile), null));

    BufferedReader in;
    try {
      in = new BufferedReader(new InputStreamReader(new FileInputStream(authFile), "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      error(new SAXParseException(e.getMessage(), null));
      return;
    } catch (FileNotFoundException e) {
      error(
          new SAXParseException(
              WscompileMessages.WSIMPORT_AUTH_FILE_NOT_FOUND(authFile, defaultAuthfile), null, e));
      return;
    }
    String text;
    LocatorImpl locator = new LocatorImpl();
    try {
      int lineno = 1;

      locator.setSystemId(authFile.getCanonicalPath());

      while ((text = in.readLine()) != null) {
        locator.setLineNumber(lineno++);
        try {
          URL url = new URL(text);
          String authinfo = url.getUserInfo();

          if (authinfo != null) {
            int i = authinfo.indexOf(':');

            if (i >= 0) {
              String user = authinfo.substring(0, i);
              String password = authinfo.substring(i + 1);
              authInfo.add(new AuthInfo(new URL(text), user, password));
            } else {
              error(
                  new SAXParseException(
                      WscompileMessages.WSIMPORT_ILLEGAL_AUTH_INFO(url), locator));
            }
          } else {
            error(
                new SAXParseException(WscompileMessages.WSIMPORT_ILLEGAL_AUTH_INFO(url), locator));
          }

        } catch (NumberFormatException e) {
          error(new SAXParseException(WscompileMessages.WSIMPORT_ILLEGAL_AUTH_INFO(text), locator));
        }
      }
      in.close();
    } catch (IOException e) {
      error(
          new SAXParseException(
              WscompileMessages.WSIMPORT_FAILED_TO_PARSE(authFile, e.getMessage()), locator));
    }
  }