Package com.substanceofcode.utils

Examples of com.substanceofcode.utils.Base64


           * Add authentication header in HTTP request. Basic authentication
           * should be formatted like this:
           *     Authorization: Basic QWRtaW46Zm9vYmFy
           */
          String userPass;
          Base64 b64 = new Base64();
          userPass = username + ":" + password;
          userPass = b64.encode(userPass.getBytes());
          m_hc.setRequestProperty("Authorization", "Basic " + userPass);
        }           
        int respCode = m_hc.getResponseCode();
        m_inputStream = m_hc.openInputStream();
        String respMsg = m_hc.getResponseMessage();
View Full Code Here


    this serialize does not need to know if Itunes is capable/enabled given
    that no fields were added to make it capable/enabled
    */
    public String serialize() {
        String preData = unencodedSerialize();
        Base64 b64 = new Base64();
        String encodedSerializedData = null;
    try {
      encodedSerializedData = b64.encode( preData.getBytes("UTF-8") );
    } catch (UnsupportedEncodingException e) {
      encodedSerializedData = b64.encode( preData.getBytes() );
    }
    return encodedSerializedData;
  }
View Full Code Here

  /** Deserialize the object **/
  public static RssItem deserialize(String encodedData)
  throws CauseMemoryException, CauseException {
    try {
      // Base64 decode
      Base64 b64 = new Base64();
      byte[] decodedData = b64.decode(encodedData);
      String data;
      try {
        data = new String( decodedData, "UTF-8" );
      } catch (UnsupportedEncodingException e) {
        data = new String( decodedData );
View Full Code Here

     
      int PASSWORD = 3;
      m_password = nodes[ startIndex + PASSWORD ];
      if (iTunesCapable) {
        // Dencode so that password is not in regular lettters.
        Base64 b64 = new Base64();
        byte[] decodedPassword = b64.decode(m_password);
        try {
          m_password = new String( decodedPassword , "UTF-8" );
        } catch (UnsupportedEncodingException e) {
          m_password = new String( decodedPassword );
        }
        if (hasPipe) {
          m_password = m_password.replace(CONE, '|');
        }
      }
     
      m_items = new Vector();
      if (firstSettings) {
        // Given the bugs with the first settings, we do not
        // retrieve the items so that we can restore them
        // without the bugs.
        return;
      }

      int ITEMS = (iTunesCapable ? ITUNES_ITEMS : 5);
      int UPDDATE = 4;
      String dateString = nodes[startIndex + UPDDATE];
      if(dateString.length()>0) {
        if (iTunesCapable) {
          m_upddate = new Date(Long.parseLong(dateString, 16));
        } else {
          m_upddate = new Date(Long.parseLong(dateString));
        }
      }
      if (iTunesCapable && hasPipe) {
        m_name = m_name.replace(CONE, '|');
      } else {
        if (!iTunesCapable) {
          // Dencode for better UTF-8 and to allow '|' in the name.
          // For iTunesCapable, replace | with (char)1
          Base64 b64 = new Base64();
          byte[] decodedName = b64.decode(m_name);
          try {
            m_name = new String( decodedName , "UTF-8" );
          } catch (UnsupportedEncodingException e) {
            m_name = new String( decodedName );
          }
View Full Code Here

    String name = m_name.replace('|', CONE);
    String username = m_username.replace('|' , CONE);
    String password = m_password.replace('|' , CONE);
    String encodedPassword;
    // Encode password to make reading password difficult
        Base64 b64 = new Base64();
    try {
      encodedPassword = b64.encode( m_password.getBytes("UTF-8") );
    } catch (UnsupportedEncodingException e) {
      encodedPassword = b64.encode( m_password.getBytes() );
    }
      String exInfoString;
    String updString;
    if (saveHdr) {
      String dateString;
View Full Code Here

    return preData;
  }

    public String serialize() {
        String preData = unencodedSerialize();
        Base64 b64 = new Base64();
        String encodedSerializedData = null;
    try {
      encodedSerializedData = b64.encode( preData.getBytes("UTF-8") );
    } catch (UnsupportedEncodingException e) {
      encodedSerializedData = b64.encode( preData.getBytes() );
    }
    return encodedSerializedData;
  }
View Full Code Here

  /** Deserialize the object */
  public static RssItem deserialize(String data)
  throws CauseMemoryException, CauseException {
    try {
      // Base64 decode
      Base64 b64 = new Base64();
      byte[] decodedData = b64.decode(data);
      try {
        data = new String( decodedData, "UTF-8" );
      } catch (UnsupportedEncodingException e) {
        data = new String( decodedData );
      }
View Full Code Here

    //#endif
    final String[] nitemArrayData = new String[itemArrayData.length];
    if (sencoded) {
      for (int ic = 0; ic < itemArrayData.length; ic++) {
        // Base64 decode
        Base64 b64 = new Base64();
        byte[] decodedData = b64.decode(itemArrayData[ic]);
        try {
          nitemArrayData[ic] = new String( decodedData, "UTF-8" );
        } catch (UnsupportedEncodingException e) {
          nitemArrayData[ic] = new String( decodedData );
        }
      }
      nodes[itemsOff] = StringUtil.join(nitemArrayData, RssFeed.CTWO, 0);
      nodes[itemsOff] = nodes[itemsOff].replace('|', RssFeed.CTHREE);
    } else {
      //#ifdef DTEST
      lngStart = System.currentTimeMillis();
      //#endif
      for (int ic = 0; ic < itemArrayData.length; ic++) {
        // Base64 decode
        Base64 b64 = new Base64();
        String data;
        try {
          nitemArrayData[ic] = b64.encode(
              itemArrayData[ic].getBytes("UTF-8") );
        } catch (UnsupportedEncodingException e) {
          nitemArrayData[ic] = b64.encode(
              itemArrayData[ic].getBytes() );
        }
      }
      //#ifdef DTEST
      encodeTime += System.currentTimeMillis() - lngStart;
View Full Code Here

           * Add authentication header in HTTP request. Basic authentication
           * should be formatted like this:
           *     Authorization: Basic QWRtaW46Zm9vYmFy
           */
          String userPass;
          Base64 b64 = new Base64();
          userPass = username + ":" + password;
          userPass = b64.encode(userPass.getBytes());
          m_hc.setRequestProperty("Authorization", "Basic " + userPass);
        }           
        int respCode = m_hc.getResponseCode();
        m_inputStream = m_hc.openInputStream();
        String respMsg = m_hc.getResponseMessage();
View Full Code Here

    //#endif
    final String[] nitemArrayData = new String[itemArrayData.length];
    if (sencoded) {
      for (int ic = 0; ic < itemArrayData.length; ic++) {
        // Base64 decode
        Base64 b64 = new Base64();
        byte[] decodedData = b64.decode(itemArrayData[ic]);
        try {
          nitemArrayData[ic] = new String( decodedData, "UTF-8" );
        } catch (UnsupportedEncodingException e) {
          nitemArrayData[ic] = new String( decodedData );
        }
      }
      nodes[itemsOff] = StringUtil.join(nitemArrayData, RssFeed.CTWO, 0);
      nodes[itemsOff] = nodes[itemsOff].replace('|', RssFeed.CTHREE);
    } else {
      //#ifdef DTEST
//@      lngStart = System.currentTimeMillis();
      //#endif
      for (int ic = 0; ic < itemArrayData.length; ic++) {
        // Base64 decode
        Base64 b64 = new Base64();
        String data;
        try {
          nitemArrayData[ic] = b64.encode(
              itemArrayData[ic].getBytes("UTF-8") );
        } catch (UnsupportedEncodingException e) {
          nitemArrayData[ic] = b64.encode(
              itemArrayData[ic].getBytes() );
        }
      }
      //#ifdef DTEST
//@      encodeTime += System.currentTimeMillis() - lngStart;
View Full Code Here

TOP

Related Classes of com.substanceofcode.utils.Base64

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.