Package sun.misc

Examples of sun.misc.BASE64Encoder


   
    public static void downloadUrl(final String url) throws IOException {
        final URL downloader = new URL(url);
        final URLConnection urlConnection = downloader.openConnection();
        if (null != downloader.getUserInfo()) {
            BASE64Encoder encoder = new BASE64Encoder();
            final String basicAuth = "Basic " + new String(encoder.encode(
                    downloader.getUserInfo().getBytes()));
            urlConnection.setRequestProperty("Authorization", basicAuth);
        }
        final BufferedReader inputStream = new BufferedReader(new InputStreamReader(
                urlConnection.getInputStream()));
View Full Code Here


   * @param key
   * @return
   * @throws Exception
   */
  public static String encryptBASE64(byte[] key) throws Exception {
    return (new BASE64Encoder()).encodeBuffer(key);
  }
View Full Code Here

   * @param key
   * @return
   * @throws Exception
   */
  public static String encryptBASE64(byte[] key) throws Exception {
    return (new BASE64Encoder()).encodeBuffer(key);
  }
View Full Code Here

    }

    private String base64EncodePolicy(JsonElement jsonElement) throws UnsupportedEncodingException
    {
        String policyJsonStr = jsonElement.toString();
        String base64Encoded = (new BASE64Encoder()).encode(policyJsonStr.getBytes("UTF-8")).replaceAll("\n","").replaceAll("\r", "");

        return base64Encoded;
    }
View Full Code Here

    private String sign(String toSign) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException
    {
        Mac hmac = Mac.getInstance("HmacSHA1");
        hmac.init(new SecretKeySpec(AWS_SECRET_KEY.getBytes("UTF-8"), "HmacSHA1"));
        String signature = (new BASE64Encoder()).encode(hmac.doFinal(toSign.getBytes("UTF-8"))).replaceAll("\n", "");

        return signature;
    }
View Full Code Here

           connection.disconnect();
       }

       //Authenticate
       connection = (HttpURLConnection) new URL("http://localhost:8080" + contextPath).openConnection();
       String authentication = (new BASE64Encoder()).encode(("alan:starcraft").getBytes());
       connection.setRequestProperty("Authorization", "Basic " + authentication);
       try {
           BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
           assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
           assertEquals("Hello World", reader.readLine());
View Full Code Here

    private final Log log;

    public YoutrackClient(String url, String project, String username, String password, Log log) {
        this.url = url;
        this.project = project;
        this.authorization = new BASE64Encoder().encode((username + ":" + password).getBytes());
        this.log = log;
    }
View Full Code Here

      {
         SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
         random.setSeed(System.currentTimeMillis());
         byte bytes[] = new byte[32];
         random.nextBytes(bytes);
         BASE64Encoder encoder = new BASE64Encoder();
         return encoder.encode(bytes);
      }
      catch (NoSuchAlgorithmException e)
      {
         throw new AssertionError(e);
      }
View Full Code Here

            // that gives us fragmented answers.
            conn.setRequestProperty("Connection", "close");
            // BASIC AUTH
            if (userPassword != null)
            {
                conn.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode(userPassword.getBytes()));
            }
            // Read response
            InputStream is = null;
            if (conn.getResponseCode() == 200)
            {
View Full Code Here

  public static byte[] decode(String pValue) throws IOException {
    return (new BASE64Decoder()).decodeBuffer(pValue);
  }

  public static String encode(byte[] pValue) {
    return (new BASE64Encoder()).encode(pValue);
  }
View Full Code Here

TOP

Related Classes of sun.misc.BASE64Encoder

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.