Package java.net

Examples of java.net.MalformedURLException


            {
                url = f.getLocation().toFile().toURL();
            }
            else
            {
                throw new MalformedURLException("Unknown file " + loc);
            }
        }
        return url;
    }
View Full Code Here


         }
      }

      // Nothing found
      RmiConnectorActivator.log(LogService.LOG_DEBUG,"Could not find provider for protocol " + protocol + " in package list '" + packages + "'", null);
      throw new MalformedURLException("Could not find provider for protocol " + protocol + " in package list '" + packages + "'");
   }
View Full Code Here

        conn.setRequestMethod("GET");
        conn.setRequestProperty("Accept", "application/json");

        if (conn.getResponseCode() != 200) {
            throw new MalformedURLException("Non-200 response: " + conn.getResponseMessage());
        }

        return conn;
    }
View Full Code Here

  public static ImageIcon loadImageIcon(final String path) {
    try {
      final URL url = Class.class.getResource(path);

      if(url==null)
        throw new MalformedURLException(path);

      return new ImageIcon(url);
    }
    catch(final Exception e) {
      e.printStackTrace();
View Full Code Here

      {
         uri = getURI();
      }
      catch (URISyntaxException e)
      {
         throw new MalformedURLException();
      }

      try
      {
         return new URL(uri.toString());
View Full Code Here

        StringBuilder result = new StringBuilder(url.getProtocol());
        result.append("://");
       
        String host = url.getHost();
        if (host.length() == 0) {
            throw new MalformedURLException("URL without a domain: " + urlAsString);
        }
       
        result.append(host);
        int port = url.getPort();
        if ((port != -1) && (port != url.getDefaultPort())) {
View Full Code Here

      return new ClientSSK(origURI);
    if("KSK".equals(keyType))
      return ClientKSK.create(origURI.getDocName());
    if("USK".equals(keyType))
      return USK.create(origURI);
    throw new MalformedURLException("Unknown keytype from "+origURI);
  }
View Full Code Here

  public ClientSSK(String docName, byte[] pubKeyHash, byte[] extras, DSAPublicKey pubKey, byte[] cryptoKey) throws MalformedURLException {
    this.docName = docName;
    this.pubKey = pubKey;
    this.pubKeyHash = pubKeyHash;
    if(docName == null)
      throw new MalformedURLException("No document name.");
    if(extras == null)
      throw new MalformedURLException("No extra bytes in SSK - maybe a 0.5 key?");
    if(extras.length < 5)
      throw new MalformedURLException("Extra bytes too short: "+extras.length+" bytes");
    this.cryptoAlgorithm = extras[2];
    if(cryptoAlgorithm != Key.ALGO_AES_PCFB_256_SHA256)
      throw new MalformedURLException("Unknown encryption algorithm "+cryptoAlgorithm);
    if(!Arrays.equals(extras, getExtraBytes()))
      throw new MalformedURLException("Wrong extra bytes");
    if(pubKeyHash.length != NodeSSK.PUBKEY_HASH_SIZE)
      throw new MalformedURLException("Pubkey hash wrong length: "+pubKeyHash.length+" should be "+NodeSSK.PUBKEY_HASH_SIZE);
    if(cryptoKey.length != CRYPTO_KEY_LENGTH)
      throw new MalformedURLException("Decryption key wrong length: "+cryptoKey.length+" should be "+CRYPTO_KEY_LENGTH);
    MessageDigest md = SHA256.getMessageDigest();
    try {
      if (pubKey != null) {
        byte[] pubKeyAsBytes = pubKey.asBytes();
        md.update(pubKeyAsBytes);
View Full Code Here

  }
 
  public ClientSSK(FreenetURI origURI) throws MalformedURLException {
    this(origURI.getDocName(), origURI.getRoutingKey(), origURI.getExtra(), null, origURI.getCryptoKey());
    if(!origURI.getKeyType().equalsIgnoreCase("SSK"))
      throw new MalformedURLException();
  }
View Full Code Here

    public ClientCHK(byte[] routingKey, byte[] encKey, byte[] extra) throws MalformedURLException {
      this.routingKey = routingKey;
      this.cryptoKey = encKey;
        if((extra == null) || (extra.length < 5))
            throw new MalformedURLException("No extra bytes in CHK - maybe a 0.5 key?");
        // byte 0 is reserved, for now
        cryptoAlgorithm = extra[1];
    if(!(cryptoAlgorithm == Key.ALGO_AES_PCFB_256_SHA256 || cryptoAlgorithm == Key.ALGO_AES_CTR_256_SHA256))
      throw new MalformedURLException("Invalid crypto algorithm");
        controlDocument = (extra[2] & 0x02) != 0;
        compressionAlgorithm = (short)(((extra[3] & 0xff) << 8) + (extra[4] & 0xff));
        hashCode = Fields.hashCode(routingKey) ^ Fields.hashCode(cryptoKey) ^ compressionAlgorithm;
    }
View Full Code Here

TOP

Related Classes of java.net.MalformedURLException

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.