Package sun.misc

Examples of sun.misc.BASE64Encoder


            connection.disconnect();
        }

        //Authenticate
        connection = (HttpURLConnection) new URL("http://localhost:8181" + 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


        assert (hash.length==20);
        byte[] res = new byte[20+salt.length];
        System.arraycopy(hash, 0, res, 0, 20);
        System.arraycopy(salt, 0, res, 20, salt.length);

        BASE64Encoder encoder = new BASE64Encoder();
        String encoded = encoder.encode(res);

        String out = SSHA_TAG + encoded;
        return out;
    }
View Full Code Here

        String user = IdentityManager.getUser();
        String password = IdentityManager.getPassword();

        // encode user and password
        byte[] encodedPassword = (user + ":" + password).getBytes();
        BASE64Encoder encoder = new BASE64Encoder();
        String auth = encoder.encode(encodedPassword);
        conn.setRequestProperty("Authorization", "Basic " + auth);

        // create connection
        conn.connect();
View Full Code Here

            wr.write("Content-Length: " + bis.available() + "\r\n");
            wr.write("Content-Type: application/octet-stream\r\n");

            // add basic authentication header
            byte[] encodedPassword = (user + ":" + password).getBytes();
            BASE64Encoder encoder = new BASE64Encoder();
            wr.write("Authorization: Basic " + encoder.encode(encodedPassword) + "\r\n");
            wr.write("\r\n");
            wr.flush();

            // write upload file data
            byte[] buffer = new byte[1024*64];
 
View Full Code Here

  return ( AUTHORIZATION_TYPE + enc );
  }
 

  private static final String getBase64Encoded(String clearString) {
  return new BASE64Encoder().encode(clearString.getBytes());
  }
View Full Code Here

      byte[] bytes = password.getBytes();
      md.update(bytes);

      // Create the digest
      byte[] hashedResult = md.digest();
      outputString = "{SHA}" + new BASE64Encoder().encode(hashedResult);
    }
    catch (Exception e) {
      System.out.println("Error" + e);
    }
    return outputString;
View Full Code Here

        HttpURLConnection modified_connection = (HttpURLConnection) connection;

        // encode and set the authentication credentials
        modified_connection.setRequestProperty(AUTHORIZATIONHDR,
                AUTHORIZATIONTYPE
                        + (new BASE64Encoder()).encode(usernameandpassword
                                .getBytes()));

        // all done. This will be sent with the request now.
    }
View Full Code Here

            (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
        assertNotNull( servlet );

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" );
       
        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

                                                   "http://localhost/feeds/org/apache/archiva/artifact-two" ).getServlet();
        assertNotNull( servlet );

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/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

            (RssFeedServlet) client.newInvocation( "http://localhost/feeds/test-repo" ).getServlet();
        assertNotNull( servlet );

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" );
       
        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

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.