Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
 
Go Back   Zimbra - Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra - Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack (1) Thread Tools Display Modes
  #11 (permalink)  
Old 01-08-2008, 12:47 PM
Junior Member
 
Posts: 9
Default success!!

dkarp .... thanks !!

This url worked: https://localhost:7071/service/admin/soap

I was able to successfully add an account.

Thanks again !!

__________________________________________________ ________
For those struggling with SOAP here is my code:

1] Make sure the 'certificates' issue is sorted out first, we used a commercial certificate.
2] We used Eclipse IDE on Linux and Zimbra 4.8/Java 1.5
3] Make sure the commons-httpclient-3.0.jar and commons-codec-1.3.jar match up and make sure you use the correct jar files all around or you run the risk of cross-referencing. Also make sure you have the correct versions of zimbrastore.jar and zimbracommons.jar.

import java.util.HashMap;
import java.util.Map;
import com.zimbra.common.service.ServiceException;
import com.zimbra.cs.account.Account;
import com.zimbra.cs.account.soap.SoapProvisioning;


final static String FNAME = "Joe";
final static String LNAME = "Shmoe";
final static String ADDRESS = "101 Market Street";
final static String CITY = "San Francisco";
final static String STATE = "CA";
final static String POSTALCODE = "94105";
static private Account createZimbraAccount;

public static void main(String[] args) {

Map<String, Object> map = new HashMap<String, Object>();
try {
map.put("gn", FNAME);
map.put("sn", LNAME);
map.put("street", ADDRESS);
map.put("l", CITY);
map.put("st", STATE);
map.put("postalCode", POSTALCODE);
} catch (Exception e) {
e.printStackTrace();
}

try {
SoapProvisioning sp = new SoapProvisioning();
sp.soapSetURI("https://localhost:7071/service/admin/soap");
sp.soapAdminAuthenticate("admin","password");
createZimbraAccount = sp.createAccount("a@b.com", "password", map);

}
catch(ServiceException se) {
se.printStackTrace();
}
}


This should help you create a simple zimbra account using SOAP.

dkarp ... thanks again ....

Last edited by ozomozo : 01-08-2008 at 02:21 PM.
Reply With Quote
  #12 (permalink)  
Old 01-31-2008, 12:56 AM
Ada Ada is offline
Member
 
Posts: 12
Default

Hi Ozomozo,

Where can I find zimbrastore.jar and zimbracommons.jar?

Thanks
Reply With Quote
  #13 (permalink)  
Old 01-31-2008, 07:07 AM
Zimbra Employee
 
Posts: 1,434
Default

They're in the Zimbra OSS distributions. Just unpack and look in /opt/zimbra/lib/jars, I believe.
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #14 (permalink)  
Old 02-11-2008, 08:59 AM
Ada Ada is offline
Member
 
Posts: 12
Default

Thanks for the reply. I found it in my Zimbra Server....

In class SoapProvisioning there's a method called preAuthAccount. I am trying to make a Signal Sign On in Zimbra but I allways get a error of authentication failed. Code:account.AUTH_FAILED
¿After the call preAuthAccount is there something else needed? Zimbra will open the mailbox of this account automaticaly?

I tried another option following the steps described in:
Preauth - Zimbra :: Wiki

1. append usu1@domain.com|name|0|timestamp
2. preauthValue = encrypt with HMAC and the zimbraPreauthKey
3. build the URL with /service/preauth?account=usu1@domain.com&expires=0&timestam p=timestamp&preauth = (preauthValue)

I am kind of stuck with this issue, any help or hint would be so nice.
Thanks

Last edited by Ada : 02-11-2008 at 09:03 AM.
Reply With Quote
  #15 (permalink)  
Old 02-11-2008, 09:10 AM
Ada Ada is offline
Member
 
Posts: 12
Default

Checking inside method preAuthAccount,
uses the parameters in different order than is explained in Zimbra wiki.

concat the values for account, by, expires, timestamp together
(in that order, order is definitely important (Zimbra Wiki)


This is code for preAuthAccount method.
XMLElement req = new XMLElement(AccountConstants.AUTH_REQUEST);
Element a = req.addElement(AccountConstants.E_ACCOUNT);
a.addAttribute(AccountConstants.A_BY, "name");
a.setText(accountName);
Element p = req.addElement(AccountConstants.E_PREAUTH);
p.addAttribute(AccountConstants.A_TIMESTAMP, timestamp);
p.addAttribute(AccountConstants.A_BY, accountBy);
p.addAttribute(AccountConstants.A_EXPIRES, expires);
p.setText(preAuth);
invoke(req);


¿Could be this the problem?
Anybody has tried this method in SoapProvisioning class?

Thanks
Reply With Quote
  #16 (permalink)  
Old 09-02-2008, 01:53 AM
Loyal Member
 
Posts: 91
Default

I cannot get what you all trying to do...

I run this code

Code:
import java.io.IOException;
import com.zimbra.common.service.ServiceException;
import com.zimbra.common.soap.Element;
import com.zimbra.common.soap.SoapHttpTransport;
import com.zimbra.cs.account.soap.SoapProvisioning;
import com.zimbra.cs.service.mail.MailService;
import com.zimbra.cs.service.account.AccountService;
import com.zimbra.cs.servlet.ZimbraServlet;
import com.zimbra.cs.util.Zimbra;
import com.zimbra.soap.ZimbraSoapContext;

public class TestZClient {
    public static void main(String [] args) throws ServiceException
    {
  SoapProvisioning sp = new SoapProvisioning();
        sp.soapSetURI("https://3.244.4.16:7071/zimbraAdmin/");
        sp.soapAdminAuthenticate("admin","fsloke999");
        System.out.println(sp.GM_ZIMBRA);
    }
}
but the warning code is:
Quote:
Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at com.zimbra.cs.account.soap.SoapProvisioning.soapSe tURI(SoapProvisioning.java:89)
at TestZClient.main(TestZClient.java:45)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(URLClassLoader.java: 200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
... 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Thank you

Last edited by fsloke : 09-30-2008 at 08:18 AM.
Reply With Quote
  #17 (permalink)  
Old 09-02-2008, 10:55 AM
Zimbra Employee
 
Posts: 1,434
Default

Looks like you're missing a library. Add dom4j-1.5.jar to your Java classpath and try again.
__________________
Bugzilla - Wiki - Downloads - Before posting... Search!
Reply With Quote
  #18 (permalink)  
Old 09-02-2008, 08:49 PM
Loyal Member
 
Posts: 91
Default

I forgot to update this post when I solve the dom4j-1.5.jar error.

Here is the second error:
Quote:
init:
deps-jar:
compile-single:
run-single:
log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.params.DefaultHttpP arams).
log4j:WARN Please initialize the log4j system properly.
com.zimbra.cs.zclient.ZClientException: invoke sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target, server: 3.244.4.16
ExceptionId:main:1220409936312:4441cb39ded2325a
Code:zclient.IO_ERROR
at com.zimbra.cs.zclient.ZClientException.IO_ERROR(ZC lientException.java:47)
at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:189)
at com.zimbra.cs.account.soap.SoapProvisioning.soapAd minAuthenticate(SoapProvisioning.java:145)
at TestZClient.main(TestZClient.java:88)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1591)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:975)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:123)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1096)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRe cord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write (AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
at java.io.FilterOutputStream.flush(FilterOutputStrea m.java:123)
at org.apache.commons.httpclient.methods.StringReques tEntity.writeRequest(StringRequestEntity.java:150)
at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.writeRequestBody(EntityEnclosingMethod.j ava:495)
at org.apache.commons.httpclient.HttpMethodBase.write Request(HttpMethodBase.java:1973)
at org.apache.commons.httpclient.HttpMethodBase.execu te(HttpMethodBase.java:993)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:324)
at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:234)
at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:297)
at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:261)
at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:185)
... 2 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:285)
at sun.security.validator.PKIXValidator.engineValidat e(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validato r.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.serv erCertificate(ClientHandshaker.java:954)
... 24 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderE xception: 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(CertPathB uilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:280)
... 30 more
BUILD SUCCESSFUL (total time: 2 seconds)
Is there have any simplest sample code (without error) that can do querying such send email or create account....

Thank you
Reply With Quote
  #19 (permalink)  
Old 09-30-2008, 02:50 AM
Active Member
 
Posts: 25
Default

Quote:
Originally Posted by ozomozo View Post
dkarp .... thanks !!

This url worked: https://localhost:7071/service/admin/soap

I was able to successfully add an account.

Thanks again !!

__________________________________________________ ________
For those struggling with SOAP here is my code:

1] Make sure the 'certificates' issue is sorted out first, we used a commercial certificate.
What do you mean with "make sure the certificates issued is sorted out first"?
I get this error:
sun.security.validator.ValidatorException

How can i set a certificate?
Reply With Quote
  #20 (permalink)  
Old 06-03-2009, 03:04 PM
Starter Member
 
Posts: 1
Default

Quote:
Originally Posted by dkarp View Post
They're in the Zimbra OSS distributions. Just unpack and look in /opt/zimbra/lib/jars, I believe.
Hi,

I am getting this error while testing my SOAP code to create an Email Account..

Caused by: java.lang.IllegalArgumentException: host parameter is null
at org.apache.commons.httpclient.HttpConnection.<init >(Unknown Source)
at org.apache.commons.httpclient.HttpConnection.<init >(Unknown Source)
at org.apache.commons.httpclient.SimpleHttpConnection Manager.getConnectionWithTimeout(Unknown Source)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(Unknown Source)
at org.apache.commons.httpclient.HttpClient.executeMe thod(Unknown Source)
at org.apache.commons.httpclient.HttpClient.executeMe thod(Unknown Source)
at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:258)
at com.zimbra.common.soap.SoapHttpTransport.invoke(So apHttpTransport.java:226)
at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:315)
at com.zimbra.common.soap.SoapTransport.invoke(SoapTr ansport.java:279)
at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:192)
at com.zimbra.cs.account.soap.SoapProvisioning.soapAd minAuthenticate(SoapProvisioning.java:145)
at com.ecommerce.imperia.service.ZimbraMailService.ad dZimbraEmailAccount(ZimbraMailService.java:69)
at org.jboss.seam.util.Reflections.invoke(Reflections .java:22)
at org.jboss.seam.intercept.RootInvocationContext.pro ceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:56)
at org.jboss.seam.transaction.RollbackInterceptor.aro undInvoke(RollbackInterceptor.java:28)
at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.BijectionInterceptor.aroundInv oke(BijectionInterceptor.java:77)
at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
at org.jboss.seam.transaction.TransactionInterceptor$ 1.work(TransactionInterceptor.java:95)
at org.jboss.seam.util.Work.workInTransaction(Work.ja va:47)
at org.jboss.seam.transaction.TransactionInterceptor. aroundInvoke(TransactionInterceptor.java:89)
at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroun dInvoke(MethodContextInterceptor.java:44)
at org.jboss.seam.intercept.SeamInvocationContext.pro ceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(Ro otInterceptor.java:107)
at org.jboss.seam.intercept.JavaBeanInterceptor.inter ceptInvocation(JavaBeanInterceptor.java:185)
at org.jboss.seam.intercept.JavaBeanInterceptor.invok e(JavaBeanInterceptor.java:103)
at com.ecommerce.imperia.service.ZimbraMailService_$$ _javassist_5.addZimbraEmailAccount(ZimbraMailServi ce_$$_javassist_5.java)
at org.jboss.el.util.ReflectionUtil.invokeMethod(Refl ectionUtil.java:329)

------------------------------------------------------------------------
And here is my Code:

import com.zimbra.common.service.ServiceException;
import com.zimbra.cs.account.Account;
import com.zimbra.cs.account.soap.SoapProvisioning;

public void addZimbraEmailAccount(){

final String FNAME = "Joe";
final String LNAME = "Shmoe";
final String ADDRESS = "101 Market Street";
final String CITY = "San Francisco";
final String STATE = "CA";
final String POSTALCODE = "94105";
Account createZimbraAccount;


Map<String, Object> map = new HashMap<String, Object>();
try {
map.put("gn", FNAME);
map.put("sn", LNAME);
map.put("street", ADDRESS);
map.put("|", CITY);
map.put("st", STATE);
map.put("postalcode", POSTALCODE);
} catch (Exception e) {
e.printStackTrace();
}

try {
SoapProvisioning sp = new SoapProvisioning();
sp.soapSetURI("https://localhost:7071/service/admin/soap");
sp.soapAdminAuthenticate("admin","password");
createZimbraAccount = sp.createAccount("a@b.com", "password", map);

}
catch(ServiceException se) {
se.printStackTrace();
}
}
Reply With Quote
Reply


Thread Tools
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

Zimbrablog.com




 

Search Engine Optimization by vBSEO 3.1.0