about summary refs log tree commit diff stats
path: root/update/plugin/svn/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'update/plugin/svn/trunk')
-rw-r--r--update/plugin/svn/trunk/manifest.mf2
-rw-r--r--update/plugin/svn/trunk/nbproject/project.dtd54
-rw-r--r--update/plugin/svn/trunk/nbproject/project.properties13
-rw-r--r--update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java68
-rw-r--r--update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java83
5 files changed, 219 insertions, 1 deletions
diff --git a/update/plugin/svn/trunk/manifest.mf b/update/plugin/svn/trunk/manifest.mf new file mode 100644 index 0000000..0f8d5d3 --- /dev/null +++ b/update/plugin/svn/trunk/manifest.mf
@@ -0,0 +1,2 @@
1Manifest-Version: 1.0
2X-COMMENT: Main-Class will be added automatically by build \ No newline at end of file
diff --git a/update/plugin/svn/trunk/nbproject/project.dtd b/update/plugin/svn/trunk/nbproject/project.dtd new file mode 100644 index 0000000..7b77177 --- /dev/null +++ b/update/plugin/svn/trunk/nbproject/project.dtd
@@ -0,0 +1,54 @@
1<?xml version='1.0' encoding='UTF-8'?>
2
3<!--
4 TODO define vocabulary identification
5 PUBLIC ID: -//vendor//vocabulary//EN
6 SYSTEM ID: http://server/path/project.dtd
7
8--><!--
9 An example how to use this DTD from your XML document:
10
11 <?xml version="1.0"?>
12
13 <!DOCTYPE project SYSTEM "project.dtd">
14
15 <project>
16 ...
17 </project>
18-->
19
20<!--- Put your DTDDoc comment here. -->
21<!ELEMENT project (configuration|type)*>
22<!ATTLIST project
23 xmlns CDATA #IMPLIED
24 >
25
26<!--- Put your DTDDoc comment here. -->
27<!ELEMENT type (#PCDATA)>
28
29<!--- Put your DTDDoc comment here. -->
30<!ELEMENT configuration (data)*>
31
32<!--- Put your DTDDoc comment here. -->
33<!ELEMENT data (test-roots|source-roots|minimum-ant-version|name)*>
34<!ATTLIST data
35 xmlns CDATA #IMPLIED
36 >
37
38<!--- Put your DTDDoc comment here. -->
39<!ELEMENT name (#PCDATA)>
40
41<!--- Put your DTDDoc comment here. -->
42<!ELEMENT minimum-ant-version (#PCDATA)>
43
44<!--- Put your DTDDoc comment here. -->
45<!ELEMENT source-roots (root)*>
46
47<!--- Put your DTDDoc comment here. -->
48<!ELEMENT root EMPTY>
49<!ATTLIST root
50 id CDATA #IMPLIED
51 >
52
53<!--- Put your DTDDoc comment here. -->
54<!ELEMENT test-roots (root)*>
diff --git a/update/plugin/svn/trunk/nbproject/project.properties b/update/plugin/svn/trunk/nbproject/project.properties index 77bb3db..97cccc2 100644 --- a/update/plugin/svn/trunk/nbproject/project.properties +++ b/update/plugin/svn/trunk/nbproject/project.properties
@@ -1,3 +1,5 @@
1application.title=InstaDiscUpdateSVN
2application.vendor=hatkirby
1build.classes.dir=${build.dir}/classes 3build.classes.dir=${build.dir}/classes
2build.classes.excludes=**/*.java,**/*.form 4build.classes.excludes=**/*.java,**/*.form
3# This directory is removed when the project is cleaned: 5# This directory is removed when the project is cleaned:
@@ -18,7 +20,8 @@ dist.javadoc.dir=${dist.dir}/javadoc
18excludes= 20excludes=
19includes=** 21includes=**
20jar.compress=false 22jar.compress=false
21javac.classpath= 23javac.classpath=\
24 ${libs.XML-RPC2.classpath}
22# Space-separated list of extra javac options 25# Space-separated list of extra javac options
23javac.compilerargs= 26javac.compilerargs=
24javac.deprecation=false 27javac.deprecation=false
@@ -40,6 +43,14 @@ javadoc.splitindex=true
40javadoc.use=true 43javadoc.use=true
41javadoc.version=false 44javadoc.version=false
42javadoc.windowtitle= 45javadoc.windowtitle=
46jnlp.codebase.type=local
47jnlp.codebase.url=file:/home/hatkirby/NetBeansProjects/InstaDiscUpdateSVN/dist/
48jnlp.enabled=false
49jnlp.offline-allowed=false
50jnlp.signed=false
51# Property libs.XML-RPC2.classpath is set here just to make sharing of project simpler.
52# The library definition has always preference over this property.
53libs.XML-RPC2.classpath=lib/commons-logging-1.1.jar:lib/ws-commons-util-1.0.2.jar:lib/xmlrpc-client-3.1.jar:lib/xmlrpc-common-3.1.jar:lib/xmlrpc-server-3.1.jar
43main.class=com.fourisland.instadisc.update.svn.Main 54main.class=com.fourisland.instadisc.update.svn.Main
44manifest.file=manifest.mf 55manifest.file=manifest.mf
45meta.inf.dir=${src.dir}/META-INF 56meta.inf.dir=${src.dir}/META-INF
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 @@
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package com.fourisland.instadisc.update.svn;
6
7import java.security.MessageDigest;
8import java.util.logging.Level;
9import java.util.logging.Logger;
10
11/**
12 *
13 * @author hatkirby
14 */
15public class MD5 {
16
17 String ver;
18
19 public MD5(String ver) {
20 this.ver = ver;
21 }
22
23 public MD5(char[] password) {
24 int i=0;
25 ver="";
26 for (i=0;i<password.length;i++)
27 {
28 ver += password[i];
29 password[i] = 0;
30 }
31 }
32
33 public String hash()
34 {
35 StringBuilder verify = new StringBuilder();
36 try {
37 MessageDigest md5 = MessageDigest.getInstance("MD5");
38 int i = 0;
39 byte[] create = new byte[ver.length()];
40 for (i = 0; i < ver.length(); i++) {
41 create[i] = (byte) ver.charAt(i);
42 }
43 byte buffer[] = md5.digest(create);
44 for (i = 0; i < buffer.length; i++) {
45 String hex = Integer.toHexString(buffer[i]);
46 verify.append(pad(hex.substring(max(hex.length() - 2, 0)),"0",2));
47 }
48 } catch (Exception ex) {
49 Logger.getLogger(MD5.class.getName()).log(Level.SEVERE, null, ex);
50 }
51 ver = "";
52 return verify.toString();
53 }
54
55 private int max(int x, int y)
56 {
57 return (x > y ? x : y);
58 }
59
60 private String pad(String in, String pad, int len)
61 {
62 while (in.length() < len)
63 {
64 in = pad + in;
65 }
66 return in;
67 }
68}
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 @@
1package com.fourisland.instadisc.update.svn;
2
3import java.io.IOException;
4import java.net.MalformedURLException;
5import java.net.URL;
6import java.util.Random;
7import java.util.logging.Level;
8import java.util.logging.Logger;
9import org.apache.xmlrpc.XmlRpcException;
10import org.apache.xmlrpc.client.XmlRpcClient;
11import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
12
13public class Main {
14
15 public static void main(String[] args) {
16 try
17 {
18 String username = getArg(0, args);
19 String password = getArg(1, args);
20 String centralServer = getArg(2, args);
21 String pathScheme = getArg(3, args);
22 String author = getArg(4, args);
23 String subscription = getArg(5, args);
24 String revision = getArg(6, args);
25
26 StringBuilder messBuilder = new StringBuilder();
27 byte rs = 0;
28
29 while (rs != -1)
30 {
31 try
32 {
33 rs = (byte) System.in.read();
34 if (rs != -1)
35 {
36 messBuilder.append(new String(new byte[]{rs}));
37 }
38 } catch (IOException ex)
39 {
40 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
41 }
42 }
43
44 String message = messBuilder.toString();
45 message = message.substring(0, message.indexOf("\n"));
46
47 Random r = new Random();
48 int verID = r.nextInt(Integer.MAX_VALUE);
49
50 String path = pathScheme.replace("__REV__", revision);
51
52 XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
53 config.setServerURL(new URL(centralServer));
54 XmlRpcClient client = new XmlRpcClient();
55 client.setConfig(config);
56 client.execute("InstaDisc.sendFromUpdate", new Object[]{username,
57 (new MD5(username + ":" + (new MD5(password)).hash() + ":" + verID)).hash(),
58 verID,
59 subscription,
60 message,
61 author,
62 path,
63 "a:0:{}"
64 });
65 } catch (XmlRpcException ex)
66 {
67 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
68 } catch (MalformedURLException ex)
69 {
70 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
71 }
72 }
73
74 public static String getArg(int arg, String[] args) {
75 if (args.length < (arg+1))
76 {
77 System.out.println("Program requires 7 arguments and you only provided " + arg);
78 System.exit(1);
79 }
80
81 return args[arg];
82 }
83}