From c0546d8e9f9947ca304a74c6122240eac25f4b3e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 7 Aug 2008 17:30:54 +0000 Subject: Update: Completed SVN plugin Closes #12 --- .../com/fourisland/instadisc/update/svn/MD5.java | 68 ++++++++++++++++++ .../com/fourisland/instadisc/update/svn/Main.java | 83 ++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java (limited to 'update/plugin/svn/trunk/src/com/fourisland') diff --git a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java new file mode 100644 index 0000000..0929022 --- /dev/null +++ b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java @@ -0,0 +1,68 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.fourisland.instadisc.update.svn; + +import java.security.MessageDigest; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author hatkirby + */ +public class MD5 { + + String ver; + + public MD5(String ver) { + this.ver = ver; + } + + public MD5(char[] password) { + int i=0; + ver=""; + for (i=0;i y ? x : y); + } + + private String pad(String in, String pad, int len) + { + while (in.length() < len) + { + in = pad + in; + } + return in; + } +} diff --git a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java index e69de29..1bc9a07 100644 --- a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java +++ b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java @@ -0,0 +1,83 @@ +package com.fourisland.instadisc.update.svn; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; + +public class Main { + + public static void main(String[] args) { + try + { + String username = getArg(0, args); + String password = getArg(1, args); + String centralServer = getArg(2, args); + String pathScheme = getArg(3, args); + String author = getArg(4, args); + String subscription = getArg(5, args); + String revision = getArg(6, args); + + StringBuilder messBuilder = new StringBuilder(); + byte rs = 0; + + while (rs != -1) + { + try + { + rs = (byte) System.in.read(); + if (rs != -1) + { + messBuilder.append(new String(new byte[]{rs})); + } + } catch (IOException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + } + + String message = messBuilder.toString(); + message = message.substring(0, message.indexOf("\n")); + + Random r = new Random(); + int verID = r.nextInt(Integer.MAX_VALUE); + + String path = pathScheme.replace("__REV__", revision); + + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setServerURL(new URL(centralServer)); + XmlRpcClient client = new XmlRpcClient(); + client.setConfig(config); + client.execute("InstaDisc.sendFromUpdate", new Object[]{username, + (new MD5(username + ":" + (new MD5(password)).hash() + ":" + verID)).hash(), + verID, + subscription, + message, + author, + path, + "a:0:{}" + }); + } catch (XmlRpcException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } catch (MalformedURLException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public static String getArg(int arg, String[] args) { + if (args.length < (arg+1)) + { + System.out.println("Program requires 7 arguments and you only provided " + arg); + System.exit(1); + } + + return args[arg]; + } +} -- cgit 1.4.1