Changeset 1399 for extensions
- Timestamp:
- Oct 10, 2011, 3:32:34 PM (12 years ago)
- Location:
- extensions/net.sf.basedb.ftp/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.ftp/trunk/.classpath
r1398 r1399 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 5 <classpathentry kind="lib" path="lib/compile/BASE2Core.jar" sourcepath="/Base2/src/core"/>6 <classpathentry kind="lib" path="lib/compile/BASE2Webclient.jar"/>7 5 <classpathentry kind="lib" path="lib/compile/slf4j-api-1.5.2.jar"/> 8 6 <classpathentry kind="lib" path="META-INF/lib/ftplet-api-1.0.5.jar"/> -
extensions/net.sf.basedb.ftp/trunk/README
r1382 r1399 46 46 == Tips and tricks == 47 47 48 * To activate a project when logging in via FTP, use a login name like 49 `username<projectname>`, where `username` is the usual login and 50 `projectname` is the name of the project to set active. This is useful 51 to access files that has been shared to a project, but note that 52 the path must be accessible all they way from the root. If no project 53 with the given name can be found, the user is logged in without an 54 active project. 55 48 56 * If you want to try out an SSL enabled FTP server, but doesn't have 49 57 a certificate, you may create one with the following command: -
extensions/net.sf.basedb.ftp/trunk/build.xml
r1398 r1399 131 131 </target> 132 132 133 <target 134 name="install" 135 depends="jar" 136 > 137 <fail unless="base.plugins" message="base.plugins is not set to the path of BASE plug-ins directory." /> 138 <copy todir="${base.plugins}"> 139 <fileset file="${jar.name}" /> 140 </copy> 141 <echo>Copied '${jar.name}' to '${base.plugins}'.</echo> 142 </target> 143 133 144 <target name="update-version"> 134 145 <echo>Setting version to: ${version}</echo> -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUser.java
r1381 r1399 36 36 import net.sf.basedb.core.DbControl; 37 37 import net.sf.basedb.core.Directory; 38 import net.sf.basedb.core.Include; 39 import net.sf.basedb.core.ItemQuery; 38 40 import net.sf.basedb.core.PermissionDeniedException; 41 import net.sf.basedb.core.Project; 39 42 import net.sf.basedb.core.SessionControl; 40 43 import net.sf.basedb.core.SystemItems; 44 import net.sf.basedb.core.Type; 41 45 import net.sf.basedb.core.User; 46 import net.sf.basedb.core.query.Expressions; 47 import net.sf.basedb.core.query.Hql; 48 import net.sf.basedb.core.query.Restrictions; 42 49 43 50 /** … … 59 66 SessionControl sc; 60 67 private User user; 68 private Project project; 61 69 private BaseFtpFile home; 62 70 … … 93 101 94 102 /** 95 Get the {@link Application#sessionCacheTimeout() value103 Get the {@link Application#sessionCacheTimeout()} value 96 104 and convert it to seconds. 97 105 */ … … 261 269 262 270 /** 271 Activate the project with the given name. 272 @param name The name of the project, or null to deactive 273 */ 274 public void setProject(String name) 275 { 276 if (!isLoggedIn()) return; 277 278 if (name == null) 279 { 280 log.info("Deactivating current project: " + project); 281 this.project = null; 282 sc.setActiveProject(null); 283 return; 284 } 285 286 log.info("Looking up project: " + name); 287 288 ItemQuery<Project> projectQuery = Project.getQuery(); 289 projectQuery.include(Include.MINE, Include.SHARED); 290 projectQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING))); 291 292 DbControl dc = null; 293 try 294 { 295 dc = sc.newDbControl(); 296 List<Project> projects = projectQuery.list(dc); 297 log.debug("Found " + projects.size() + " projects for name: " + name); 298 if (projects.size() > 0) 299 { 300 this.project = projects.get(0); 301 log.info("Activating project: " + project); 302 sc.setActiveProject(project); 303 } 304 } 305 catch (RuntimeException ex) 306 { 307 log.error("Failed to activate project: name=" + name, ex); 308 throw ex; 309 } 310 finally 311 { 312 if (dc != null) dc.close(); 313 } 314 } 315 316 317 /** 263 318 Logout and close the session. 264 319 */ -
extensions/net.sf.basedb.ftp/trunk/src/net/sf/basedb/clients/ftp/BaseUserManager.java
r1381 r1399 175 175 String login = auth.getUsername(); 176 176 String pwd = auth.getPassword(); 177 String project = null; 177 178 String ip = auth.getUserMetadata().getInetAddress().getHostAddress(); 179 180 /* 181 If login has pattern like 'username<project>' we extract the 182 login and project from it. 183 */ 184 if (login != null && login.endsWith(">")) 185 { 186 int index = login.indexOf("<"); 187 if (index > 0 && index < login.length()-1) 188 { 189 project = login.substring(index+1, login.length()-1); 190 login = login.substring(0, index); 191 } 192 } 178 193 179 194 log.info("Trying to authenticate: login=" + login); 180 195 log.debug("password=" + pwd); 196 log.debug("project=" + project); 181 197 log.debug("ip=" + ip); 182 198 … … 186 202 user.login(pwd, ip, ftpClientIsInstalled ? BaseFtpServer.CLIENT_ID : null); 187 203 log.info("Login successful: login=" + login); 204 if (project != null) user.setProject(project); 188 205 } 189 206 catch (Exception ex)
Note: See TracChangeset
for help on using the changeset viewer.