Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Base64Decoder error(cryptic java file)
Base64Decoder error [message #1695986] Wed, 20 May 2015 17:46 Go to next message
Eclipse UserFriend
Greetings,
For the following code I am getting an error message. I have no clue what to do.
public String decrypt(String password) {
    try {
      // create the key and parameter spec
      KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, interactions);
      SecretKey key = SecretKeyFactory.getInstance(keyFormat).generateSecret(keySpec);
      AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, interactions);
      // create the cipher
      Cipher dcipher = Cipher.getInstance(key.getAlgorithm());
      dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
      byte[] dec = null;
      try {
        dec = Base64Coder.decode(cryptic);
      } catch(IllegalArgumentException ex) {
        // decode legacy files encoded with sun encoder
      dec = new sun.misc.BASE64Decoder().decodeBuffer(cryptic);
      }
      byte[] bytes = dcipher.doFinal(dec);
      return new String(bytes, encoding);
    } catch(Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }

The error is indicated by underline on the following line
dec = new sun.misc.BASE64Decoder().decodeBuffer(cryptic);

The error message is as follows:
Access restriction: The type 'BASE64Decoder" is not API (restriction on required library '/usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre/lib/rd.jar')
Re: Base64Decoder error [message #1696109 is a reply to message #1695986] Thu, 21 May 2015 17:11 Go to previous messageGo to next message
Eclipse UserFriend
The error means that the class you're using, sun.misc.BASE64Decoder, isn't meant to be used by you (or me, or anyone who isn't involved in the creation of rd.jar). It's possible to configure Eclipse to make that a warning, but it's a bad idea. See http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html

Instead, ...

Does java.util.Base64 work for you? That's new in Java 8.

[Updated on: Thu, 21 May 2015 17:12] by Moderator

Re: Base64Decoder error [message #1696171 is a reply to message #1696109] Fri, 22 May 2015 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Thanks for help. However, I am new to Eclipse and Java. I managed to do basic programs in Java, however, this code is from textbook I downloaded which is opensourcephysics It has a lot of classes and java files therefore Its new to me. Complete listing of this code that gives error is in attachment.
I need steps in troubleshooting this. I tried replacing
sun.misc.BASE64Decoder
in
dec = new sun.misc.BASE64Decoder().decodeBuffer(cryptic);
line with
java.util.Base64
but it does not work unless my approach to this problem is incorrect.
Re: Base64Decoder error [message #1696199 is a reply to message #1696171] Fri, 22 May 2015 17:21 Go to previous messageGo to next message
Eclipse UserFriend
Ok Adam, I understand. Not a problem. I'm happy to help as long as it doesn't interfere with my real job. Smile

So what I think you need to do in place of
dec = new sun.misc.BASE64Decoder().decodeBuffer(cryptic);

is:
dec = java.util.Base64.getMimeDecoder().decode(cryptic);
Re: Base64Decoder error [message #1696255 is a reply to message #1696199] Sun, 24 May 2015 11:44 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Eric,
But unfortunately the bug is still there. Probably something else is doing this but erroneously pointing me to this line. I do not know. It is really weird.
see the attachment.
I will try a banned method which is disabling eclipse to do that.
  • Attachment: pic4.bmp
    (Size: 3.75MB, Downloaded 402 times)
Re: Base64Decoder error [message #1696257 is a reply to message #1696199] Sun, 24 May 2015 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi Erick,
I used a banned approach to this problem with a little twist of my own.
I used the same old 'erroneous' java code line.

1) In Eclipse, I clicked on Window/Preferences/Java/Compiler/(Errors/Warnings)
2) On top of display click on 'Configure Project Specific Settings) then select your current project name
3) Then select Deprecated and restricted API
4) Then in " Forbidden reference (access rules) " switch from Error to Warning.
5) Click Okay.

clean, rebuild, and run.
It works for me so far, only for my specific project. Still I have 100's of warnings.
A little bite of forbidden apple will not hurt ... Rolling Eyes

Regards,
Adam

[Updated on: Sun, 24 May 2015 12:31] by Moderator

To Bug or Not to Bug. [message #1696259 is a reply to message #1696199] Sun, 24 May 2015 12:30 Go to previous message
Eclipse UserFriend
I observed something on screen which is repeatable and occasionally disappears.
The boxes overlap with label with other box in the control box. See pics in attachment.
  • Attachment: overlaps.pdf
    (Size: 152.21KB, Downloaded 286 times)
Previous Topic:Plug-in manifest editor-Extesions tab-right click
Next Topic:Eclipse Console vs JTextArea
Goto Forum:
  


Current Time: Mon Apr 21 02:04:32 EDT 2025

Powered by FUDForum. Page generated in 0.06641 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top