Package java.io

Examples of java.io.FileInputStream


    char[] pass =  AgentServer.getProperty(PASS, "changeit").toCharArray();
    String keyFile = AgentServer.getProperty(KEYFILE, ".keystore");

    KeyStore keystore = KeyStore.getInstance(AgentServer.getProperty(KTYPE, "JKS"));
    keystore.load(new FileInputStream(keyFile), pass);

    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    kmf.init(keystore, pass);

    TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
View Full Code Here


   */
  private static final byte[] readLicenseFileFromDisk(File licenseFile) throws IOException
  {
    byte[] returnByteArray = null;

    FileInputStream fileInputStream = new FileInputStream(licenseFile);
    DataInputStream dataInputStream = new DataInputStream(fileInputStream);
    try {
      returnByteArray = new byte[fileInputStream.available()];
      dataInputStream.readFully(returnByteArray);
    } finally {
      dataInputStream.close();
      fileInputStream.close();
    }
    return returnByteArray;
  } //end of readLicenseFileFromDisk method
View Full Code Here

            String path = arg.substring(0, split);
            if (split > 0) {
                InputStream is = null;
                try {
                    ports[i] = Integer.parseInt(arg.substring(split + 1));
                    is = new FileInputStream(path);
                    sdefs[i] = (ServiceDefinition)ctx.unmarshalDocument(is, null);
                } catch (NumberFormatException e) {
                    System.err.println("Error parsing port number in argument " + i + ": " + arg);
                    valid = false;
                } catch (FileNotFoundException e) {
View Full Code Here

        XMLStreamReader parser = null;
        if (contentString != null) {
            parser = StAXUtils.createXMLStreamReader(new StringReader(contentString));
        } else if (contentFile != null) {
            parser = StAXUtils.createXMLStreamReader(new FileInputStream(contentFile));
        }
       
        SOAPEnvelope envelope;
        if (parser != null) {
            if (contentIsEnvelope) {
View Full Code Here

        ProcessConf pconf = ((BPELEngineImpl)engine)._store.getProcessConfiguration(qName);

        try {
            File deployDir = new File(pconf.getBaseURI());
            File bpelDoc = new File(deployDir, pconf.getBpelDocument());
            return new FileInputStream(bpelDoc);
        } catch (FileNotFoundException e) {
            throw new RuntimeException("Faile to load bpel file", e);
        }
    }
View Full Code Here

    int type=ERROR;
    int vendor=VENDOR_OPENSSH;

    try{
      File file=new File(prvkey);
      FileInputStream fis=new FileInputStream(prvkey);
      byte[] buf=new byte[(int)(file.length())];
      int len=0;
      while(true){
        int i=fis.read(buf, len, buf.length-len);
        if(i<=0)
          break;
        len+=i;
      }
      fis.close();

      int i=0;

      while(i<len){
        if(buf[i]=='B'&& buf[i+1]=='E'&& buf[i+2]=='G'&& buf[i+3]=='I'){
          i+=6;     
          if(buf[i]=='D'&& buf[i+1]=='S'&& buf[i+2]=='A'){ type=DSA; }
    else if(buf[i]=='R'&& buf[i+1]=='S'&& buf[i+2]=='A'){ type=RSA; }
    else if(buf[i]=='S'&& buf[i+1]=='S'&& buf[i+2]=='H'){ // FSecure
      type=UNKNOWN;
      vendor=VENDOR_FSECURE;
    }
    else{
            //System.err.println("invalid format: "+identity);
      throw new JSchException("invalid privatekey: "+prvkey);
    }
          i+=3;
    continue;
  }
        if(buf[i]=='C'&& buf[i+1]=='B'&& buf[i+2]=='C'&& buf[i+3]==','){
          i+=4;
    for(int ii=0; ii<iv.length; ii++){
            iv[ii]=(byte)(((a2b(buf[i++])<<4)&0xf0)+(a2b(buf[i++])&0xf));
      }
    continue;
  }
  if(buf[i]==0x0d &&
     i+1<buf.length && buf[i+1]==0x0a){
    i++;
    continue;
  }
  if(buf[i]==0x0a && i+1<buf.length){
    if(buf[i+1]==0x0a){ i+=2; break; }
    if(buf[i+1]==0x0d &&
       i+2<buf.length && buf[i+2]==0x0a){
       i+=3; break;
    }
    boolean inheader=false;
    for(int j=i+1; j<buf.length; j++){
      if(buf[j]==0x0a) break;
      //if(buf[j]==0x0d) break;
      if(buf[j]==':'){inheader=true; break;}
    }
    if(!inheader){
      i++;
      encrypted=false;    // no passphrase
      break;
    }
  }
  i++;
      }

      if(type==ERROR){
  throw new JSchException("invalid privatekey: "+prvkey);
      }

      int start=i;
      while(i<len){
        if(buf[i]==0x0a){
    boolean xd=(buf[i-1]==0x0d);
          System.arraycopy(buf, i+1,
         buf,
         i-(xd ? 1 : 0),
         len-i-1-(xd ? 1 : 0)
         );
    if(xd)len--;
          len--;
          continue;
        }
        if(buf[i]=='-'){  break; }
        i++;
      }
      data=Util.fromBase64(buf, start, i-start);

      if(data.length>4 &&            // FSecure
   data[0]==(byte)0x3f &&
   data[1]==(byte)0x6f &&
   data[2]==(byte)0xf9 &&
   data[3]==(byte)0xeb){

  Buffer _buf=new Buffer(data);
  _buf.getInt()// 0x3f6ff9be
  _buf.getInt();
  byte[]_type=_buf.getString();
  //System.err.println("type: "+new String(_type));
  byte[] _cipher=_buf.getString();
  String cipher=Util.byte2str(_cipher);
  //System.err.println("cipher: "+cipher);
  if(cipher.equals("3des-cbc")){
       _buf.getInt();
     byte[] foo=new byte[data.length-_buf.getOffSet()];
     _buf.getByte(foo);
     data=foo;
     encrypted=true;
     throw new JSchException("unknown privatekey format: "+prvkey);
  }
  else if(cipher.equals("none")){
       _buf.getInt();
       _buf.getInt();

           encrypted=false;

     byte[] foo=new byte[data.length-_buf.getOffSet()];
     _buf.getByte(foo);
     data=foo;
  }
      }

      if(pubkey!=null){
  try{
    file=new File(pubkey);
    fis=new FileInputStream(pubkey);
    buf=new byte[(int)(file.length())];
          len=0;
          while(true){
            i=fis.read(buf, len, buf.length-len);
            if(i<=0)
              break;
            len+=i;
          }
    fis.close();

    if(buf.length>4 &&             // FSecure's public key
       buf[0]=='-' && buf[1]=='-' && buf[2]=='-' && buf[3]=='-'){

      boolean valid=true;
View Full Code Here

    @Override
    protected void initReaders() {
        try {
            eventAssignmentReader = new BufferedReader(
                    new InputStreamReader(new FileInputStream(new File(getFolder(), eventAssignmentFile)), "cp1252"));
        } catch (Exception ex) {
            logger.fatal("Konnte Datei nicht öffnen " + eventAssignmentFile, ex);
        }

        try {
            courseInstancesReader = new BufferedReader(
                    new InputStreamReader(new FileInputStream(new File(getFolder(), courseInstancesFile)), "cp1252"));
        } catch (Exception ex) {
            logger.fatal("Konnte Datei nicht öffnen " + courseInstancesFile, ex);
        }
    }
View Full Code Here

        super.setUp();
    }

    @Test
    public void testMain() throws Exception {
        new XmlImport(dataPool, settings, new FileInputStream(new File("/home/peterk/.timefinder/storage.xml"))).doWork();
        WorkloadOverviewCommand command = new WorkloadOverviewCommand();
        command.setSettings(settings);
        command.setDataPool(dataPool);
//        command.doOnce();
    }
View Full Code Here

    public void load() throws IOException {
        File xmlFile = getSettingsFile();
        SAXReader saxReader = new SAXReader();
        try {
            Document document = saxReader.read(new FileInputStream(xmlFile));

            List list = document.getRootElement().elements();
            Iterator iter = list.iterator();
            while (iter.hasNext()) {
                Element element = (Element) iter.next();
View Full Code Here

                            tr.get(ID + ".confirmation.title"), JOptionPane.OK_CANCEL_OPTION);
                    if (resultOP != JOptionPane.OK_OPTION) {
                        return;
                    }
                }
                istream = new FileInputStream(file);
            }
        } catch (Exception ex) {
            String errorMsg = "Cannot read file! " + ex.getLocalizedMessage();
            logger.fatal(errorMsg, ex);
            bar.setErrorMessage(errorMsg);
View Full Code Here

TOP

Related Classes of java.io.FileInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.