Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base64.encode()


           oos.writeObject(obj);
           oos.close();
           zos.close();
           baos.close();
           Base64 base64Codec = new Base64();
           return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
       }
       catch (IOException e)
       {
           log.fatal("Cannot encode Object with Base64", e);
           throw new FacesException(e);
View Full Code Here


     * @return the artifact
     */
    public static String createArtifact() {
        Base64 base64 = new Base64();
        String artifact = createRandomHexString(20);
        return new String(base64.encode(artifact.getBytes()));

    }

    /**
     * Consumes the artifact and returns it back (if it exists)
View Full Code Here

     */
    public static String storeArtifact(String userName) {
        long time = new Date().getTime() / MSECS_IN_SEC;
        Base64 base64 = new Base64();
        String artifact =
            new String(base64.encode(createRandomHexString(20).getBytes()));
        logger.debug("storeArtifact: storing artifact (" + artifact +
                     ") for user (" + userName + ") and time (" +
                     new Long(time).toString() + ")");
        createArtifactMap(artifact, userName, time);
        return artifact;
View Full Code Here

            oos.writeObject(obj);
            oos.close();
            zos.close();
            baos.close();
            Base64 base64Codec = new Base64();
            return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
        }
        catch (IOException e) {
            log.fatal("Cannot encode Object with Base64", e);
            throw new FacesException(e);
        }
View Full Code Here

            oos.writeObject(obj);
            oos.close();
            zos.close();
            baos.close();
            Base64 base64Codec = new Base64();
            return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
        }
        catch (IOException e)
        {
            log.fatal("Cannot encode Object with Base64", e);
            throw new FacesException(e);
View Full Code Here

               oos.writeObject(obj);
               oos.close();
               zos.close();
               baos.close();
               Base64 base64Codec = new Base64();
               return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
           }
           catch (IOException e)
           {
               log.fatal("Cannot encode Object with Base64", e);
               throw new FacesException(e);
View Full Code Here

            writer.close();
            zos.close();
            baos.close();

            Base64 base64Codec = new Base64();
            return new String(base64Codec.encode( baos.toByteArray() ), ZIP_CHARSET);
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
View Full Code Here

        request.addHeader( "User-Agent", "Apache Archiva unit test" );
        request.setMethod( "GET" );

        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();
        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

   * Encodes the given byte array.
   */
  public static String encodeBase64(byte[] buffer)
  {   
    Base64 encoder = new Base64();
    return new String(encoder.encode(buffer));
  }

  public static MimeParts parseMultipartRelatedMessage(String message, String httpHeaders, String encoding)
  {
    byte[] buffer = null;
View Full Code Here

        deflaterOutputStream.write(xmlBytes, 0, xmlBytes.length);
        deflaterOutputStream.close();

        // next, base64 encode it
        Base64 base64Encoder = new Base64();
        byte[] base64EncodedByteArray = base64Encoder.encode(byteOutputStream
          .toByteArray());
        return new String(base64EncodedByteArray);
    }
}
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.