locked
How to get Privatekey RRS feed

  • Question

  • Hi,

    I am new to Healthvault. I am trying to call webservice from java. I get the following sample code from forum. Added that in java SDK project code.

            StringBuilder requestXml = new StringBuilder();
            requestXml.append("<info><group>");
            requestXml.append("<filter><type-id>bd0403c5-4ae2-4b0e-a8db-1888678e4528</type-id></filter>");
            requestXml.append("<format><section>core</section><section>otherdata</section><xml/></format>");
            requestXml.append("</group></info>");
            Request request = new Request();
            request.setMethodName("GetThings");
            request.setOfflineUserId("e2f925e7-2748-4d88-bz48-32036dc10020");
            request.setRecordId("73ab2792-5481-43eb-837c-67d1e3337300");
            request.setInfo(requestXml.toString());
            Connection connection = ConnectionFactory.getConnection();
            HVAccessor accessor = new HVAccessor();
            accessor.send(request, connection);

    When I am trying to run this program I am getting following Exception.

     

    Exception in thread "main" com.microsoft.hsg.HVException: com.microsoft.hsg.HVSystemException: Could not get private key information
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:68)
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:79)
        at com.microsoft.hsg.applications.TrialConnection1.main(TrialConnection1.java:36)
    Caused by: com.microsoft.hsg.HVSystemException: Could not get private key information
        at com.microsoft.hsg.DefaultPrivateKeyStore.initData(DefaultPrivateKeyStore.java:160)
        at com.microsoft.hsg.DefaultPrivateKeyStore.getPrivateKey(DefaultPrivateKeyStore.java:112)
        at com.microsoft.hsg.ApplicationAuthenticator.ensurePrivateKey(ApplicationAuthenticator.java:225)
        at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:137)
        at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:130)
        at com.microsoft.hsg.Connection.authenticate(Connection.java:163)
        at com.microsoft.hsg.Connection.authenticate(Connection.java:172)
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:62)
        ... 2 more
    Caused by: com.microsoft.hsg.HVException: Key not found
        at com.microsoft.hsg.DefaultPrivateKeyStore.initData(DefaultPrivateKeyStore.java:142)
        ... 9 more

     

    So what is missing in this example. How to get private key? Also I want to know how to get OfflineUserId or RecordIds?

    Thanks..

    Monday, July 5, 2010 12:54 PM

Answers

  • Hello Manjiri,

    The private key will be generated in your machine's keystore after executing the below command . you dont need to get any private key from HealthVault team.

    "keytool -genkey -keyalg RSA -keysize 2048 -keystore keystore -alias java-wildcat -validity 9999"

    Coming to your second question, There is no other alternative way to login programatically to HealthVault.

    Regards,

    Madan kamuju

    Wednesday, July 7, 2010 8:48 AM

All replies

  • Hello Manjiriy,

    Could you Please find the below thread in HealthVault Java Library for resolving the issue of Creating a Certificate with private key with java SDK.

          http://healthvaultjavalib.codeplex.com/Thread/View.aspx?ThreadId=33813

    For getting the PersonId and RecordId you can use the below url.

         http://healthvaultjavalib.codeplex.com/Thread/View.aspx?ThreadId=83220

    Hope this helps and please let me know if you need any further help.

     

    Regards,

    Madan Kamuju

     

     

    Monday, July 5, 2010 1:24 PM
  • Hi,

    I have run these two commands

    keytool -genkey -keyalg RSA -keysize 2048 -keystore keystore -alias java-wildcat -validity 9999

    keytool -export -alias java-wildcat -keystore keystore > my-pub.cer

    then this file is created my-pub.cer

    In this link it is given that

    http://healthvaultjavalib.codeplex.com/wikipage?title=Getting%20Started

    send this to healthvault team. So I need to submit this to HealthVault?

    So public key or private key required in this case?

    Which keys the sample java application is using? because I have not generated any keys but still I am able to run the files. So can I use the same keys in my application?

     

     

     

    Tuesday, July 6, 2010 9:01 AM
  • Hello Manjiriy,

    When you are ready to push your application to production environment, you need to send public certificate(ex: my-pub.cer) that matches your private key, to Microsoft HealthVault team so that it can be registered on production server.

    please find the go-live guide here

    java application will uses the private key.

    Hope this helps and please let me know if you need any further help.

     

    Regards,

    Madan Kamuju


    • Proposed as answer by Madan kamuju Tuesday, July 6, 2010 10:23 AM
    Tuesday, July 6, 2010 10:23 AM
  • Hi Madan,

    Thanks a lot for your reply.

    Currently I do not want to deploy application on production environment. As I am just trying to call web services. but that is through simple java program (stand alone application) not throgh jsp/servlet. So in this case I require private key from HealthVault team?

    In the weight sample example first time the request is redirecting to healtvault Windows Live ID login, after login it is coming to local weight page.

    Instead of going to this link https://login.live.com/login.srf and then login, Is there any other way to login programatically throgh some webservice?

    Thanks..

    Tuesday, July 6, 2010 7:05 PM
  • Hello Manjiri,

    The private key will be generated in your machine's keystore after executing the below command . you dont need to get any private key from HealthVault team.

    "keytool -genkey -keyalg RSA -keysize 2048 -keystore keystore -alias java-wildcat -validity 9999"

    Coming to your second question, There is no other alternative way to login programatically to HealthVault.

    Regards,

    Madan kamuju

    Wednesday, July 7, 2010 8:48 AM
  • Hi Madan,

    Private key error is now resolved.

    I have created new application https://config.healthvault-ppe.com/ throgh this link as "Application type default." If I am setting application ID to this newly created apllication's ID,but I was getting

    Exception in thread "main" com.microsoft.hsg.HVException: com.microsoft.hsg.HVAccessDeniedException
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:68)
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:79)
        at com.microsoft.hsg.TrialConnection.main(TrialConnection.java:59)
    Caused by: com.microsoft.hsg.HVAccessDeniedException
        at com.microsoft.hsg.DefaultResponseCodeTranslator.translate(DefaultResponseCodeTranslator.java:31)
        at com.microsoft.hsg.DefaultResponseStrategy.checkResponseCode(DefaultResponseStrategy.java:74)
        at com.microsoft.hsg.DefaultResponseStrategy.doWithResponse(DefaultResponseStrategy.java:65)
        at com.microsoft.hsg.HVAccessor$1$1.handleResponse(HVAccessor.java:94)
        at com.microsoft.hsg.URLConnectionTransport.doRequest(URLConnectionTransport.java:48)
        at com.microsoft.hsg.Connection.makeRequest(Connection.java:177)
        at com.microsoft.hsg.Connection.send(Connection.java:142)
        at com.microsoft.hsg.HVAccessor$1.send(HVAccessor.java:91)
        at com.microsoft.hsg.SimpleSendStrategy.doWithSender(SimpleSendStrategy.java:20)
        at com.microsoft.hsg.HVAccessor.send(HVAccessor.java:89)
        at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:143)
        at com.microsoft.hsg.ApplicationAuthenticator.authenticate(ApplicationAuthenticator.java:130)
        at com.microsoft.hsg.Connection.authenticate(Connection.java:163)
        at com.microsoft.hsg.Connection.authenticate(Connection.java:172)
        at com.microsoft.hsg.ConnectionFactory.getConnection(ConnectionFactory.java:62)
        ... 2 more

    this exception.

    So I have changed app Id to default app id in sample, then that error has gone. but I am getting

    Exception in thread "main" com.microsoft.hsg.HVUncategorizedException
        at com.microsoft.hsg.DefaultResponseCodeTranslator.translate(DefaultResponseCodeTranslator.java:33)
        at com.microsoft.hsg.DefaultResponseStrategy.checkResponseCode(DefaultResponseStrategy.java:74)
        at com.microsoft.hsg.DefaultResponseStrategy.doWithResponse(DefaultResponseStrategy.java:65)
        at com.microsoft.hsg.HVAccessor$1$1.handleResponse(HVAccessor.java:94)
        at com.microsoft.hsg.URLConnectionTransport.doRequest(URLConnectionTransport.java:48)
        at com.microsoft.hsg.Connection.makeRequest(Connection.java:177)
        at com.microsoft.hsg.Connection.send(Connection.java:142)
        at com.microsoft.hsg.HVAccessor$1.send(HVAccessor.java:91)
        at com.microsoft.hsg.DefaultSendStrategy.doWithSender(DefaultSendStrategy.java:26)
        at com.microsoft.hsg.HVAccessor.send(HVAccessor.java:89)
        at com.microsoft.hsg.TrialConnection.main(TrialConnection.java:61)

    I have also tried to set OfflineUserId with my above application's created Admin => personId, but it is giving same error.

    I have reffered this link

    http://healthvaultjavalib.codeplex.com/Thread/View.aspx?ThreadId=32646&ANCHOR and trying following code.

            Request request = new Request();

            request.setTtl(3600 * 8 + 300); 
            request.setMethodName("GetPersonInfo");
            request.setOfflineUserId("ef2e8e6a-96c9-4e62-a03b-029fdc55c80d");
            //send request
            Connection connection = ConnectionFactory.getConnection();
            HVAccessor accessor = new HVAccessor();
            accessor.send(request, connection);

    So can you please let me know what is missing?

    Thanks..

    Wednesday, July 7, 2010 10:27 AM
  • Hello Manjiri,

    I have seen this HVUncategorizedException in HealthVault Java Library Forum thread and it is nothing but the Error code 67 is InvalidPersonOrGroupId.

    Could you please make sure that you are getting the person id using the same application id as the one your offline app is using? Both person id and record id are anonomized on a per-application basis.

    Could you please go through the below forum thread for complete code to execute.

    http://social.msdn.microsoft.com/Forums/en-US/healthvault/thread/a7f0f447-3818-4fb1-b973-cf887dc33f48

    Hope this helps.

    Regards,

    Madan Kamuju

     

    Wednesday, July 7, 2010 1:10 PM
  • Hi Madan,

     

    Above exception is not still resolved. I have put detailed description in following thread

    http://healthvaultjavalib.codeplex.com/Thread/View.aspx?ThreadId=218720

    Please check and let me know, I am missing anything in the flow. or I need to follow some other process?

     

    Thanks..

     

    Thursday, July 8, 2010 7:04 AM
  • Hello Manjiriy,

    I am contacting our technical team on this issue and i will update you once i get some information.

    Regards,

    Madan Kamuju

    Thursday, July 8, 2010 8:44 AM
  • FYI: for future reference, please ask new questions in new threads.  As the current exception is a new problem, and unrelated to the original question regarding the public/private key, it would be best handled via a new post.  As the developer asking the question, you will likely get a quicker response and more people looking at your question, as threads where the original question is answered will often be overlooked by those of us helping out here.

    Anyhow, we're more than happy to help either way, but just as general advice-- the quickest response is achieved by asking new questions in new posts.

    Thanks, and happy developing!

    Tuesday, July 13, 2010 11:30 PM