You appear to use the hashed password and not the password itself. Use the real password to construct the session string.<div><br></div><div><br><div class="gmail_quote">On Fri, Dec 9, 2011 at 5:38 PM, Ksenija Poljak <span dir="ltr"><<a href="mailto:ksenija.poljak@altus-it.hr">ksenija.poljak@altus-it.hr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I do the same thing and is not working. This line alone does not cause any problems. But when I try to use UserPool.info(client); or any other method, returned error string is: HTTP server returned unexpected status: Unauthorized.<div class="HOEnZb">
<div class="h5"><div>
<br><div class="gmail_quote">On Fri, Dec 9, 2011 at 12:52 PM, Prakhar Srivastava <span dir="ltr"><<a href="mailto:prakhar.apj@gmail.com" target="_blank">prakhar.apj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi,<div>This is how I create a connection to the server</div><div>oneClient = new Client("oneadmin:onepass","<a href="http://192.168.1.5:2633/RPC2" target="_blank">http://192.168.1.5:2633/RPC2</a>");</div>

<div><br></div>
<div>Check that you are using the </div><div>import org.opennebula.client.Client; </div><div><br></div><div>to make user that you are using the correct client. Also send the stacktrace if you are still facing problems.</div>

<span><font color="#888888">
<div><br></div></font></span><div><span><font color="#888888">Prakhar</font></span><div><div><br><br><div class="gmail_quote">On Fri, Dec 9, 2011 at 5:03 PM, Ksenija Poljak <span dir="ltr"><<a href="mailto:ksenija.poljak@altus-it.hr" target="_blank">ksenija.poljak@altus-it.hr</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Even when I use that API, I still get Unauthorized exception.<div>What is the proper way to form a session string that gets user (for start oneadmin) authenticated and authorized in Java client so that I can test other methods?</div>



<div>I use client function: Client client = new Client("session_string", "server_url");</div><div><br></div><div><pre style="background-color:rgb(255,255,255)">public <b>Client</b>(java.lang.String secret,
              java.lang.String endpoint)
       throws <a href="http://opennebula.org/doc/3.0/oca/java/org/opennebula/client/ClientConfigurationException.html" title="class in org.opennebula.client" target="_blank">ClientConfigurationException</a></pre></div><div>


<div><div><br><div><br>
<div class="gmail_quote">On Thu, Dec 8, 2011 at 5:16 PM, Prakhar Srivastava <span dir="ltr"><<a href="mailto:prakhar.apj@gmail.com" target="_blank">prakhar.apj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



Hi Ksenija,<div>Why don't you simply use the <a href="http://opennebula.org/documentation:rel3.0:java" title="documentation:rel3.0:java" style="font-size:13px;color:rgb(0,152,195);font-family:Arial,Verdana,Geneva,Helvetica,sans-serif;line-height:18px;text-align:left;background-color:rgb(245,245,245)" target="_blank">Java OpenNebula Cloud API</a> that is packaged with opennebula. If there is no specific scenario, its best to use them.</div>




<div><br></div><div>Prakhar<br><br><div class="gmail_quote"><div><div>On Thu, Dec 8, 2011 at 3:23 PM, Ksenija Poljak <span dir="ltr"><<a href="mailto:ksenija.poljak@altus-it.hr" target="_blank">ksenija.poljak@altus-it.hr</a>></span> wrote:<br>




</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Hi, I'm using opennebula 3 and I'm trying to write an xmlrpc Java client.<div>
I'm not able to connect my client to opennebula server.</div>
<div>I keep getting unauthorized exception:</div><div><br></div><div>org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Unauthorized</div>
<div><br></div><div>My testing program:</div><div><br></div><div><div>package open.nebula.client;</div><div><br></div><div><br></div><div>import java.net.MalformedURLException;</div><div>import java.net.URL;</div><div><br>





</div><div>import org.apache.xmlrpc.XmlRpcException;</div><div>import org.apache.xmlrpc.client.XmlRpcClient;</div><div>import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;</div><div><br></div><div>public class OpenNebulaClient{</div>





<div><span style="white-space:pre-wrap">  </span>private XmlRpcClient client = new XmlRpcClient();;</div><div><span style="white-space:pre-wrap">       </span>private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();</div>





<div><span style="white-space:pre-wrap">  </span>private String session = "oneadmin:ffd775fdb8e47ebf5b68513843f31742f74118e8";</div><div><span style="white-space:pre-wrap">  </span></div>
<div><span style="white-space:pre-wrap">  </span>public OpenNebulaClient(String server_url)</div><div><span style="white-space:pre-wrap">       </span>{</div><div><span style="white-space:pre-wrap">                        </span>try{</div>
<div><span style="white-space:pre-wrap">                          </span>this.config.setServerURL(new URL(server_url));</div><div><span style="white-space:pre-wrap">                           </span>this.client.setConfig(this.config);</div>
<div><span style="white-space:pre-wrap">                  </span>}catch(MalformedURLException e){</div><div><span style="white-space:pre-wrap">                         </span>System.err.println(e);</div><div><span style="white-space:pre-wrap">                   </span>}</div>





<div><span style="white-space:pre-wrap">  </span>}<span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>public void getUserInfo(int id) throws XmlRpcException</div>





<div><span style="white-space:pre-wrap">  </span>{</div><div><span style="white-space:pre-wrap">                </span>Object[] params = {session,id};</div><div><span style="white-space:pre-wrap">          </span>try {</div>
<div>            Object[] result = (Object[])this.client.execute("<a href="http://one.user.info" target="_blank">one.user.info</a>",params);</div><div>            if(!result[0].equals(null)) {</div><div>            <span style="white-space:pre-wrap">              </span>boolean success = (Boolean)result[0];</div>





<div>            <span style="white-space:pre-wrap">              </span>String str_res = (String)result[1];</div><div>            <span style="white-space:pre-wrap">          </span>System.out.println("success="+success);</div>
<div>            <span style="white-space:pre-wrap">              </span>System.out.println("result="+str_res);</div><div>            }else{</div><div>            <span style="white-space:pre-wrap">    </span>System.out.println("success=0");</div>





<div>            }</div><div><span style="white-space:pre-wrap">              </span>}catch (XmlRpcException e) {</div><div><span style="white-space:pre-wrap">                     </span>System.err.println(e);</div>
<div><span style="white-space:pre-wrap">                  </span>//e.printStackTrace();</div><div>        }</div><div><span style="white-space:pre-wrap">   </span>}</div><div><span style="white-space:pre-wrap">        </span></div>
<div><span style="white-space:pre-wrap">  </span>public static void main(String[] args)</div><div><span style="white-space:pre-wrap">   </span>{</div><div><span style="white-space:pre-wrap">                </span>OpenNebulaClient on_client = new</div>





<div><br></div><div> OpenNebulaClient("http://server_ip:port/RPC2");</div><div><span style="white-space:pre-wrap">                </span>try{</div><div><span style="white-space:pre-wrap">                     </span>on_client.getUserInfo(0);</div>





<div><span style="white-space:pre-wrap">          </span>}catch(XmlRpcException xmlrpce){</div><div><span style="white-space:pre-wrap">                 </span>System.err.println(xmlrpce);</div><div><span style="white-space:pre-wrap">             </span>}</div>





<div><span style="white-space:pre-wrap">  </span>}</div><div>}</div></div><div><br></div><div><br></div><div>I'm confused becose when I look at examples on the web, there are methods used as one.userinfo, and on opennebula official site they are listed in form: <a href="http://one.user.info" target="_blank">one.user.info</a>.</div>





<div>Session string I used consists of username:password that I get listed with command: 'oneuser show 0' on opennebula server.</div><div>Client and opennebula server are on different machines.</div><div>I'm not sure what I do wrong. Any suggestions would be more than helpfull. Tnx in advance.</div>





<div><br></div><div>the full stackTrace of error:</div><div><br></div><div><div>org.apache.xmlrpc.client.XmlRpcHttpTransportException: HTTP server returned unexpected status: Unauthorized</div><div><span style="white-space:pre-wrap">       </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:94)</div>





<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:152)</div><div><span style="white-space:pre-wrap">    </span>at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)</div>





<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)</div><div><span style="white-space:pre-wrap">   </span>at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)</div>





<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)</div><div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)</div>





<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)</div><div><span style="white-space:pre-wrap">  </span>at open.nebula.client.OpenNebulaClient.getUserInfo(OpenNebulaClient.java:30)</div>





<div><span style="white-space:pre-wrap">  </span>at open.nebula.client.OpenNebulaClient.main(OpenNebulaClient.java:49)</div></div>
<br></div></div>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div></div>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org" target="_blank">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opennebula.org">Users@lists.opennebula.org</a><br>
<a href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br>
<br></blockquote></div><br></div>