Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Jeremy Bunag
Greenhorn
+ Follow
news
1
Posts
0
Threads
since Nov 19, 2009
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by Jeremy Bunag
JAX-WS Consuming Exchange Web Services with java using glassfish, error authentication: Unauthorized
I'm working on EWS too (just starting), and I found this elsewhere. The authenticator requires basic authentication:
from
Yale Exchange and Java article
public class YaleExchangeServerPortFactory extends ExchangeServerPortFactory { String uri; String adDomain; String uid; String pwd; ExchangeServices service; Authenticator basicAuth; static{ javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(new AllTrustingSocketFactory()); } /** * Set up Authentication * */ protected void setupAuthenticator(){ if(basicAuth == null){ basicAuth = new Authenticator(){ protected PasswordAuthentication getPasswordAuthentication(){ String superUid = YaleExchangeServerPortFactory.this.adDomain + "\\" + YaleExchangeServerPortFactory.this.uid; String superPwd = YaleExchangeServerPortFactory.this.pwd; return new PasswordAuthentication(superUid ,superPwd.toCharArray()); } }; Authenticator.setDefault(basicAuth); } } public ExchangeServicePortType getExchangeServerPort() { ExchangeServicePortType port = null; try{ port = getExchangeServices().getExchangeServicePort(); } catch (Exception e){ throw new RuntimeException(e); } return port; } protected ExchangeServices getExchangeServices() throws Exception{ setupAuthenticator(); if(service == null) service = new ExchangeServices(new URL(uri)); return service; } public String getAdDomain() { return adDomain; } public void setAdDomain(String adDomain) { this.adDomain = adDomain; } public String getUri() { return uri; } public void setUri(String uri) { this.uri = uri; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } public String getUid() { return uid; } public void setUid(String uid) { this.uid = uid; } }
Hope this helps!
-Jeremy
show more
15 years ago
Web Services