diff --git a/sharepoint/api/pom.xml b/sharepoint/api/pom.xml new file mode 100644 index 0000000..1da2b64 --- /dev/null +++ b/sharepoint/api/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + + de.muehlencord.shared + sharepoint + 1.0-SNAPSHOT + + + api + jar + api + + + + + + org.jvnet.jax-ws-commons + jaxws-maven-plugin + 2.2 + + + ${project.build.directory}/generated-sources/jaxws-wsimport + + + + + authentication2010 + generate-sources + + wsimport + + + ${basedir}/src/main/resources/2010/wsdl + + authentication.wsdl + + /2010/wsdl/authentication.wsdl + com.microsoft.schemas.sharepoint.soap.authentication + + authentication.wsdl + + + + + alerts2010 + generate-sources + + wsimport + + + ${basedir}/src/main/resources/2010/wsdl + + alerts.wsdl + + /2010/wsdl/alerts.wsdl + com.microsoft.schemas.sharepoint.soap.alerts + + alerts.wsdl + + + + + sites2010 + generate-sources + + wsimport + + + ${basedir}/src/main/resources/2010/wsdl + + sites.wsdl + + /2010/wsdl/sites.wsdl + com.microsoft.schemas.sharepoint.soap.sites + + sites.wsdl + + + + + webs2010 + generate-sources + + wsimport + + + ${basedir}/src/main/resources/2010/wsdl + + webs.wsdl + + /2010/wsdl/webs.wsdl + com.microsoft.schemas.sharepoint.soap.webs + + webs.wsdl + + + + + + + + + + junit + junit + 4.10 + test + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/AbstractAuthenticator.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/AbstractAuthenticator.java new file mode 100644 index 0000000..67a1b93 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/AbstractAuthenticator.java @@ -0,0 +1,49 @@ +package de.muehlencord.shared.sharepoint.api; + +import java.net.Authenticator; + +/** + * + * @author jomu + */ +public class AbstractAuthenticator extends Authenticator { + + String domain; + String user; + String password; + + public AbstractAuthenticator(String user, String password) { + super(); + this.domain = null; + this.user = user; + this.password = password; + } + + public AbstractAuthenticator(String domain, String user, String password) { + super(); + this.domain = domain; + this.user = user; + this.password = password; + } + + public String getDomain() { + return domain; + } + + public String getUser() { + return user; + } + + public String getPassword() { + return password; + } + + public String getUserName() { + String userName = user; + if (domain != null && !domain.isEmpty()) { + userName = domain + "\\" + user; + } + return userName; + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticator.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticator.java new file mode 100644 index 0000000..7372799 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticator.java @@ -0,0 +1,24 @@ +package de.muehlencord.shared.sharepoint.api; + +import java.net.PasswordAuthentication; + +/** + * + * @author jomu + */ +public class NtlmAuthenticator extends AbstractAuthenticator { + + public NtlmAuthenticator(String user, String password) { + super(user, password); + } + + public NtlmAuthenticator(String domain, String user, String password) { + super(domain, user, password); + } + + @Override + public PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(getUserName(), password.toCharArray()); + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java new file mode 100644 index 0000000..249b135 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPContext.java @@ -0,0 +1,39 @@ +package de.muehlencord.shared.sharepoint.api; + +import java.net.Authenticator; +import java.net.URL; + +/** + * + * @author jomu + */ +public class SPContext { + + private URL siteURL; + private AbstractAuthenticator authenticator; + private SPVersion spVersion; + + public SPContext(URL siteURL, AbstractAuthenticator authenticator, SPVersion spVersion) { + this.siteURL = siteURL; + this.authenticator = authenticator; + this.spVersion = spVersion; + configure(); + } + + private void configure() { + Authenticator.setDefault(authenticator); + } + + public URL getSiteURL() { + return siteURL; + } + + public AbstractAuthenticator getAuthenticator() { + return authenticator; + } + + public SPVersion getSpVersion() { + return spVersion; + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java new file mode 100644 index 0000000..22c2262 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPObject.java @@ -0,0 +1,19 @@ +package de.muehlencord.shared.sharepoint.api; + +/** + * + * @author jomu + */ +public class SPObject { + + private SPContext context; + + public SPObject(SPContext context) { + this.context = context; + } + + public SPContext getContext() { + return context; + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPVersion.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPVersion.java new file mode 100644 index 0000000..a8a4555 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/SPVersion.java @@ -0,0 +1,10 @@ +package de.muehlencord.shared.sharepoint.api; + +/** + * + * @author jomu + */ +public enum SPVersion { + SP2010; + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/authentication/SPAuthentication.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/authentication/SPAuthentication.java new file mode 100644 index 0000000..71ed808 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/authentication/SPAuthentication.java @@ -0,0 +1,40 @@ +package de.muehlencord.shared.sharepoint.api.authentication; + +import com.microsoft.schemas.sharepoint.soap.authentication.Authentication; +import com.microsoft.schemas.sharepoint.soap.authentication.AuthenticationSoap; +import com.microsoft.schemas.sharepoint.soap.authentication.LoginResult; +import de.muehlencord.shared.sharepoint.api.AbstractAuthenticator; +import de.muehlencord.shared.sharepoint.api.SPContext; +import de.muehlencord.shared.sharepoint.api.SPObject; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import javax.xml.ws.BindingProvider; + +/** + * + * @author jomu + */ +public class SPAuthentication extends SPObject { + + public SPAuthentication(SPContext context) { + super(context); + } + + private void authenticate(BindingProvider prov) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { + AbstractAuthenticator authenticator = getContext().getAuthenticator(); + LoginResult result = getAuthenticationPort().login(authenticator.getUserName(), authenticator.getPassword()); + + } + + private AuthenticationSoap getAuthenticationPort() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { + URL wsURL = new URL(getContext().getSiteURL().toString() + "/_vti_bin/Authentication.asmx"); + URL wsdlURL = new URL(SPContext.class.getResource("/wsdl/authentication.wsdl").toExternalForm()); + Authentication service = new Authentication(wsdlURL); + AuthenticationSoap alertsPort = service.getAuthenticationSoap(); + ((BindingProvider) alertsPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); + return alertsPort; + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java new file mode 100644 index 0000000..b84c1a9 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/lists/SPList.java @@ -0,0 +1,32 @@ +package de.muehlencord.shared.sharepoint.api.lists; + +import com.microsoft.schemas.sharepoint.soap.lists.Lists; +import com.microsoft.schemas.sharepoint.soap.lists.ListsSoap; +import de.muehlencord.shared.sharepoint.api.SPContext; +import de.muehlencord.shared.sharepoint.api.SPObject; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import javax.xml.ws.BindingProvider; + +/** + * + * @author jomu + */ +public class SPList extends SPObject { + + public SPList(SPContext context) { + super(context); + } + + private ListsSoap getListsPort(URL webUrl) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { + URL wsURL = new URL(webUrl.toString() + "/_vti_bin/Lists.asmx"); + URL wsdlURL = new URL(SPContext.class.getResource("/wsdl/lists.wsdl").toExternalForm()); + Lists service = new Lists(wsdlURL); + ListsSoap listsPort = service.getListsSoap(); + ((BindingProvider) listsPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); + return listsPort; + } + +} diff --git a/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/sites/SPSite.java b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/sites/SPSite.java new file mode 100644 index 0000000..7d9cd94 --- /dev/null +++ b/sharepoint/api/src/main/java/de/muehlencord/shared/sharepoint/api/sites/SPSite.java @@ -0,0 +1,31 @@ +package de.muehlencord.shared.sharepoint.api.sites; + +import com.microsoft.schemas.sharepoint.soap.webs.Webs; +import com.microsoft.schemas.sharepoint.soap.webs.WebsSoap; +import de.muehlencord.shared.sharepoint.api.SPContext; +import de.muehlencord.shared.sharepoint.api.SPObject; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import javax.xml.ws.BindingProvider; + +/** + * + * @author jomu + */ +public class SPSite extends SPObject { + + public SPSite(SPContext context) { + super(context); + } + + public static WebsSoap getWebsPort(URL webUrl) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { + URL wsURL = new URL(webUrl.toString() + "/_vti_bin/Webs.asmx"); + URL wsdlURL = new URL(SPSite.class.getResource("/wsdl/webs.wsdl").toExternalForm()); + Webs service = new Webs(wsdlURL); + WebsSoap websPort = service.getWebsSoap(); + ((BindingProvider) websPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); + return websPort; + } +} diff --git a/sharepoint/api/src/main/resources/2010/wsdl/alerts.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/alerts.wsdl new file mode 100644 index 0000000..29b60b6 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/alerts.wsdl @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/resources/2010/wsdl/authentication.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/authentication.wsdl new file mode 100644 index 0000000..f8c69a5 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/authentication.wsdl @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sharepoint/api/src/main/resources/2010/wsdl/lists.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/lists.wsdl new file mode 100644 index 0000000..7eb9c75 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/lists.wsdl @@ -0,0 +1,1515 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/resources/2010/wsdl/sites.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/sites.wsdl new file mode 100644 index 0000000..28017b5 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/sites.wsdl @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/main/resources/2010/wsdl/webs.wsdl b/sharepoint/api/src/main/resources/2010/wsdl/webs.wsdl new file mode 100644 index 0000000..b2bc514 --- /dev/null +++ b/sharepoint/api/src/main/resources/2010/wsdl/webs.wsdl @@ -0,0 +1,969 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticatorTest.java b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticatorTest.java new file mode 100644 index 0000000..c2ff2c8 --- /dev/null +++ b/sharepoint/api/src/test/java/de/muehlencord/shared/sharepoint/api/NtlmAuthenticatorTest.java @@ -0,0 +1,25 @@ +package de.muehlencord.shared.sharepoint.api; + +import de.muehlencord.shared.sharepoint.api.sites.SPSite; +import java.net.MalformedURLException; +import java.net.URL; +import org.junit.Test; + +/** + * + * @author jomu + */ +public class NtlmAuthenticatorTest { + + + + @Test + public void testAuthentication() throws MalformedURLException { + // Create NTLM v2 credentials (authenticator) & setup context + NtlmAuthenticator credentials = new NtlmAuthenticator("DOMAIN", "username", "password"); + SPContext context = new SPContext(new URL ("http://localhost:8088/"), credentials, SPVersion.SP2010); + // Connect to Sharepoint + SPSite instance = new SPSite(context); + } + +} diff --git a/sharepoint/mock/pom.xml b/sharepoint/mock/pom.xml new file mode 100644 index 0000000..333a2b8 --- /dev/null +++ b/sharepoint/mock/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + de.muehlencord.shared + sharepoint + 1.0-SNAPSHOT + + de.muehlencord.shared.sharepoint + mock + jar + \ No newline at end of file diff --git a/sharepoint/pom.xml b/sharepoint/pom.xml new file mode 100644 index 0000000..60cc78b --- /dev/null +++ b/sharepoint/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + + de.muehlencord + shared + 1.0-SNAPSHOT + + de.muehlencord.shared + sharepoint + pom + + api + mock + + + UTF-8 + + \ No newline at end of file