Reading encoded characters

I used openLDAP to store digital certificate.
As client I use java program. java program read the .der(ASN.1) encoded file and store the certificate in the server.
But I have problem when I reading certificates entries and create the certificate back.Out put from the server is ASN.1 encoded string. How i can create the certificate(.cer or .der) file from that output.

If the DER content represents an X509 certificate then you need to get the bytes and use            final X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(derBytes);
            final RSAPublicKey pk = (RSAPublicKey)keyFactory.generatePublic(publicKeySpec);
to recover the public key.

Similar Messages

  • [SOLVED] Problems opening folders with UTF-8 encoded characters

    Hello everyone, I'm having an issue when I acess folders in all my programs ( except Dolphin File Manager). Every time I open the folder navigation window in my programs, folders with UTF-8 encoded characters ( such as "ç", "á ", "ó", "í", etc ) are not shown or the folder name not show these characters, therefore, I can not open documents inside these folders.
    However, as you saw, I can type these characters normally. Here's my "locale.conf" :
    LANG="en_US.UTF-8:ISO-8859-1"
    LC_TIME="pt_BR.UTF-8:ISO-8859-1"
    And here's the output of the command "locale -a" :
    C
    en_US.utf8
    POSIX
    Last edited by regmoraes (2015-04-17 12:55:19)

    Thing is, when I run locale -a, I get
    $ locale -a
    C
    de_DE@euro
    de_DE.iso885915@euro
    de_DE.utf8
    en_US
    en_US.iso88591
    en_US.utf8
    ja_JP
    ja_JP.eucjp
    ja_JP.ujis
    ja_JP.utf8
    japanese
    japanese.euc
    POSIX
    So an entry for every locale I have uncommented in my locale.conf. Just making sure, by "following the steps in the beginner's guide", you also mean running locale-gen?
    Are those folders on a linux filesystem like ext4 or on a windows (ntfs?)

  • Cannot read foreign characters!!!

    Requirement: Read a text file containing foreign characters and print it/ store it in string buffer
    Problems: Doesnt work, and throws exception whenever Reader.read() or BufferedReader.readline()
    method is envoked...
    How do i get arround this?
    Here is a sample text from the file...
    Ang�ende utleggelse av kopierte lydfiler i CVS8 format via internett � f� fjernet p� denne e-mail n�dt til � bemerke
    here is the sample program:
    import java.io.*;
    public class LoadUTF8 {
         private static String _FILE = null;
         public static void main(String args[]) {
              _FILE = args[0];
              try {
                   System.out.println(getUTF8());
              catch(Exception e) {e.printStackTrace();}
              try {
                   loadUTF8Data();
              catch(Exception e) {e.printStackTrace();}
         public static String getUTF8() {
              StringBuffer buffer = new StringBuffer();
              try {
                   FileInputStream fis = new FileInputStream(_FILE);
                   InputStreamReader isr = new InputStreamReader(fis, "UTF8");
                   Reader in = new BufferedReader(isr);
                   int ch;
                   while ((ch = in.read()) > -1) {
                        buffer.append((char)ch);
                   in.close();
                   return buffer.toString();
              } catch (IOException e) {
                   e.printStackTrace();
                   return null;
         public static void loadUTF8Data() {
    try
                   InputStream in = new FileInputStream(_FILE);
                   BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF8"));
                   String line = null;
                   StringBuffer buffer = new StringBuffer();
    while ( ( line = reader.readLine() ) != null ) // Read line until EOF
    buffer.append( line + "\n" );
    System.out.println("" + buffer.toString() + "");
              catch(Exception e) {
                   e.printStackTrace();
    Error Message:
    sun.io.MalformedInputException
    at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:110)
    at java.io.InputStreamReader.convertInto(InputStreamReader.java:137)
    at java.io.InputStreamReader.fill(InputStreamReader.java:186)
    at java.io.InputStreamReader.read(InputStreamReader.java:249)
    at java.io.BufferedReader.fill(BufferedReader.java:139)
    at java.io.BufferedReader.read(BufferedReader.java:157)
    at mtrack.cda.utils.LoadUTF8.getUTF8(LoadUTF8.java:25)
    at mtrack.cda.utils.LoadUTF8.main(LoadUTF8.java:15)
    NB:- It works fine with normal text files that doesn't have any foreign character!
    If either of getUTF8() or loadUTF8Data() functions work, i will be very happy!!! :-)

    Hi Pratim,
    Your code is absolutely correct and can be adapted to read in any foreign characters as long as you create your InputStreamReader with the same encoding that was used to write the file you are trying to read. By default, java encodes files in a format called Cp1252. Cp1252 can be used to encode ASCII characters (\u0000->\u007f) + an extended region (\u0080->\u00ff). This extended region contains, among other characters, the extra characters used by languages like Spanish, German etc. To read such a file, change your code to:
    InputStreamReader isr = new InputStreamReader(fis, "Cp1252"); However, if one wants to encode characters beyond \u007f (for example, Chinese, Hindu, Russian etc.) then one cannot use Cp1252 encoding. Frequently, such characters are encoded using UTF8 (Unicode Transformation Format 8). UTF8 is capable of encoding the entire unicode character set. There are many many different encodings supported by java. The point is that you must to use the same encoding to read back the characters as was used to store them.
    I suggest that you experiment with writing characters to files and reading them back into java using different encodings. You already have the code to read the characters. To write the files, you can either use Microsoft Word or you can write code analogous to your code above except using the OutputStreamWriter. It will also be helpful to you if you have some way of examining the bytes in your output files.
    Regards,
    Joe

  • How to read Chinese Characters in iTunes?

    Hi all,
    Is there anyone who can enlighten me on how I can read chinese characters in iTunes? I have quite a number of Chinese songs that I wish to be played in iTunes, but I noticed that it does not read the chinese song titles and had small rectangles in place of the chinese characters.
    I tried using a third-party software lke NJStar, but the chinese characters resulted were crammed together and were not legible.
    Please help. Thanks.

    now instead of small
    little squares, there are funny symbols and letters
    that don't make any sense whenever there are
    supposedly chinese characters.
    That probably means that the id3 tags on your songs are not encoded correctly. I understand that the program ConvertZ can help fix this.

  • How to read chinese characters with Nano

    I transfered some chinese songs to my Nano using iTunes.
    But now i can't read the characters...

    Please always tell people what OS you are using.
    Most likely the ID3 tags for the songs are not encoded correctly for the iPod. See this note for some info:
    http://discussions.apple.com/thread.jspa?threadID=121866&tstart=15
    If you are running Windows, there is a program called ConvertZ that may help.

  • How can Mail of OS X Mountain Lion read Chinese Characters?

    Mail cannot read Chinese characters. Message looks like a series of "??????". However, Safari can read Chinese characters. What setting can make Mail read Chinese Characters?

    Pippi10 wrote:
    Mail cannot read Chinese characters. Message looks like a series of "??????".
    Normally that indicates an encoding glitch, where the email headers are not telling Mail the right encoding to use.  The first thing to try is Message > Text Encoding and see if UTF-8 or one of the various Chinese encodings give the right display.
    Also go to View > Message > Raw Source and tell us what you see in the headers that say "charset=  ".

  • Tomcat unable to read accented characters from MySQL

    Folks,
    Can anyone help with me this problem?
    It seems that my version of Tomcat is unable to read accented characters from my MySQL Database.
    I've checked in the Database and the characters are all correctly represented there. But when, in my servlet code, I do:
    String author = results.getString("author_surname");If the String contains any accented character then the character shows as a '?'. (Even before it gets to the JSP - I'm writing the results straight to catalina.out).
    Looking around these forums I found that some people suggested adding
    ?useUnicode=TRUE&characterEncoding=UTF-8;to the end of my jdbc url. As in:
    <ResourceParams name="jdbc/connection">
    //a whole load of other params
      <parameter>
        <name>url</name>
         <value>jdbc:mysql://localhost:3306/bookshop?useUnicode=TRUE&characterEncoding=UTF-8</value>
      </parameter>
    </ResourceParams>inside my server.xml
    But it doesn't seem to make any difference. In addition, I doubt I even need to use Unicode as the accents I need are only: ����� etc.
    (Incidentally, writing that line into my server.xml, tomcat complains that it should finish with a semi-colon. Is that correct? Even if I put in the semi-colon, it still complains!!)
    Any suggestions on this would be much appreciated. Thank you.

    user13109986 wrote:
    HI,
    From http://download.oracle.com/docs/cd/B10501_01/server.920/a96529/ch9.htm
    My understanding is the JDBC Api converts the string from the database to UTF-16.. If so is there any way to disable the UTF-16 encoding at JDBC API?That's exactly what it's supposed to do. There isn't even any concept of what it would mean to disable that: Java characters are UTF-16 representations of Unicode code-points, so there isn't anything else it could do.
    I still suspect the JDBC part is working correctly and your writing-to-file isn't. I found this quote in the Wikipedia article on Windows-1256:
    Windows-1256 is a code page used to write Arabic (and possibly some other languages that use Arabic script, like Persian) under Microsoft Windows. This code page is not compatible with ISO 8859-6 and MacArabic encodings.So was there a particular reason you chose Cp1256 and not ISO-8859-6 as the charset to write to the file with?

  • Reading Japanese Characters from Properties File

    I am running on Windows 2000 (English). Can any one suggest on how to read Japanese Characters from a ".properties" file.
    TIA

    look at ResourceBundle and unicode encoding,
    Jim

  • Reading Japanese characters.

    I am not able to read Japanese characters in Unicode in Sun machines. Has any body experienced this problem before. I hade a Shift-SJIS encoding file. I later ran the native2ascii -encoding SJIS on the file and when I bring up my application. I do not see the Japanese characters at all.
    Thanks,

    I have a file in Shift-JIS. I then compile using javac -encoding SJIS to let the compiler know that it is a Shift-JIS file. I am not able to get it running in Solaris machine. Do I need to do something different for this. I have JapStrings_ja.java file which has the strings in Shift-SJIS.
    Thanks

  • How to read Korean characters using Java program?

    In Oracle table, i am having Korean characters, how to read those characters using JDBC and insert into SQL Server?
    NLS_NCHAR_CHARACTERSET is UTF8

    What data type is the column in the Oracle table? The NLS_NCHAR_CHARACTERSET would control the encoding of NCHAR and NVARCHAR2 columns. The NLS_CHARACTERSET would control the encoding of CHAR and VARCHAR2 columns.
    Justin

  • How can I make my BB 8800 read arabic characters?

    I havn't bought the BB yet, I just want to make sure if it can read arabic characters.....
    It's really important help please....

    Hi psycho-blazem
    The language support offered on a BlackBerry smartphone depends on the wireless carrier.
    http://www.blackberry.com/btsc/KB12390
    Thanks,
    -FS
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click Solution? for posts that have solved your issue(s)!

  • Time of reading encoder position

    Hello,
    I want to ask you people where can i learn function execution times of NI 7358 board? I'm developing driver for this card on QNX 6.5. When i send read encoder position package to 7358, the first data comes to RDB register after around 10 ms for first time. Is it normal? Is there any documentation file that includes all function execution times (average)?
    Best regards.

    Hi erhan,
    I'm not too surprised that once the motion has started, the "Read Axis Status" function takes more time. The card should devote more resources towards managing the movement. That being said, the timing help document is only in reference to the individual function calls and as you stated the Read Axis Status alone has no latency. 
    Unfortunately, besides this timing help document, there isn't other documentation that is released that discusses the execution timing. If this is a bigger concern, I would try benchmarking the process on multiple computers.
    Paul M
    National Instruments | Applications Engineer | www.ni.com/support

  • Read Encoder Position Error -70012

    I am using the "Read Encoder Position" and I keep getting error #-70012.  There are no errors up to this point and it does not SEEM to affect the way my program runs.  Does anyone know what this error is? 
    I did try to look up the error # to no avail.
    Thanks.

    Have you seen this?

  • Replace encoded characters in URL

    Hi gurus,
    I have the following requirement and I don't know how to solve it in the best way.
    I have a Z transaction for uploading a local file. This file contains URL's and after upload, there are stored in SAP.
    I need to check this URL and replace encoded characters with corresponding codes, for example: space -> %20
    How can I do this? I've been looking for a solution, but I haven't found anything usefull yet.
    Any ideas?
    Thanks a lot!

    Have a look at class CL_HTTP_UTILITY. There are some methods which looks promising.
    The method ESCAPE_URL is waht you needed.
    pass UNESCAPED = 'http://forums.sdn.sap.com/edit!default.jspa?messageID=11060123'
    output = HTTP%3a%2f%2fFORUMS%2eSDN%2eSAP%2eCOM%2fEDIT%21DEFAULT%2eJSPA%3fMESSAGEID%3d11060123
    & for vice versa use UNESCAPE_URL
    Edited by: Keshav.T on Feb 7, 2012 2:23 PM

  • Need special encoded characters in an Email subject with java 1.3.1_02

    I need to find a way to construct an Email through java with Subject lines built using characters from various Asian encodings. Such as Shift-JIS, Chinese Big5, etc.
    These encodings cannot be in UTF-8 format and must remain in the native character set.
    For testing I have an HTML file constructed using a single line of text with Shift-JIS characters. This file shows properly in web browsers under the Shift-JIS encoding view, and when used to create the body of an email it works perfectly through the DataHandler. However, I cannot get any java Reader to pull the same stream of characters into the Subject of the email. The Subject is always garbage no matter what I do.
    Here is a small code sample with the relevant lines:
    Session session = Session.getDefaultInstance(System.getProperties(), null);
    MimeMessage reSend = new MimeMessage(session);
    Transport ship = session.getTransport();
    BufferedReader s = new BufferedReader(new InputStreamReader(new FileInputStream("C:\\JavaPrograms\\Converted\\JISConv.html"), "SJIS"));
    String resub = s.readLine();
    s.close();
    reSend.setSubject(resub);
    DataHandler collect = new DataHandler(new FileDataSource("C:\\JavaPrograms\\Converted\\JISConv.html"));
    reSend.setDataHandler(collect);
    ship.send(reSend);If I use the "SJIS" encoding in the InputStreamReader above, all characters are shown as "?". If I delete it entirely and use the system default, I get half of the characters and the rest are garbage. I can generate either of those results using various other Japanese and Western encoding definitions.
    I have tried using the above code, also DataHandlers for the Subject, FileReader directly to a String, ByteArrayInputStreams, and StringBuffers. So far everything I try ends up at the same result.
    Can anyone help me out? I really need this to work. If I can get this one encoding to work, then I should be able to program case switches for the other encodings.
    Thanks kindly!
    Kurt Jackson

    First this is an issue with javamail and not with java.
    What makes you think that the mime standard allows what you want to do?
    Both of your 'tests' have been done using alternatives which do support alternative encodings.
    These encodings cannot be in UTF-8 format and must remain in the native character set.That seems rather unlikely to me. Email is transported using one encoding. Certainly SMTP uses only ascii. So what ever you put in there is going to be ASCII no matter what you do to it. I suppose something at the end might try to read it using an alternative encoding but then what happens when someone really wants to send those ASCII characters?
    Mime, I believe, is built on SMTP. And the subject line is still SMTP and thus ASCII.
    Here is one link that covers mime (you might want to check the backing references though.)
    http://www.mindspring.com/~mgrand/mime.html
    I believe there is some sort of official or unofficial standard for doing what you want. I would suggest that you start by getting that first. I would suspect JavaMail doesn't support it.
    Once you have a standard to follow you have the following choices..
    - Modify JavaMail directly to support this (this then becomes a non-distributable solution.)
    - Extend JavaMail do support this. This might or might not be possible.
    - Write your own implementation (don't use JavaMail.)
    - Find another solution from another source that already implements this.

Maybe you are looking for

  • Why can't I print from my ipad?

    I've had my iPad for almost a year now and I like it a lot. It looks very good, it performs very well even though I'm far from reaching my goal of only taking my ipad to school, nothing else. One important reason why this won't be the case for quite

  • Iphone 4s downgrade ios 7 please !! ios 8 its very slow

    i like to downgrade my iphone 4s to ios 7.1.2 please

  • Vbscript - detecting configuration changes

    Hi, not sure if this is the right community to post this kind of question but i am after some example of vbscripts to detect routing change for example like to know when someone add a new route entry, advertised in to our campus networks, would like

  • Creating BW Function module to extract R3 Function module data.

    Could you tell me how to create a BW Function Module to Extract data from  R/3 Function module?. Also, the BW function module needs to pass a date/time filter to R/3 function module basis which the R/3 function module passes the date/time restricted

  • Upgrade hard drive on DV9925NR

    I have an HP laptop (model DV9925nr), with a Western Digital factory hard drive (model WD2500BEVS). I'm running low on storage space, and would like to upgrade to a bigger drive. Before I drop the bucks on a new drive, can anyone tell me whether the