Base64 class

Here is a Base64 class. I'm not the author, but it's not important, the important thing is that you can use it for encode and decode. It's very useful!!!. Enjoy it!!.
package yourPackage;
import java.io.*; // needed only for main() method.
* Provides encoding of raw bytes to base64-encoded characters, and
* decoding of base64 characters to raw bytes.
public class Base64
* returns an array of base64-encoded characters to represent the
* passed data array.
* @param data the array of bytes to encode
* @return base64-coded character array.
static public char[] encode(byte[] data)
char[] out = new char[((data.length + 2) / 3) * 4];
// 3 bytes encode to 4 chars. Output is always an even
// multiple of 4 characters.
for (int i = 0, index = 0; i < data.length; i += 3, index += 4)
boolean quad = false;
boolean trip = false;
int val = (0xFF & (int) data);
val <<= 8;
if ((i + 1) < data.length)
val |= (0xFF & (int) data[i + 1]);
trip = true;
val <<= 8;
if ((i + 2) < data.length)
val |= (0xFF & (int) data[i + 2]);
quad = true;
out[index + 3] = alphabet[(quad ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 2] = alphabet[(trip ? (val & 0x3F) : 64)];
val >>= 6;
out[index + 1] = alphabet[val & 0x3F];
val >>= 6;
out[index + 0] = alphabet[val & 0x3F];
return out;
* Decodes a BASE-64 encoded stream to recover the original
* data. White space before and after will be trimmed away,
* but no other manipulation of the input will be performed.
* As of version 1.2 this method will properly handle input
* containing junk characters (newlines and the like) rather
* than throwing an error. It does this by pre-parsing the
* input and generating from that a count of VALID input
* characters.
static public byte[] decode(char[] data)
// as our input could contain non-BASE64 data (newlines,
// whitespace of any sort, whatever) we must first adjust
// our count of USABLE data so that...
// (a) we don't misallocate the output array, and
// (b) think that we miscalculated our data length
// just because of extraneous throw-away junk
int tempLen = data.length;
for (int ix = 0; ix < data.length; ix++)
if ((data[ix] > 255) || codes[data[ix]] < 0)
--tempLen; // ignore non-valid chars and padding
// calculate required length:
// -- 3 bytes for every 4 valid base64 chars
// -- plus 2 bytes if there are 3 extra base64 chars,
// or plus 1 byte if there are 2 extra.
int len = (tempLen / 4) * 3;
if ((tempLen % 4) == 3)
len += 2;
if ((tempLen % 4) == 2)
len += 1;
byte[] out = new byte[len];
int shift = 0; // # of excess bits stored in accum
int accum = 0; // excess bits
int index = 0;
// we now go through the entire array (NOT using the 'tempLen' value)
for (int ix = 0; ix < data.length; ix++)
int value = (data[ix] > 255) ? -1 : codes[data[ix]];
if (value >= 0)// skip over non-code
accum <<= 6; // bits shift up by 6 each time thru
shift += 6; // loop, with new bits being put in
accum |= value; // at the bottom.
if (shift >= 8)// whenever there are 8 or more shifted in,
shift -= 8; // write them out (from the top, leaving any
out[index++] = // excess at the bottom for next iteration.
(byte)((accum >> shift) & 0xff);
// we will also have skipped processing a padding null byte ('=') here;
// these are used ONLY for padding to an even length and do not legally
// occur as encoded data. for this reason we can ignore the fact that
// no index++ operation occurs in that special case: the out[] array is
// initialized to all-zero bytes to start with and that works to our
// advantage in this combination.
// if there is STILL something wrong we just have to throw up now!
if (index != out.length)
throw new Error("Miscalculated data length (wrote " +
index + " instead of " + out.length + ")");
return out;
// code characters for values 0..63
static private char[] alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" .toCharArray();
// lookup table for converting base64 characters to value in range 0..63
static private byte[] codes = new byte[256];
static
for (int i = 0; i < 256; i++)
codes[i] = -1;
for (int i = 'A'; i <= 'Z'; i++)
codes[i] = (byte)(i - 'A');
for (int i = 'a'; i <= 'z'; i++)
codes[i] = (byte)(26 + i - 'a');
for (int i = '0'; i <= '9'; i++)
codes[i] = (byte)(52 + i - '0');
codes['+'] = 62;
codes['/'] = 63;
public static void main(String[] args)
boolean decode = false;
if (args.length == 0)
System.out.println("usage: java Base64 [-d[ecode]] filename");
System.exit(0);
for (int i = 0; i < args.length; i++)
if ("-decode".equalsIgnoreCase(args[i]))
decode = true;
else if ("-d".equalsIgnoreCase(args[i]))
decode = true;
String filename = args[args.length - 1];
File file = new File(filename);
if (!file.exists())
System.out.println("Error: file '" + filename + "' doesn't exist!");
System.exit(0);
if (decode)
char[] encoded = readChars(file);
byte[] decoded = decode(encoded);
writeBytes(file, decoded);
else
byte[] decoded = readBytes(file);
char[] encoded = encode(decoded);
writeChars(file, encoded);
* @param file
* @return
private static byte[] readBytes(File file)
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
InputStream fis = new FileInputStream(file);
InputStream is = new BufferedInputStream(fis);
int count = 0;
byte[] buf = new byte[16384];
while ((count = is.read(buf)) != -1)
if (count > 0)
baos.write(buf, 0, count);
is.close();
catch (Exception e)
e.printStackTrace();
return baos.toByteArray();
* @param file
* @return
private static char[] readChars(File file)
CharArrayWriter caw = new CharArrayWriter();
try
Reader fr = new FileReader(file);
Reader in = new BufferedReader(fr);
int count = 0;
char[] buf = new char[16384];
while ((count = in.read(buf)) != -1)
if (count > 0)
caw.write(buf, 0, count);
in.close();
catch (Exception e)
e.printStackTrace();
return caw.toCharArray();
* @param file
* @param data
private static void writeBytes(File file, byte[] data)
try
OutputStream fos = new FileOutputStream(file);
OutputStream os = new BufferedOutputStream(fos);
os.write(data);
os.close();
catch (Exception e)
e.printStackTrace();
* @param file
* @param data
private static void writeChars(File file, char[] data)
try
Writer fos = new FileWriter(file);
Writer os = new BufferedWriter(fos);
os.write(data);
os.close();
catch (Exception e)
e.printStackTrace();

Ok.
The main reason of my message was that in the beginning I didn't know anything for Base64 class and I needed one for my project. I was looking for it and when I had found it I thought in do post a new topic in this forum to help to the people that they should have the same problem. Now I can see more solutions for this issue.
Thank you very much.
Bye

Similar Messages

  • XML Parsing Base64 Content - Special Characters Umlaut etc

    Hello!
    I am currently parsing an XML file which has it's content encoded in Base64. My application parses the XML file (from a provider) and pass on the content to a GUI where the user can change the value of the nodes and store the same back in a new XML (which is then to be sent back to the provider). The Application uses only "UTF-8" . I am currently using the Base64 class provided at http://iharder.net/base64
    The problem I have is that the special characters like �, � etc, are being depicted as (?) i.e. unreadable. Only when I control the decoding process i.e. String resoolt = new String (result.getBytes(), "UTF-8") do I get the correct content, and the same can be posted on the GUI.
    The application produces an XML file (The application in question is a translation app), which when re-opened in the application for retranslation has the same problem... it is shown with teh special characters with (?).
    After a lot of debugging I found that the XML produced by the application does not need the forcing of content into UTF-8 using the code above, it is read automatically correctly (with all the content correct), but due to the coding I have done... String resoolt = new String (result.getBytes(), "UTF-8") the nodes are decoded with the earlier problem umlauts et al missing.
    Now I could use a test to differntiate between the two cases XML from the provider or the XML which is produced by my own app, and doesn"t work on the Provider and treat them differently, but I don't want this solution since the XML which my app produces is not accepted as input at the providers.
    So my query.. what is the best way to go about it now... I am quite stymied >(
    Thanks!
    Tim

    Amazingly enough some other user has the identical problem to yours and has expressed it in exactly the same words. Has the same name as you too.
    http://forum.java.sun.com/thread.jspa?threadID=606929&tstart=0
    (Cross-posting is frowned on here.)

  • How to deocde a Base64 String in Sun Java ME SDK 3.0(Urgent)

    Hi there, I want to decode a base64 encoded String in Sun Java ME SDK 3.0 , but cant find any solution to this, after doing search related to this I found that it's very easy to decode a Base64 string in Sun Wireless Toolkit 2.5 using following code:
    import com.sun.midp.io.Base64;
    byte[] data = Base64.decode(EncodedString);
    But I found that it's not possible in Java ME SDK as com.sun.midp.io.Base64 is not available there, anyone please give me some alternative of above code so that I can decode a Base64 String in Java ME SDK.
    Eagerly waiting for the possible solution.

    Can you please let us know as how you solved the problem? Since we are developing a blackberry app, we found base64 class for blackberry development. We have plans of doing the same in android, not sure whether they have this. As long as we have generic base64 class that can be used in any client device, that would be great. I did a lot of research and could not fine. Please give us the solution.

  • AIR 15 broke build, Base64

    Our project has com.sociodox.utils.Base64, as source, included in a SWC project's source paths.
    Starting with AIR15, the compiler is unable to resolve this Base64 class - I unzipped the SWC in question and looked at the catalog, and I found dependencies on it, but no definition.
    The compiler is definitely processing the Base64.as file - I can introduce syntax errors into it, and the compiler catches them.
    Again, this all worked correctly on AIR 14 and previous.
    By chance, working on an unrelated issue, one of our developers discovered that adding the AIR SDK lib "gamepad.swc" to the project works around the error. Looking at the catalog for gamepad.swc, I see that the Sociodox Base64 class is defined there.
    In short: the compiler can't resolve our Base64 class, forcing us to provide it from another source.

    Could you please open a new bug report on this over at bugbase.adobe.com?  When adding the bug, please include a sample project and details on the device we should test against.  If you'd like to keep this private, feel free to email the attachment to me directly ([email protected]). 
    Once added, please let me know the bug number and I'll ask the mobile team to investigate.

  • String - enc.Base64 - XML - dec.Base64 - String

    Well, I encrypt a string using the Base64 Class from sourceforge.net 'iharder'.
    Then I write it to an XML-file.
    That's working fine. But if I load the XML-file, parse it and want to decode my base64.encrypted String, the decoder produces only senseless characters... the string is not the same as before :-( ...
    what am I doing wrong?
    Here are some code snippets:
    encoding:
    String encryptedPassword = Base64.encodeString(Globals.password);decoding:
    String decryptedPassword = Base64.decode(password.getFirstChild().toString()).toString();I hope, someone can help me :-D

    You are assuming that
    "password.getFirstChild().toString()" returns the
    result of your "encryption", aren't you? If I use non-encrypted text instead of a encrypted string, it returns my plain-text password without any problems!
    And you are
    assuming that the Base64 encode and decode methods
    work correctly.Hmmm... I just decoded the password for printing it out on screen before writing the encrypted password to the xml-file:
    password (norm): test
    password (encrypted): dGVzdA==
    password (decrypted): [B@14ed577
    corresponding code:
    String encryptedPassword = Base64.encodeString(Globals.password);
    System.out.println("Passwort (norm): "+Globals.password);
    System.out.println("Passwort (encrypted): "+encryptedPassword);
    System.out.println("Passwort (decrypted): "+Base64.decode(encryptedPassword));That seems to me, that the decoder doesn't work properly.
    But I can't believe that... I chose iharder because it is recommended by many users on java.sun!
    If you want to debug something, don't try to debug two
    things at once. First test that decode() and encode()
    are really inverses. (And what's with that .toString()
    at the end of your decoding?) This decode-methode returns byte[]... the .toString()-method should generate a string from that byte[]. I know, it looks freaky :-D
    Second, find out whether
    that DOM calculation is getting the node you believe
    it is getting, instead of some other node.Well, the data -> xml -> data routines work fine, I wrote them using non-encrypted plain text. The encryption-decryption statements were added later.
    The xml-file's encoding is UTF-8. That's generated and loaded by DOM. I don't think, that DOM mixes up encodings of its own?!? (-> luis_m)

  • Base64 Decode Function Netweaver 7.1

    Hi,
    After migration from Netweaver 7.0 to 7.1, the Class Base64 cannot be resolved any more.
    In 7.0 I used the Base64 Class from com.sap.aii.utilxi.base64.api.Base64.
    Is there a simular class in 7.1?
    Best regards,
    Peter

    HI,
    thanks for your answer.  Which dependency do I have to add, when I want to use this package?
    import com.sap.mw.jco.util.Codecs.Base64; -> I get the error Import cannot be resolved.
    Sorry, I'm new in Java Programming with Netweaver.
    Best regards,
    Peter

  • Base64 encode decode question

    Hi
    I use the auclair base64 class to encode and decode base64 locally and it works great.
    But when I send the string to my server and back (aspx), I cannot decode it I have the 2030 error from flash.
    When I compare the encoded string from both end they look the same.
    I make sure it is fully loaded before attempting the decode.
    Is this a common bug or I'm I wrong somewhere?
    Thanks
    I use the latest air.

    The -d switch on the openssl base64 command enables debugging; it's the short version of the --debug switch.  Probably not what you're after, either.  The -D switch would be more typical, that's the short version of --decode switch, and probably what you had intended.
    The -i (--input) and -o (--output) switches allow you to specify input and output files, which is one way to pass a whole lot of data into that command.
    Do you have an example of some of the text that you're working with?

  • Base64

    i want to encode using base64 class.bt in java1.5 base64 is deprecate d. so wht is hte supported package in jdk1.5

    There is java/util/prefs/Base64There is? Not in 1.5 or 1.6It in my src.zip of 1.6 (I do not have access to the Sun pages right now to check the APIs):
    * @(#)Base64.java     1.7 05/11/17
    * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
    * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
    package java.util.prefs;
    * Static methods for translating Base64 encoded strings to byte arrays
    * and vice-versa.
    * @author  Josh Bloch
    * @version 1.7, 11/17/05
    * @see     Preferences
    * @since   1.4
    class Base64 {
    . . .

  • Sha1 to base64 key format needed

    Hello All,
    I am new to Java and trying to get my arms around the various places to find new classes for various functions.
    I am trying to find a class that will convert a seed string using SHA1 into a base64 string. I have done some heavy trolling through many google pointers but I have not found exactly what I am looking for.
    In perl I would use something like the following two lines:
    use Digest::SHA1 qw(sha1_base64);
    $base64digeststring = sha1_base64("foobar");
    Does anybody have any stubs of code for this?
    Thanks,
    Mark

    I java it is two seperate steps. The first is to SHA-1 digest the input and then to base64 encode the resulting digest.
    MessageDigest md = MessageDigest.getInstance("SHA1");
    byte[] digest = md.digest(input.getBytes("ASCII"));
    String enc = Base64.encode(digest);
    The above example assumes you have a Base64.class which you probably don't. MessageDigest on the other hand is included in the base jdk and jre so that line should work fine for you out of the box. So in short what you really need to find is a Base64 encoder/decoder class(es).
    There is one that is packaged with Sun's JDK in the sun.misc package. Problem with using that is that it only exists on Sun's JVMs (aka IBM jvm would result in your app failing). However, if you search for Base64 and Java you should find numerous open source impls you can use..
    Enjoy..

  • Error while configuring Oracle Internet Directory

    Hi All,
    I have installed OID according to instructions in
    http://download.oracle.com/docs/cd/E21764_01/install.1111/b32474/start.htm#BEHHHCBB
    I was trying to configure OID using instructions given in section 6.5 Only OID Without a WebLogic Domain at below url
    http://download.oracle.com/docs/cd/E21764_01/install.1111/e12002/oid.htm#CIHHFIGC
    The configurations is failing in creation of directory giving an error below:
    [2011-11-15T12:14:40.321+05:30] [as] [NOTIFICATION] [] [oracle.as.config] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] Ports: nonssl= 3060 ssl= 3131
    [2011-11-15T12:14:40.321+05:30] [as] [NOTIFICATION] [] [oracle.as.config] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] Creating OID specific directories
    [2011-11-15T12:14:40.321+05:30] [as] [NOTIFICATION] [] [oracle.as.config] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] JPS Files already exist: oracle.as.config.ProvisionException: Dest file (C:\Oracle\Middleware\asinst_2\config\JPS\jps-config-jse.xml) already exists.
    [2011-11-15T12:14:40.321+05:30] [as] [NOTIFICATION] [] [oracle.as.config] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] Files already exist: oracle.as.config.ProvisionException: Dest file (C:\Oracle\Middleware\asinst_2\config\JPS\system-jazn-data.xml) already exists.
    [2011-11-15T12:14:41.774+05:30] [as] [ERROR] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [[
    java.lang.NoClassDefFoundError: oracle/security/xmlsec/util/Base64
    at oracle.security.jps.internal.common.util.JpsCommonUtil.<clinit>(JpsCommonUtil.java:204)
    at oracle.security.jps.internal.core.runtime.JpsContextFactoryImpl.getContext(JpsContextFactoryImpl.java:154)
    at oracle.security.jps.internal.core.runtime.JpsContextFactoryImpl.getContext(JpsContextFactoryImpl.java:165)
    at oracle.iam.management.oid.install.wls.OIDComponentHelper$1.run(OIDComponentHelper.java:396)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.iam.management.oid.install.wls.OIDComponentHelper.setCredInCSF(OIDComponentHelper.java:389)
    at oracle.iam.management.oid.install.wls.OIDComponentHelper.setPasswdsInCSF(OIDComponentHelper.java:361)
    at oracle.iam.management.oid.install.wls.OIDComponent.onCreate(OIDComponent.java:177)
    at oracle.as.config.impl.OracleASComponentBaseImpl.createComponent(OracleASComponentBaseImpl.java:596)
    at oracle.as.config.impl.OracleASComponentBaseImpl.create(OracleASComponentBaseImpl.java:105)
    at oracle.as.provisioning.fmwadmin.ASComponentProv.createComponent(ASComponentProv.java:144)
    at oracle.as.provisioning.fmwadmin.ASComponentProv.createComponent(ASComponentProv.java:73)
    at oracle.as.provisioning.fmwadmin.ASInstanceProv._createComponent(ASInstanceProv.java:401)
    at oracle.as.provisioning.fmwadmin.ASInstanceProv.createComponent(ASInstanceProv.java:358)
    at oracle.as.provisioning.fmwadmin.ASInstanceProv.createInstanceAndComponents(ASInstanceProv.java:136)
    at oracle.as.provisioning.engine.WorkFlowExecutor._createASInstancesAndComponents(WorkFlowExecutor.java:537)
    at oracle.as.provisioning.engine.WorkFlowExecutor.executeWLSWorkFlow(WorkFlowExecutor.java:441)
    at oracle.as.provisioning.engine.Config.executeConfigWorkflow_WLS(Config.java:866)
    at oracle.as.provisioning.engine.Config.executeConfigWorkflow_WLS(Config.java:820)
    at oracle.as.idm.install.config.IdMDirectoryServicesManager.doExecute(IdMDirectoryServicesManager.java:855)
    at oracle.as.install.engine.modules.configuration.client.ConfigAction.execute(ConfigAction.java:335)
    at oracle.as.install.engine.modules.configuration.action.TaskPerformer.run(TaskPerformer.java:87)
    at oracle.as.install.engine.modules.configuration.action.TaskPerformer.startConfigAction(TaskPerformer.java:104)
    at oracle.as.install.engine.modules.configuration.action.ActionRequest.perform(ActionRequest.java:15)
    at oracle.as.install.engine.modules.configuration.action.RequestQueue.perform(RequestQueue.java:63)
    at oracle.as.install.engine.modules.configuration.standard.StandardConfigActionManager.start(StandardConfigActionManager.java:158)
    at oracle.as.install.engine.modules.configuration.boot.ConfigurationExtension.kickstart(ConfigurationExtension.java:81)
    at oracle.as.install.engine.modules.configuration.ConfigurationModule.run(ConfigurationModule.java:83)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: oracle.security.xmlsec.util.Base64
    at oracle.as.install.engine.modules.configuration.standard.StandardConfigActionClassLoader.loadClass(StandardConfigActionClassLoader.java:75)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    ... 29 more
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE:16] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: IdMProvisioningEventListener] [SRC_METHOD: onConfigurationError] ENTRY bb084f6d-09f4-4737-b462-a0a877a439db
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] ________________________________________________________________________________
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] [OOB IDM CONFIG EVENT] onConfigurationError -> configGUID bb084f6d-09f4-4737-b462-a0a877a439db
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] [OOB IDM CONFIG EVENT] ErrorID: 35076
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] [OOB IDM CONFIG EVENT] Description: [[
    Error creating ASComponent oid1.
    Cause:
    An internal operation has failed: oracle/security/xmlsec/util/Base64
    Action:
    See logs for more details.
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] ________________________________________________________________________________
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] [OOB IDM CONFIG EVENT] onConfigurationError -> eventResponse ==oracle.as.provisioning.engine.ConfigEventResponse@1cc678a
    [2011-11-15T12:14:41.774+05:30] [as] [NOTIFICATION] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [OOB IDM CONFIG EVENT] onConfigurationError -> Configuration Status: -1
    [2011-11-15T12:14:41.774+05:30] [as] [NOTIFICATION] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [OOB IDM CONFIG EVENT] onConfigurationError -> Asking User for RETRY or ABORT
    [2011-11-15T12:14:41.774+05:30] [as] [NOTIFICATION] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [OOB IDM CONFIG EVENT] onConfigurationError -> ActionStep:OID
    [2011-11-15T12:14:41.774+05:30] [as] [TRACE] [] [oracle.as.provisioning] [tid: 12] [ecid: 0000JE_xudK9d_QwI^e9Sv1EkWaj000003,0] [SRC_CLASS: oracle.as.idm.install.config.event.IdMProvisionEventListener] [SRC_METHOD: onConfigurationError] [OOB IDM CONFIG EVENT] onConfigurationError -> wait for User Input ....
    ===================================================================
    It is not able to find the class oracle.security.xmlsec.util.Base64.
    I was able to find a related thread on this issue at Oracle Internet Directory Config Error Linux x64 java.lang.NoClassDefFoundE
    but didn't find much helpful.
    The setup details are as follows:
    Weblogic Version: 10.3.5
    RCU Version: 11.1.1.3.3
    IDM version: 11.1.1.2.0 (release version) Upgraded to 11.1.1.5.0 (Patchset version)
    Also Oracle IDM installation has the jar file odst_xmlsec.jar having the Base64 class.
    Please let me know if you see any issues.
    Thanks in advance,
    Vikrant
    Edited by: 894449 on Nov 16, 2011 1:01 AM

    Hi,
    Please try
    "Error Creating ASComponent Oid1" Error During OID Configuration When Installing OID11g (Doc ID 1427253.1) that should resolve the issue.

  • How to parse xml file, containing image,  generaged from JAX-RS connector?

    Hi,
    We are using JAX-RS connector and just want to call getBusinessObjects() directly using JerseyMe (basically bypassing sync engine). We have used sync engine so far and want to try as how to bypass it. The method produces the text/xml and verified the xml file in the web by giving the full url. The plan is to call the same URL from the Java Me Client using JerseyMe. When I print the bytes at the client I receive the same xml that I have seen in the web. Actually, I am passing an image that I can see in a different character format in xml (assuming this is bcos of UTF-8 encoding). I am wondering as how to parse this xml file and how to decode the "UTF-8" format? Do we need to use SGMP for this or use kxml or java me webservices spec.
    I would really appreciate if somebody can answer this one.
    I have been observing in this forum that SGMP team is not at all active in answering the questions. Please let us know whether Oracle is keeping this product and we can continue using SGMP1.1. Please let us know so that we can plan accordingly as we are building a product based on SGMP.

    Hi Rajiv,
    The client library is using org.apache.commons.codec.binary.Base64 internally. We don't have the full Commons Codec library bundled, but you can look up the javadoc for the Base64 class online. All you need to do is call Base64.decode(obj.getBytes()) on the objects you get out of the XML.
    In general it isn't a good idea to depend on implementation details of the client library, but in this case, I think it is pretty safe to expect org.apache.commons.codec.binary.Base64 to remain in our library.
    --Ryan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to make all characters of a 3DES encrypted string printable

    I am performing a triple DES on a string, and when I print out the encrypted data, it is 'chopping' off a character on the terminal.
    For instance, I run the encrpytion ona string "blah", and print out the results:
    java Test3Des blah
    OUTPUT = ?$O4|
    The problem here is that the string should have a "|" at the beginning of the output, not only the end. So I am not sure how I can 'pad' the output so that it can be saved to a file, and not remove characters around it in such a way that I can read it back in and decrypt to get "blah" back.
    Thank you for the help....

    Your encrypted bytes have all the information you need, what you need is to convert those bytes with a Base64 encoding class before you print them to the output. You don't need to do this before writing to a file, but it is best as them you don't have any problems with the Unicode only behavior of some of the InputStream subclasses. You didn't mention any JCE provider, but BouncyCastle offers a Base64 class as part of their implementation.
    Another caveat, make sure to always specify the formatting when making String objects and writing to a file, etc., etc. I prefer "UTF-8" for it.

  • Illegal character in Auth-Header

    Hi,
    I am trying to send a SOAP Message from a HCP Application to a Webservice from Cloud for Customer.
    The request uses basic authentication.
    My problem now is, that I get a SOAP Exception saying that there is a illegal character in the auth header.
    Illegal character(s) in message header value: Basic
    After searching in google I think that there is a new line character at the end of the credentials which causes
    the error and this seems to be a bug in a library from sun. However I use the apache implementation of the
    Base64 class and I tested whether there is such a new line character but everything is alright.
    If I run it as a local Java application every works fine and the request is successful but in the cloud environment
    I always get this error.
    Does anyone face the same issue or know a resolution to this problem?
    Any help will be appreciated.
    Thanks in advance and best regards
    Felix

    Hi ejp,
    It's a rsa public, the usercert.pem looks like below,
    so since it's not an x509 certificate not sure if I
    can read it using a
    java.security.cert.CertificateFactory?
    Basically I just want to print the public and private
    key out as a String. Any help is appreciated.
    -----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCg8yo6rDhsNiwUfV
    R37HgF4bWq
    oG13Nd9XLT+Z0VLzCkWJZOdzGNQnnm7ujoQ8gbxeDvIo9RG5I3eZte
    BwD91Nf6P/
    E9lvJQDL2Qnz4EXH/CVW9DeEfvY1UJN9kc6q6KkYEPWssvVvlDOp2s
    lbEKZCJtaP
    vVuGCAqfaps8J0FjOQIDAQAB
    -----END PUBLIC KEY-----
    import java.security.KeyFactory;
    import java.security.interfaces.RSAPublicKey;
    import java.security.spec.X509EncodedKeySpec;
    import sun.misc.BASE64Decoder;
    public class MakeRSAPublicKeyFromPEM
        public static void main(String[] args) throws Exception
            final String publickeyAsString =
                    "-----BEGIN PUBLIC KEY-----\n"+
                    "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCg8yo6rDhsNiwUfVR37HgF4bWq\n"+
                    "oG13Nd9XLT+Z0VLzCkWJZOdzGNQnnm7ujoQ8gbxeDvIo9RG5I3eZteBwD91Nf6P/\n"+
                    "E9lvJQDL2Qnz4EXH/CVW9DeEfvY1UJN9kc6q6KkYEPWssvVvlDOp2slbEKZCJtaP\n"+
                    "vVuGCAqfaps8J0FjOQIDAQAB\n"+
                    "-----END PUBLIC KEY-----\n";
            final BASE64Decoder decoder = new BASE64Decoder();
            final byte[] publicKeyAsBytes = decoder.decodeBuffer(publickeyAsString.replaceAll("-+.*?-+",""));
            final X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyAsBytes);
            final KeyFactory keyFactory = KeyFactory.getInstance("RSA");
            final RSAPublicKey publicKey = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);
            System.out.println("Modulus ........... " + publicKey.getModulus());
            System.out.println("Public exponent ... " + publicKey.getPublicExponent());
    }

  • UDF does not find package in imported archive

    Hello,
    as I want to use a base64 encoding method I have created an imported archive to use the package org.apache.commons.code.binary and want to use Base64 class in an UDF.
    I have created an imported archive in the same SVCW and namespsace as the UDF exists. However when executing the UDF I get the following error message:
    package org,.apache.commons.codes.binary. does not exist
    import org.apache.commons.codec.binary.*
    The import statement in the UDF is spelled correctly and the imported archive was acitvated without error.
    What could be the reason for this?

    Hello,
    I have created an imported archive in the same SVCW and namespsace as the UDF exists. However when executing the UDF I get the following error message:
    package <org,.apache>.commons.codes.binary. does not exist
    import org.apache.commons.<codec.>binary.*
    The import archive procedure you have done is correct. In your UDF check your importing statement as its not in correct syntax.
    and also check the spelling of the package. check the words i have marked with in tags.
    Regards,
    Prasanna

  • J2ee error--Could not login to config tool

    hi,
    the J2ee instance in my SAP Server is not running.
    The SAP Server is of the following configuration.
    OS: AIX
    Installation: AS-ABAP + JAVA
    Database: Oracle
    My ABAP instance is running. ABAP and JAVA are runnning on different schema
    When i try to connect to config tool , I am getting the following error. Please guide, of if you have faced a situation before
    Connecting to database ... java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
            at java.lang.reflect.Method.invoke(Method.java:391)
            at com.sap.engine.offline.OfflineToolStart.main(OfflineToolStart.java:81)
    Caused by: java.lang.NoClassDefFoundError: iaik.utils.Base64Exception
            at java.lang.J9VMInternals.verifyImpl(Native Method)
            at java.lang.J9VMInternals.verify(J9VMInternals.java:59)
            at java.lang.J9VMInternals.initialize(J9VMInternals.java:120)
            at com.sap.engine.core.configuration.impl.persistence.rdbms.DBConnectionPool.<init>(DBConnectionPool.java:108)
            at com.sap.engine.core.configuration.impl.persistence.rdbms.PersistenceHandler.<init>(PersistenceHandler.java:38)
            at com.sap.engine.core.configuration.impl.cache.ConfigurationCache.<init>(ConfigurationCache.java:149)
            at com.sap.engine.core.configuration.bootstrap.ConfigurationManagerBootstrapImpl.init(ConfigurationManagerBootstrapImpl.java:236)
            at com.sap.engine.core.configuration.bootstrap.ConfigurationManagerBootstrapImpl.<init>(ConfigurationManagerBootstrapImpl.java:49)
            at com.sap.engine.configtool.console.ConsoleConfigTool.loadClusterData(ConsoleConfigTool.java:97)
            at com.sap.engine.configtool.console.ConsoleConfigTool.<init>(ConsoleConfigTool.java:53)
            at com.sap.engine.configtool.console.ConsoleConfigTool.main(ConsoleConfigTool.java:1279)
            ... 6 more

    Hello Balaji,
    The ClassNotFoundError is complaining about class Base64.  This class is part of the util.jar library which can be found in the following location:
    ./j2ee/configtool/lib/util.jar
    Please verify that this library file is present.  If it is, please verify that the file is not corrupt by executing the following command:
    jar -tvf util.jar
    With the above command you should see the contents of the archive.   One of the classes should be Base64.class.
    If necessary you can redeploy the configtool.sda archive which is located under
    .\SDM\root\origin\sap.com\com.sap.engine.configtool\SAP AG\<#>\<version_info>\configtool.sda.
    Use SDM to redeploy the archive using option 'Update SCAs/SDAs that have any version' under the deploy tab.
    Regards,
    Nathan

Maybe you are looking for

  • Converting a character string to into a date raise ORA-01843

    I always confused in using to_date() function,such as the following example.How could I convert the string "'8-十月-2006 " into a date correctly.Thank you in advance. SQL> select TO_DATE('18-十月-2006 16:49:57','dd-mon-yyyy hh24:mi:ss','nls_DATE_language

  • Which is the MYSQL version compatible with SAP PI 7.0

    Dear friends, can any body tell me which is the MYSQL version compatible with SAP PI 7.0,  i m getting the below error , some body told me, may be the MYSQL version is not compatible with PI 7.0 Message processing failed. Cause: com.sap.aii.af.ra.ms.

  • IOS 7, safari and no recent entries in address bar for recently visited websites

    Hallo, I have an ipad mini with ios 7 and when using safari and its address and search bar, entring the first few letters of a previously visited website does not give me the option to select that address to minimise data entry. What can i do? Ps: ho

  • NLS Error when use ICX

    We use ICX to invoke a jweb catridge, and parameters was tranfered with hashtable. when get the Http Request,we found the character is error. we know it must the NLS setting error,but we don't know how to correct it. please mail to me [email protecte

  • Komplete 7 on a macbook pro?

    Lately I have been thinking of upgrading my synth and midi tracks arsenal by installing komplete 7 by native instruments on my macbook pro. I have done a good bit of research on the product itself and I think I will like it a lot. However, I have rea