List of usage examples for org.apache.commons.httpclient HttpURL setUserinfo
public void setUserinfo(String paramString1, String paramString2) throws URIException, NullPointerException
From source file:org.pengyou.client.lib.DavContext.java
public HttpURL getHttpURL() throws URIException { HttpURL url = new HttpURL(this.host + ":" + this.port); url.setUserinfo(this.username, this.getPassword()); return url;//ww w . j a v a 2 s.c o m }
From source file:org.pengyou.ooo.utils.WebDavStore.java
private static HttpURL uriToHttpURL(String uri, String login, String password) throws URIException { HttpURL httpURL = uri.startsWith("https") ? new HttpsURL(uri) : new HttpURL(uri); if (login != null && login.length() > 0) httpURL.setUserinfo(login, password); return httpURL; }
From source file:org.socialbiz.cog.dms.WebDavAccess.java
private WebdavResource getWebdavResource(String path, String uid, String pwd) throws Exception { try {//from ww w . j a v a2 s . c o m //This is the goofy step, the HttpURL class requires something that looks like //a file path, NOT a URL, and so must be "decoded". But normal URLDecoding does //not work because it converts plus symbols to spaces, so need to "encode" the //plus signs first, so that the decode preserves them correctly. //we need to move OFF this library sometime soon int plusPos = path.indexOf("+"); while (plusPos >= 0) { path = path.substring(0, plusPos) + "%2B" + path.substring(plusPos + 1); plusPos = path.indexOf("+"); } String goofyPath = URLDecoder.decode(path, "UTF-8"); HttpURL url = new HttpURL(goofyPath); //A backslash in the user id indicates the use of NT domain auth int slashPos = uid.indexOf('\\'); if (slashPos > 0) { //This is the NT domain case String hostName = url.getHost(); String ntdomain = uid.substring(0, slashPos); String ntuid = uid.substring(slashPos + 1); NTCredentials cred = new NTCredentials(ntuid, pwd, hostName, ntdomain); return new WebdavResource(goofyPath, cred); } else { if (uid != null && uid.length() > 0 && pwd != null) { //This is the non-NT case, use basic auth if uid is provided url.setUserinfo(uid, pwd); } return new WebdavResource(url); } } catch (Exception e) { throw new NGException("nugen.exception.unable.to.access.webdav.resource", new Object[] { path, uid }, e); } }
From source file:sos.scheduler.editor.app.WebDavDialogListener.java
private WebdavResource connect(String url) { WebdavResource wdr = null;/*from w w w .j av a2 s . c o m*/ String user = null; String password = null; String host = null; String port = null; try { //selfsigned; wenn selbssignierte Certifikate bercksichtigt werden sollen //es gilt jetzt nur die offizielle //System.getProperties().put("javax.net.ssl.trustStore","C:/scheduler/webdav_keystore/.keystore"); //System.getProperties().put("javax.net.ssl.trustStorePassword","changeit"); user = sosString.parseToString(currProfile.get("user")); password = sosString.parseToString(currProfile.get("password")); String proxyHost = sosString.parseToString(currProfile.get("proxy_server")); int proxyPort = 21; if (sosString.parseToString(currProfile.get("proxy_port")).length() > 0) proxyPort = Integer.parseInt(sosString.parseToString(currProfile.get("proxy_port"))); String key = Options.getProperty("profile.timestamp." + currProfileName); if (key != null && key.length() > 8) { key = key.substring(key.length() - 8); } if (password.length() > 0 && sosString.parseToString(key).length() > 0) { password = SOSCrypt.decrypt(key, password); } if (password.length() == 0) { Shell shell = new Shell(); shell.pack(); Dialog dialog = new Dialog(shell); dialog.setText("Password"); dialog.open(this); while (!shell.isDisposed()) { if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep(); } //shell.getDisplay().dispose(); //shell.dispose(); password = getPassword(); } HttpURL hrl = new HttpURL(url); hrl.setUserinfo(user, password); if (proxyHost.length() > 0) wdr = new WebdavResource(hrl, proxyHost, proxyPort); else wdr = new WebdavResource(hrl); wdr.setDebug(9); if (logtext != null) logtext.append("..webdav server reply [connect] [status= " + wdr.getStatusMessage()); Options.setProperty("last_webdav_profile", currProfileName); Options.saveProperties(); } catch (Exception ex) { hasError = true; try { new ErrorLog( "error in " + sos.util.SOSClassUtil.getMethodName() + " ; error in webdav server init with [host=" + host + "], [port=" + port + "].", ex); } catch (Exception ee) { //tu nichts } if (logtext != null) logtext.append("..error in webdav server init with [host=" + host + "], [port=" + port + "], cause: " + getErrorMessage(ex) + "\n"); } return wdr; }