Results 1 to 4 of 4

Thread: Create account with Java API

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    6

    Default Create account with Java API

    Hi.

    I trying to create account with java api. I found many message but anything solved what i need.

    Zimbra version 5.0.14-GA

    I need to create a certificate, How? when i put it?

    After that i need create accounts.

    Thanks


    Libs
    Code:
    zimbracommon.jar
    zimbra-native.jar
    zimbrastore.jar
    dom4j-1.5.jar
    commons-httpclient-3.0.jar
    commons-logging.jar
    log4j-1.2.8.jar
    commons-codec-1.3.jar
    mail.jar
    Java Class
    Code:
    package zimbra;
    
    import java.io.IOException;
    
    import com.zimbra.common.soap.AccountConstants;
    import com.zimbra.common.soap.Element;
    import com.zimbra.common.soap.SoapFaultException;
    import com.zimbra.common.soap.SoapHttpTransport;
    import com.zimbra.cs.servlet.ZimbraServlet;
    
    public class AccountTest {
    
    	public static void main(String[] args) {
    		try {
    
    			SoapHttpTransport trans = null;
    	
    			trans = new SoapHttpTransport("https://zimbra.test.br:7071" + ZimbraServlet.USER_SERVICE_URI);
    	
    			Element req = Element.XMLElement.mFactory.createElement(AccountConstants.AUTH_REQUEST);
    			req.addAttribute(AccountConstants.E_ACCOUNT,"admin@zimbra.test.br");
    			req.addAttribute(AccountConstants.E_PASSWORD,"BananaMole");
    			
    			Element resp;
    			resp = trans.invoke(req);
    			
    	
    			System.out.println(req);
    			System.out.println(resp);
    		
    		} catch (SoapFaultException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    }
    ERROR
    Code:
    log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpParams).
    log4j:WARN Please initialize the log4j system properly.
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
    	at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
    	at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
    	at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
    	at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
    	at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
    	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
    	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
    	at java.io.FilterOutputStream.flush(FilterOutputStream.java:123)
    	at org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:150)
    	at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
    	at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
    	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
    	at com.zimbra.common.soap.SoapHttpTransport.invoke(SoapHttpTransport.java:243)
    	at com.zimbra.common.soap.SoapHttpTransport.invoke(SoapHttpTransport.java:217)
    	at com.zimbra.common.soap.SoapTransport.invoke(SoapTransport.java:315)
    	at com.zimbra.common.soap.SoapTransport.invoke(SoapTransport.java:279)
    	at zimbra.AccountTest.main(AccountTest.java:25)
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
    	at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
    	at sun.security.validator.Validator.validate(Validator.java:218)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
    	... 23 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
    	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
    	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
    	... 29 more

  2. #2
    Join Date
    Apr 2009
    Posts
    3
    Rep Power
    6

    Default SSL self-signed

    I think the problem it's the certificate self-sign on my server.

    Someone know what should i do to import the server certificate?

  3. #3
    Join Date
    Jul 2009
    Posts
    7
    Rep Power
    6

  4. #4
    Join Date
    Aug 2013
    Posts
    1
    Rep Power
    2

    Default Certificate

    Quote Originally Posted by satangozz View Post
    Hi.

    I trying to create account with java api. I found many message but anything solved what i need.

    Zimbra version 5.0.14-GA

    I need to create a certificate, How? when i put it?

    After that i need create accounts.

    Thanks


    Libs
    Code:
    zimbracommon.jar
    zimbra-native.jar
    zimbrastore.jar
    dom4j-1.5.jar
    commons-httpclient-3.0.jar
    commons-logging.jar
    log4j-1.2.8.jar
    commons-codec-1.3.jar
    mail.jar
    Java Class
    Code:
    package zimbra;
    
    import java.io.IOException;
    
    import com.zimbra.common.soap.AccountConstants;
    import com.zimbra.common.soap.Element;
    import com.zimbra.common.soap.SoapFaultException;
    import com.zimbra.common.soap.SoapHttpTransport;
    import com.zimbra.cs.servlet.ZimbraServlet;
    
    public class AccountTest {
    
    	public static void main(String[] args) {
    		try {
    
    			SoapHttpTransport trans = null;
    	
    			trans = new SoapHttpTransport("https://zimbra.test.br:7071" + ZimbraServlet.USER_SERVICE_URI);
    	
    			Element req = Element.XMLElement.mFactory.createElement(AccountConstants.AUTH_REQUEST);
    			req.addAttribute(AccountConstants.E_ACCOUNT,"admin@zimbra.test.br");
    			req.addAttribute(AccountConstants.E_PASSWORD,"BananaMole");
    			
    			Element resp;
    			resp = trans.invoke(req);
    			
    	
    			System.out.println(req);
    			System.out.println(resp);
    		
    		} catch (SoapFaultException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    }
    ERROR
    Code:
    log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpParams).
    log4j:WARN Please initialize the log4j system properly.
    javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1611)
    	at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:187)
    	at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:181)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1035)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:124)
    	at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
    	at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1112)
    	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
    	at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
    	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
    	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
    	at java.io.FilterOutputStream.flush(FilterOutputStream.java:123)
    	at org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:150)
    	at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:495)
    	at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1973)
    	at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
    	at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    	at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
    	at com.zimbra.common.soap.SoapHttpTransport.invoke(SoapHttpTransport.java:243)
    	at com.zimbra.common.soap.SoapHttpTransport.invoke(SoapHttpTransport.java:217)
    	at com.zimbra.common.soap.SoapTransport.invoke(SoapTransport.java:315)
    	at com.zimbra.common.soap.SoapTransport.invoke(SoapTransport.java:279)
    	at zimbra.AccountTest.main(AccountTest.java:25)
    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:285)
    	at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:191)
    	at sun.security.validator.Validator.validate(Validator.java:218)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:126)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:209)
    	at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:249)
    	at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1014)
    	... 23 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    	at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:174)
    	at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:238)
    	at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:280)
    	... 29 more
    Problem is ceritificate, in this link is response http://www.thinkplexx.com/learn/how

    In this link you can get certificate from server https://gist.github.com/hprange/4091496

Similar Threads

  1. java program to creataccount
    By thangavel in forum Developers
    Replies: 2
    Last Post: 04-03-2009, 12:30 AM
  2. [SOLVED] Web Service to create mailbox account
    By jv1410 in forum Developers
    Replies: 1
    Last Post: 10-19-2007, 05:31 PM
  3. Fedora 5: Could not create the Java virtual machine
    By mi2enno in forum Installation
    Replies: 6
    Last Post: 06-01-2007, 04:16 AM
  4. Tomcat, Java VM Problems - RAM related? Help
    By Mo_Hong in forum Administrators
    Replies: 3
    Last Post: 03-28-2007, 03:00 PM
  5. Replies: 3
    Last Post: 02-09-2006, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •