Package sun.misc

Examples of sun.misc.BASE64Encoder.encode()


        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?groupId=org.apache.archiva&artifactId=artifact-two" );
       
        BASE64Encoder encoder = new BASE64Encoder();
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encode( userPass.getBytes() );       
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );       
       
        WebResponse response = client.getResponse( request );       
        assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) );
        assertNotNull( "Should have recieved a response", response );
View Full Code Here


       
        WebRequest request = new GetMethodWebRequest( "http://localhost/rss/rss_feeds?repoId=unauthorized-repo" );
       
        BASE64Encoder encoder = new BASE64Encoder();
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encode( userPass.getBytes() );       
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );       
       
        try
        {
            WebResponse response = client.getResponse( request );
View Full Code Here

    }

    byte[] raw = AIO.getAllData(fis);

    BASE64Encoder encoder = new BASE64Encoder();
    String u = encoder.encode(raw);

    contentArea.setText(u);

    // save encoded file
    fc = new JFileChooser(".");
View Full Code Here

          connection.setDoOutput(true);
          connection.setDoInput(true);
          connection.setUseCaches(false);
         
          BASE64Encoder encoder = new BASE64Encoder();
          String basicAuthHeader = "Basic " + encoder.encode((userName+":"+password).getBytes("UTF-8"));
          ((HttpURLConnection)connection).setRequestProperty("Authorization", basicAuthHeader);

          if (postData != null) {
        ((HttpURLConnection) connection).setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json");
View Full Code Here

    BASE64Encoder encoder = new BASE64Encoder();

    // let's create some dummy salt
    byte[] salt = new byte[8];
    random.nextBytes(salt);
    return encoder.encode(salt)+
      encoder.encode(userId.getBytes());
  }

     
  /**
 
View Full Code Here

    // let's create some dummy salt
    byte[] salt = new byte[8];
    random.nextBytes(salt);
    return encoder.encode(salt)+
      encoder.encode(userId.getBytes());
  }

     
  /**
   * Decrypts the string and removes the salt
View Full Code Here

      //encrypt login
      PBEParameterSpec paramSpec = new PBEParameterSpec(loginSalt, ITERATIONS);
      cipher.init(Cipher.ENCRYPT_MODE, secretKey,paramSpec);
      byte[] loginBytes = cipher.doFinal(login.getBytes());
      BASE64Encoder encoder = new BASE64Encoder();
      String loginToStore = URLEncoder.encode(encoder.encode(loginBytes),"UTF-8");
     
      //encrypt password
      paramSpec = new PBEParameterSpec(passwordSalt,ITERATIONS);
      cipher.init(Cipher.ENCRYPT_MODE, secretKey,paramSpec);
      byte[] passwordBytes = cipher.doFinal(password.getBytes());
View Full Code Here

     
      //encrypt password
      paramSpec = new PBEParameterSpec(passwordSalt,ITERATIONS);
      cipher.init(Cipher.ENCRYPT_MODE, secretKey,paramSpec);
      byte[] passwordBytes = cipher.doFinal(password.getBytes());
      String passwordToStore = URLEncoder.encode(encoder.encode(passwordBytes),"UTF-8");
     
     
      encryptedCredentials[0] = loginToStore;
      encryptedCredentials[1] = passwordToStore;
      return encryptedCredentials;
View Full Code Here

    }
   
    private static String encrypt(String password) {
        try {
            BASE64Encoder enc = new BASE64Encoder();
            return byteArrayToHexString(MessageDigest.getInstance("MD5").digest(enc.encode(password.getBytes("UTF-8")).getBytes("UTF-8")));
        } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
            Logger.getLogger(DatabaseKoppeling.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
View Full Code Here

   
    public static String encrypt(String password) {
        if(password == null) return null;
        try {
            BASE64Encoder enc = new BASE64Encoder();
            return byteArrayToHexString(MessageDigest.getInstance("MD5").digest(enc.encode(password.getBytes("UTF-8")).getBytes("UTF-8")));
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(DatabaseKoppeling.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(DatabaseKoppeling.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.