예제 #1
0
 public static void main(String[] args) throws IOException {
   String host, username, password, base;
   if (args.length < 4) {
     println("Usage: LdapMain host:port username password base");
     return;
   } else {
     host = args[0];
     username = args[1];
     password = args[2];
     base = args[3];
   }
   LdapMain a = new LdapMain();
   println("Connecting to ldap://" + host);
   println("Using base:" + base);
   SimpleLdapUserStore store = a.getStore("ldap://" + host, username, password, base);
   println("Enter query user[/password]: ");
   BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
   String value = stdin.readLine();
   while (Strings.isNotBlank(value)) {
     String myname = value;
     String mypass = null;
     if (value.contains("/")) {
       myname = Strings.substringBefore(value, "/");
       mypass = Strings.substringAfter(value, "/");
     }
     try {
       a.tryGet(store, myname);
       if (null != mypass) {
         a.tryTestPassword(store, myname, mypass);
       }
     } catch (Exception e) {
       e.printStackTrace();
     } finally {
       println("Enter query user[/password]: ");
     }
     value = stdin.readLine();
   }
 }
예제 #2
0
 private int updateFile(File path) {
   int count = 0;
   if (path.isDirectory()) {
     String[] fileNames = path.list();
     for (String fileName : fileNames) {
       File file = new File(path.getAbsolutePath() + "/" + fileName);
       if (file.isDirectory()) {
         count += updateFile(file);
         file.delete();
       } else {
         String type = Strings.substringAfter(fileName, ".");
         boolean passed = containType(type);
         if (passed) {
           logger.debug("updating avatar by {}", file.getName());
           updateAvatar(Strings.substringBefore(fileName, "."), file, type);
           count++;
         }
         file.delete();
       }
     }
   }
   return count;
 }