Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: [SOLVED] help about SoapProvisioning

  1. #1
    majodo is offline Senior Member
    Join Date
    Mar 2007
    Posts
    55
    Rep Power
    8

    Default [SOLVED] help about SoapProvisioning

    Hello,
    I am trying to use services of SoapProvisioning specialy : services of creating new account.
    I try this but i have a java.lang.NullPointerException:
    --------------------------------------------------------------
    try
    {
    SoapProvisioning sp ;
    sp.soapSetURI("http://10.22.28.14" + ZimbraServlet.USER_SERVICE_URI);
    sp.soapAdminAuthenticate("admin","****");
    sp.createAccount("new_user@domain.com", "password", null);
    }
    catch(Exception ex){ ex.printStackTrace(); }
    ---------------------------------------------------------------------

  2. #2
    Klug's Avatar
    Klug is offline Moderator
    Join Date
    Mar 2006
    Location
    Beaucaire, France
    Posts
    2,292
    Rep Power
    13

    Default

    Did you look at the other forum and the answer I gave you on that ?

    Soap services are available on port 7070 : http://localhost:7070/service/soap/

  3. #3
    majodo is offline Senior Member
    Join Date
    Mar 2007
    Posts
    55
    Rep Power
    8

    Default

    ok now the problem is in: sp.soapAdminAuthenticate
    the error is:
    -------------------------------------------------
    log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
    log4j:WARN Please initialize the log4j system properly.
    com.zimbra.soap.SoapFaultException: unknown document: AuthRequest
    at com.zimbra.soap.Soap12Protocol.soapFault(Soap12Pro tocol.java:102)
    at com.zimbra.soap.SoapTransport.extractBodyElement(S oapTransport.java:215)
    at com.zimbra.soap.SoapTransport.parseSoapResponse(So apTransport.java:191)
    at com.zimbra.soap.SoapHttpTransport.invoke(SoapHttpT ransport.java:214)
    at com.zimbra.soap.SoapTransport.invoke(SoapTransport .java:231)
    at com.zimbra.cs.account.soap.SoapProvisioning.invoke (SoapProvisioning.java:156)
    at com.zimbra.cs.account.soap.SoapProvisioning.soapAd minAuthenticate(SoapProvisioning.java:128)
    at com.zimbra.cs.account.soap.Test1.creer_compte(Test 1.java:23)
    at com.zimbra.cs.account.soap.Test1.main(Test1.java:3 4)
    ----------------------------------------------------------------------

  4. #4
    dkarp is offline Zimbra Employee
    Join Date
    Aug 2005
    Posts
    1,433
    Rep Power
    11

    Default admin auth requires admin port

    If you're trying to auth as admin, you need to point SoapProvisioning at the admin port and URL, not the regular port/URL.
    Bugzilla - Wiki - Downloads - Before posting... Search!

  5. #5
    majodo is offline Senior Member
    Join Date
    Mar 2007
    Posts
    55
    Rep Power
    8

    Default

    yes i try https://ip_zimbrahost:7071/service/admin/soap but also gives me exception

  6. #6
    mrojek is offline Member
    Join Date
    May 2007
    Location
    Poland Warszawa
    Posts
    11
    Rep Power
    7

    Default

    Code:
    Hello,
    I am trying to use services of SoapProvisioning specialy : services of creating new account.
    I try this but i have a java.lang.NullPointerException:
    --------------------------------------------------------------
    try
    		{	
    			SoapProvisioning sp ;
    			sp.soapSetURI("http://10.22.28.14" + ZimbraServlet.USER_SERVICE_URI);
    			sp.soapAdminAuthenticate("admin","****");
    			sp.createAccount("new_user@domain.com", "password", null);
    		}
    		catch(Exception ex){ ex.printStackTrace(); }
    ---------------------------------------------------------------------
    You must change it for
    Code:
    "https://10.22.28.14:7071"+ZimbraServlet.ADMIN_SERVICE_URI
    Last edited by mrojek; 05-10-2007 at 01:29 AM.

  7. #7
    majodo is offline Senior Member
    Join Date
    Mar 2007
    Posts
    55
    Rep Power
    8

    Default

    also with : https://10.22.28.14:7071"+ZimbraServlet.ADMIN_SERVICE_URI
    i had an exception in sp.soapAdminAuthenticate("admin","****") :
    -----------------------------------------------------------------------
    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: 10.22.28.14
    at com.zimbra.cs.zclient.ZClientException.IO_ERROR(ZC lientException.java:54)
    ------------------------------------------------------------------------

    i try the uri "https://10.22.28.14:7071/service/admin/soap" in my browser
    and i get the tomcat "error:HTTP Status 405 - HTTP method GET is not supported by this URL" is that normal ?
    what wrong in my: sp.soapAdminAuthenticate("admin","****") ?

  8. #8
    mrojek is offline Member
    Join Date
    May 2007
    Location
    Poland Warszawa
    Posts
    11
    Rep Power
    7

    Default

    OK i have this same problem. You try connect by https it's secure connection with changing public key. You server hasn't got a certificate from trustet provider (for example verisign.com) or samthing like that and java don't trust this server you must add this certificate to java certificate file.

  9. #9
    mrojek is offline Member
    Join Date
    May 2007
    Location
    Poland Warszawa
    Posts
    11
    Rep Power
    7

    Default

    I use this simple java class:
    Code:
    import java.io.*;
    import java.net.URL;
    
    import java.security.*;
    import java.security.cert.*;
    
    import javax.net.ssl.*;
    
    public class InstallCert {
    
        public static void main(String[] args) throws Exception {
    	String host;
    	int port;
    	char[] passphrase;
    	args = new String[1];
    	args[0]="www.example.com:7071";
    	if ((args.length == 1) || (args.length == 2)) {
    	    String[] c = args[0].split(":");
    	    host = c[0];
    	    port = (c.length == 1) ? 443 : Integer.parseInt(c[1]);
    	    String p = (args.length == 1) ? "changeit" : args[1];
    	    passphrase = p.toCharArray();
    	} else {
    	    System.out.println("Usage: java InstallCert <host>[:port] [passphrase]");
    	    return;
    	}
    //for my windows and java
    	File file = new File("C:\\Program Files\\Java\\jre1.6.0\\lib\\security\\cacerts");
    //	if (file.isFile() == false) {
    //	    char SEP = File.separatorChar;
    //	   
    //	    File dir = new File(System.getProperty("java.home") + SEP
    //		    + "lib" + SEP + "security");
    //	    file = new File(dir, "jssecacerts");
    //	    if (file.isFile() == false) {
    //		file = new File(dir, "cacerts");
    //	    }
    //	}
    	System.out.println("Loading KeyStore " + file + "...");
    	InputStream in = new FileInputStream(file);
    	KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
    	ks.load(in, passphrase);
    	in.close();
    
    	SSLContext context = SSLContext.getInstance("TLS");
    	TrustManagerFactory tmf =
    	    TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
    	tmf.init(ks);
    	X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0];
    	SavingTrustManager tm = new SavingTrustManager(defaultTrustManager);
    	context.init(null, new TrustManager[] {tm}, null);
    	SSLSocketFactory factory = context.getSocketFactory();
    	
    	System.out.println("Opening connection to " + host + ":" + port + "...");
    	SSLSocket socket = (SSLSocket)factory.createSocket(host, port);
    	socket.setSoTimeout(10000);
    	try {
    	    System.out.println("Starting SSL handshake...");
    	    socket.startHandshake();
    	    socket.close();
    	    System.out.println();
    	    System.out.println("No errors, certificate is already trusted");
    	} catch (SSLException e) {
    	    System.out.println();
    	    e.printStackTrace(System.out);
    	}
    
    	X509Certificate[] chain = tm.chain;
    	if (chain == null) {
    	    System.out.println("Could not obtain server certificate chain");
    	    return;
    	}
    
    	BufferedReader reader =
    		new BufferedReader(new InputStreamReader(System.in));
    
    	System.out.println();
    	System.out.println("Server sent " + chain.length + " certificate(s):");
    	System.out.println();
    	MessageDigest sha1 = MessageDigest.getInstance("SHA1");
    	MessageDigest md5 = MessageDigest.getInstance("MD5");
    	for (int i = 0; i < chain.length; i++) {
    	    X509Certificate cert = chain[i];
    	    System.out.println
    	    	(" " + (i + 1) + " Subject " + cert.getSubjectDN());
    	    System.out.println("   Issuer  " + cert.getIssuerDN());
    	    sha1.update(cert.getEncoded());
    	    System.out.println("   sha1    " + toHexString(sha1.digest()));
    	    md5.update(cert.getEncoded());
    	    System.out.println("   md5     " + toHexString(md5.digest()));
    	    System.out.println();
    	}
    
    	System.out.println("Enter certificate to add to trusted keystore or 'q' to quit: [1]");
    	String line = reader.readLine().trim();
    	int k;
    	try {
    	    k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1;
    	} catch (NumberFormatException e) {
    	    System.out.println("KeyStore not changed");
    	    return;
    	}
    
    	X509Certificate cert = chain[k];
    	String alias = host + "-" + (k + 1);
    	ks.setCertificateEntry(alias, cert);
    
    	OutputStream out = new FileOutputStream("C:\\Program Files\\Java\\jre1.6.0\\lib\\security\\cacerts");
    	ks.store(out, passphrase);
    	out.close();
    
    	System.out.println();
    	System.out.println(cert);
    	System.out.println();
    	System.out.println
    		("Added certificate to keystore 'jssecacerts' using alias '"
    		+ alias + "'");
    	 String gdzie = new String(System.getProperty("java.home//") +
    			   "lib//"   + "security");
    		    System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    		    System.out.println(gdzie);
    		    
        }
        
        private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray();
        
        private static String toHexString(byte[] bytes) {
    	StringBuilder sb = new StringBuilder(bytes.length * 3);
    	for (int b : bytes) {
    	    b &= 0xff;
    	    sb.append(HEXDIGITS[b >> 4]);
    	    sb.append(HEXDIGITS[b & 15]);
    	    sb.append(' ');
    	}
    	return sb.toString();
        }
    
        private static class SavingTrustManager implements X509TrustManager {
    	
    	private final X509TrustManager tm;
    	private X509Certificate[] chain;
    	
    	SavingTrustManager(X509TrustManager tm) {
    	    this.tm = tm;
    	}
        
    	public X509Certificate[] getAcceptedIssuers() {
    	    throw new UnsupportedOperationException();
    	}
        
    	public void checkClientTrusted(X509Certificate[] chain, String authType)
    		throws CertificateException {
    	    throw new UnsupportedOperationException();
    	}
        
    	public void checkServerTrusted(X509Certificate[] chain, String authType)
    		throws CertificateException {
    	    this.chain = chain;
    	    tm.checkServerTrusted(chain, authType);
    	}
        }
    
    }
    It should work

  10. #10
    majodo is offline Senior Member
    Join Date
    Mar 2007
    Posts
    55
    Rep Power
    8

    Default

    Thanks a lot it works very well now
    and congratulation for your work.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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