Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Base64Decoder error(cryptic java file)
Base64Decoder error [message #1695986] Wed, 20 May 2015 21:46 Go to next message
Adam Szewczyk is currently offline Adam SzewczykFriend
Messages: 6
Registered: May 2015
Junior Member
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 21:11 Go to previous messageGo to next message
Erick Hagstrom is currently offline Erick HagstromFriend
Messages: 107
Registered: April 2014
Location: USA
Senior Member
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 21:12]

Report message to a moderator

Re: Base64Decoder error [message #1696171 is a reply to message #1696109] Fri, 22 May 2015 14:17 Go to previous messageGo to next message
Adam Szewczyk is currently offline Adam SzewczykFriend
Messages: 6
Registered: May 2015
Junior Member
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 21:21 Go to previous messageGo to next message
Erick Hagstrom is currently offline Erick HagstromFriend
Messages: 107
Registered: April 2014
Location: USA
Senior Member
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 15:44 Go to previous messageGo to next message
Adam Szewczyk is currently offline Adam SzewczykFriend
Messages: 6
Registered: May 2015
Junior Member
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 370 times)
Re: Base64Decoder error [message #1696257 is a reply to message #1696199] Sun, 24 May 2015 16:16 Go to previous messageGo to next message
Adam Szewczyk is currently offline Adam SzewczykFriend
Messages: 6
Registered: May 2015
Junior Member
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 16:31]

Report message to a moderator

To Bug or Not to Bug. [message #1696259 is a reply to message #1696199] Sun, 24 May 2015 16:30 Go to previous message
Adam Szewczyk is currently offline Adam SzewczykFriend
Messages: 6
Registered: May 2015
Junior Member
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 246 times)
Previous Topic:Plug-in manifest editor-Extesions tab-right click
Next Topic:Eclipse Console vs JTextArea
Goto Forum:
  


Current Time: Thu Apr 25 04:10:00 GMT 2024

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

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

Back to the top