summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.xml90
-rw-r--r--docs/00_index.mkd7
-rw-r--r--docs/04_releases.mkd12
-rw-r--r--src/com/gitblit/AuthenticationFilter.java2
-rw-r--r--src/com/gitblit/GitBlit.java11
-rw-r--r--src/com/gitblit/models/ServerSettings.java12
-rw-r--r--src/com/gitblit/utils/Base64.java311
-rw-r--r--src/com/gitblit/utils/ConnectionUtils.java1
-rw-r--r--src/com/gitblit/utils/RpcUtils.java4
9 files changed, 402 insertions, 48 deletions
diff --git a/build.xml b/build.xml
index 5c3494bd..854b5f1e 100644
--- a/build.xml
+++ b/build.xml
@@ -85,7 +85,8 @@
<property name="distribution.zipfile" value="gitblit-${gb.version}.zip" />
<property name="distribution.warfile" value="gitblit-${gb.version}.war" />
<property name="fedclient.zipfile" value="fedclient-${gb.version}.zip" />
- <property name="manager.zipfile" value="manager-${gb.version}.zip" />
+ <property name="manager.jarfile" value="manager-${gb.version}.jar" />
+ <property name="gbapi.zipfile" value="gbapi-${gb.version}.zip" />
</target>
@@ -273,7 +274,10 @@
<arg value="%FEDCLIENT%=${fedclient.zipfile}" />
<arg value="--substitute" />
- <arg value="%MANAGER%=${manager.zipfile}" />
+ <arg value="%MANAGER%=${manager.jarfile}" />
+
+ <arg value="--substitute" />
+ <arg value="%API%=${gbapi.zipfile}" />
<arg value="--substitute" />
<arg value="%BUILDDATE%=${gb.versionDate}" />
@@ -378,7 +382,7 @@
<exclude name="com/gitblit/client/**" />
<exclude name="com/gitblit/GitBlitServer*.class" />
<exclude name="com/gitblit/Launcher*.class" />
- <exclude name="com/gitblit/MakeCertificate*.class" />
+ <exclude name="com/gitblit/MakeCertificate*.class" />
</fileset>
</copy>
@@ -409,7 +413,7 @@
<classpath refid="master-classpath" />
<manifest>
<attribute name="Main-Class" value="com.gitblit.FederationClientLauncher" />
- <attribute name="Specification-Version" value="${gb.version}" />
+ <attribute name="Specification-Version" value="${gb.version}" />
<attribute name="Release-Date" value="${gb.versionDate}" />
</manifest>
</genjar>
@@ -417,10 +421,10 @@
<!-- Build the federation client zip file -->
<zip destfile="${fedclient.zipfile}">
<fileset dir="${basedir}">
- <include name="fedclient.jar" />
+ <include name="fedclient.jar" />
</fileset>
<fileset dir="${basedir}/distrib">
- <include name="federation.properties" />
+ <include name="federation.properties" />
</fileset>
</zip>
</target>
@@ -434,7 +438,7 @@
<target name="buildManager" depends="compile" description="Builds the stand-alone Gitblit Manager">
<echo>Building Gitblit Manager ${gb.version}</echo>
- <genjar jarfile="manager.jar">
+ <genjar jarfile="${manager.jarfile}">
<resource file="${basedir}/src/com/gitblit/client/splash.png" />
<resource file="${basedir}/resources/gitblt-favicon.png" />
<resource file="${basedir}/resources/gitweb-favicon.png" />
@@ -466,18 +470,45 @@
<manifest>
<attribute name="Main-Class" value="com.gitblit.client.GitblitManagerLauncher" />
<attribute name="SplashScreen-Image" value="splash.png" />
- <attribute name="Specification-Version" value="${gb.version}" />
+ <attribute name="Specification-Version" value="${gb.version}" />
<attribute name="Release-Date" value="${gb.versionDate}" />
</manifest>
</genjar>
- <!-- Build the Manager zip file -->
- <zip destfile="${manager.zipfile}">
- <fileset dir="${basedir}">
- <include name="manager.jar" />
- </fileset>
- </zip>
</target>
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Build the Gitblit API client library
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <target name="buildApiLibrary" depends="compile" description="Builds the Gitblit RPC client library">
+ <echo>Building Gitblit API Library ${gb.version}</echo>
+
+ <genjar jarfile="gbapi.jar">
+ <class name="com.gitblit.client.GitblitClient" />
+ <classpath refid="master-classpath" />
+ <classfilter>
+ <exclude name="com.google.gson." />
+ </classfilter>
+ <manifest>
+ <attribute name="Specification-Version" value="${gb.version}" />
+ <attribute name="Release-Date" value="${gb.versionDate}" />
+ </manifest>
+ </genjar>
+
+ <!-- Build the API library zip file -->
+ <zip destfile="${gbapi.zipfile}">
+ <fileset dir="${basedir}">
+ <include name="gbapi.jar" />
+ </fileset>
+ <fileset dir="${basedir}/ext">
+ <include name="gson*.jar" />
+ <exclude name="gson*-sources.jar" />
+ <exclude name="gson*-javadoc.jar" />
+ </fileset>
+ </zip>
+ </target>
<!--
@@ -596,7 +627,10 @@
<arg value="%FEDCLIENT%=${fedclient.zipfile}" />
<arg value="--substitute" />
- <arg value="%MANAGER%=${manager.zipfile}" />
+ <arg value="%MANAGER%=${manager.jarfile}" />
+
+ <arg value="--substitute" />
+ <arg value="%API%=${gbapi.zipfile}" />
<arg value="--substitute" />
<arg value="%BUILDDATE%=${gb.versionDate}" />
@@ -628,7 +662,7 @@
Compile from source, publish binaries, and build & deploy site
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
- <target name="buildAll" depends="buildGO,buildWAR,buildFederationClient,buildManager,buildSite">
+ <target name="buildAll" depends="buildGO,buildWAR,buildFederationClient,buildManager,buildApiLibrary,buildSite">
<!-- Cleanup -->
<delete dir="${project.build.dir}" />
<delete dir="${project.war.dir}" />
@@ -645,7 +679,7 @@
<echo>Uploading Gitblit ${gb.version} binaries</echo>
- <!-- Upload ZIP file -->
+ <!-- Upload Gitblit GO ZIP file -->
<gcupload
username="${googlecode.user}"
password="${googlecode.password}"
@@ -655,7 +689,7 @@
summary="Gitblit GO v${gb.version} (standalone, integrated Gitblit server)"
labels="Featured, Type-Package, OpSys-All" />
- <!-- Upload WAR file -->
+ <!-- Upload Gitblit WAR file -->
<gcupload
username="${googlecode.user}"
password="${googlecode.password}"
@@ -665,7 +699,7 @@
summary="Gitblit WAR v${gb.version} (standard WAR webapp for servlet containers)"
labels="Featured, Type-Package, OpSys-All" />
- <!-- Upload FedClient -->
+ <!-- Upload Gitblit FedClient -->
<gcupload
username="${googlecode.user}"
password="${googlecode.password}"
@@ -675,15 +709,25 @@
summary="Gitblit Federation Client v${gb.version} (command-line tool to clone data from federated Gitblit instances)"
labels="Featured, Type-Package, OpSys-All" />
- <!-- Upload Manager -->
+ <!-- Upload Gitblit Manager -->
<gcupload
username="${googlecode.user}"
password="${googlecode.password}"
projectname="gitblit"
- filename="${manager.zipfile}"
- targetfilename="manager-${gb.version}.zip"
+ filename="${manager.jarfile}"
+ targetfilename="manager-${gb.version}.jar"
summary="Gitblit Manager v${gb.version} (Swing tool to remotely administer a Gitblit server)"
labels="Featured, Type-Package, OpSys-All" />
+
+ <!-- Upload Gitblit API Library -->
+ <gcupload
+ username="${googlecode.user}"
+ password="${googlecode.password}"
+ projectname="gitblit"
+ filename="${gbapi.zipfile}"
+ targetfilename="gbapi-${gb.version}.zip"
+ summary="Gitblit API Library v${gb.version} (JSON RPC library to integrate with your software)"
+ labels="Featured, Type-Package, OpSys-All" />
</target>
@@ -713,7 +757,7 @@
Compile from source, publish binaries, and build & deploy site
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
- <target name="publishAll" depends="publishBinaries,publishSite">
+ <target name="publishAll" depends="publishBinaries,publishSite">
<!-- Cleanup -->
<delete dir="${project.build.dir}" />
<delete dir="${project.war.dir}" />
diff --git a/docs/00_index.mkd b/docs/00_index.mkd
index 1080f095..8e04b97f 100644
--- a/docs/00_index.mkd
+++ b/docs/00_index.mkd
@@ -18,7 +18,8 @@ Gitblit is available in two variations:
### Tools
-- *Gitblit Manager* - a Java/Swing application for remote administration of a Gitblit server
+- *Gitblit API* - a JSON RPC client library for integrating Gitblit into your systems
+- *Gitblit Manager* - a Java/Swing application for remote administration of a Gitblit server which uses the Gitblit API library
- *Gitblit Federation Client* - a command line tool to clone/pull groups of repositories and optionally users and settings
### Java Runtime Requirement
@@ -27,7 +28,7 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit
### Current Release
-**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%)|[war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%)|[fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%)|[manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*
+**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*
- **security**: fixed security hole when cloning clone-restricted repository with TortoiseGit (issue 28)
- improved: updated ui with Twitter's Bootstrap CSS toolkit
@@ -38,7 +39,7 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit
**New:** *web.enableRpcServlet = true*
**New:** *web.enableRpcManagement = false*
**New:** *web.enableRpcAdministration = false*
-- added: reusable JSON RPC client class
+- added: Gitblit API JSON RPC library
- added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server.
- added: per-repository setting to skip size calculation (faster repositories page loading)
- added: per-repository setting to skip summary metrics calculation (faster summary page loading)
diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd
index 778fd0e8..6868b192 100644
--- a/docs/04_releases.mkd
+++ b/docs/04_releases.mkd
@@ -1,7 +1,7 @@
## Release History
### Current Release
-**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%)|[war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%)|[fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%)|[manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*
+**%VERSION%** ([go](http://code.google.com/p/gitblit/downloads/detail?name=%GO%) | [war](http://code.google.com/p/gitblit/downloads/detail?name=%WAR%) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=%FEDCLIENT%) | [manager](http://code.google.com/p/gitblit/downloads/detail?name=%MANAGER%) | [api](http://code.google.com/p/gitblit/downloads/detail?name=%API%)) based on [%JGIT%][jgit] &nbsp; *released %BUILDDATE%*
- **security**: fixed security hole when cloning clone-restricted repository with TortoiseGit (issue 28)
- improved: updated ui with Twitter's Bootstrap CSS toolkit
@@ -12,7 +12,7 @@
**New:** *web.enableRpcServlet = true*
**New:** *web.enableRpcManagement = false*
**New:** *web.enableRpcAdministration = false*
-- added: reusable JSON RPC client class
+- added: Gitblit API JSON RPC library
- added: Gitblit Manager (Java/Swing Application) for remote administration of a Gitblit server.
- added: per-repository setting to skip size calculation (faster repositories page loading)
- added: per-repository setting to skip summary metrics calculation (faster summary page loading)
@@ -33,7 +33,7 @@
### Older Releases
-**0.6.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.zip)|[war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.war)|[fedclient](http://code.google.com/p/gitblit/downloads/detail?name=fedclient-0.6.0.zip)) based on [JGit 1.1.0 (201109151100-r)][jgit] &nbsp; *released 2011-09-27*
+**0.6.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.6.0.war) | [fedclient](http://code.google.com/p/gitblit/downloads/detail?name=fedclient-0.6.0.zip)) based on [JGit 1.1.0 (201109151100-r)][jgit] &nbsp; *released 2011-09-27*
- added: federation feature to allow gitblit instances (or gitblit federation clients) to pull repositories and, optionally, settings and accounts from other gitblit instances. This is something like [svn-sync](http://svnbook.red-bean.com/en/1.5/svn.ref.svnsync.html) for gitblit.
**New:** *federation.name =*
@@ -52,7 +52,7 @@
- fixed: syndication urls for WAR deployments
- fixed: authentication for zip downloads
-**0.5.2** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.2.zip)|[war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.2.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-07-27*
+**0.5.2** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.2.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.2.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-07-27*
- fixed: active repositories with a HEAD that pointed to an empty branch caused internal errors (issue 14)
- fixed: bare-cloned repositories were listed as (empty) and were not clickable (issue 13)
@@ -68,13 +68,13 @@
- updated: MarkdownPapers 1.1.0
- updated: Jetty 7.4.3
-**0.5.1** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.1.zip)|[war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.1.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-06-28*
+**0.5.1** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.1.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.1.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-06-28*
- clarified SSL certificate generation and configuration for both server-side and client-side
- added some more troubleshooting information to documentation
- replaced JavaService with Apache Commons Daemon
-**0.5.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.0.zip)|[war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.0.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-06-26*
+**0.5.0** ([go](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.0.zip) | [war](http://code.google.com/p/gitblit/downloads/detail?name=gitblit-0.5.0.war)) based on [JGit 1.0.0 (201106090707-r)][jgit] &nbsp; *released 2011-06-26*
- initial release
diff --git a/src/com/gitblit/AuthenticationFilter.java b/src/com/gitblit/AuthenticationFilter.java
index 6b7a0af2..277b220b 100644
--- a/src/com/gitblit/AuthenticationFilter.java
+++ b/src/com/gitblit/AuthenticationFilter.java
@@ -33,11 +33,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import org.eclipse.jgit.util.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.Base64;
import com.gitblit.utils.StringUtils;
/**
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index 19edf204..834375b7 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -1307,7 +1307,12 @@ public class GitBlit implements ServletContextListener {
*/
public ServerSettings getSettingsModel() {
// ensure that the current values are updated in the setting models
- settingsModel.updateCurrentValues(settings);
+ for (String key : settings.getAllKeys(null)) {
+ SettingModel setting = settingsModel.get(key);
+ if (setting != null) {
+ setting.currentValue = settings.getString(key, "");
+ }
+ }
return settingsModel;
}
@@ -1433,13 +1438,13 @@ public class GitBlit implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
servletContext = contextEvent.getServletContext();
- settingsModel = loadSettingModels();
+ settingsModel = loadSettingModels();
if (settings == null) {
// Gitblit WAR is running in a servlet container
WebXmlSettings webxmlSettings = new WebXmlSettings(contextEvent.getServletContext());
configureContext(webxmlSettings, true);
}
-
+
serverStatus.servletContainer = servletContext.getServerInfo();
}
diff --git a/src/com/gitblit/models/ServerSettings.java b/src/com/gitblit/models/ServerSettings.java
index 47148d32..3aae2e3b 100644
--- a/src/com/gitblit/models/ServerSettings.java
+++ b/src/com/gitblit/models/ServerSettings.java
@@ -21,8 +21,6 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import com.gitblit.IStoredSettings;
-
/**
* Server settings represents the settings of the Gitblit server including all
* setting metadata such as name, current value, default value, description, and
@@ -40,7 +38,7 @@ public class ServerSettings implements Serializable {
public ServerSettings() {
settings = new TreeMap<String, SettingModel>();
}
-
+
public List<String> getKeys() {
return new ArrayList<String>(settings.keySet());
}
@@ -52,12 +50,4 @@ public class ServerSettings implements Serializable {
public SettingModel get(String key) {
return settings.get(key);
}
-
- public void updateCurrentValues(IStoredSettings storedSettings) {
- for (String key : storedSettings.getAllKeys(null)) {
- if (settings.containsKey(key)) {
- settings.get(key).currentValue = storedSettings.getString(key, "");
- }
- }
- }
}
diff --git a/src/com/gitblit/utils/Base64.java b/src/com/gitblit/utils/Base64.java
new file mode 100644
index 00000000..6fd2daf1
--- /dev/null
+++ b/src/com/gitblit/utils/Base64.java
@@ -0,0 +1,311 @@
+//
+// NOTE: The following source code is heavily derived from the
+// iHarder.net public domain Base64 library. See the original at
+// http://iharder.sourceforge.net/current/java/base64/
+//
+
+package com.gitblit.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+/**
+ * Encodes and decodes to and from Base64 notation.
+ * <p>
+ * I am placing this code in the Public Domain. Do with it as you will. This
+ * software comes with no guarantees or warranties but with plenty of
+ * well-wishing instead! Please visit <a
+ * href="http://iharder.net/base64">http://iharder.net/base64</a> periodically
+ * to check for updates or to contribute improvements.
+ * </p>
+ *
+ * @author Robert Harder
+ * @author rob@iharder.net
+ * @version 2.1, stripped to minimum feature set used by JGit.
+ */
+public class Base64 {
+ /** The equals sign (=) as a byte. */
+ private final static byte EQUALS_SIGN = (byte) '=';
+
+ /** Indicates equals sign in encoding. */
+ private final static byte EQUALS_SIGN_DEC = -1;
+
+ /** Indicates white space in encoding. */
+ private final static byte WHITE_SPACE_DEC = -2;
+
+ /** Indicates an invalid byte during decoding. */
+ private final static byte INVALID_DEC = -3;
+
+ /** Preferred encoding. */
+ private final static String UTF_8 = "UTF-8";
+
+ /** The 64 valid Base64 values. */
+ private final static byte[] ENC;
+
+ /**
+ * Translates a Base64 value to either its 6-bit reconstruction value or a
+ * negative number indicating some other meaning. The table is only 7 bits
+ * wide, as the 8th bit is discarded during decoding.
+ */
+ private final static byte[] DEC;
+
+ static {
+ try {
+ ENC = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" //
+ + "abcdefghijklmnopqrstuvwxyz" //
+ + "0123456789" //
+ + "+/" //
+ ).getBytes(UTF_8);
+ } catch (UnsupportedEncodingException uee) {
+ throw new RuntimeException(uee.getMessage(), uee);
+ }
+
+ DEC = new byte[128];
+ Arrays.fill(DEC, INVALID_DEC);
+
+ for (int i = 0; i < 64; i++)
+ DEC[ENC[i]] = (byte) i;
+ DEC[EQUALS_SIGN] = EQUALS_SIGN_DEC;
+
+ DEC['\t'] = WHITE_SPACE_DEC;
+ DEC['\n'] = WHITE_SPACE_DEC;
+ DEC['\r'] = WHITE_SPACE_DEC;
+ DEC[' '] = WHITE_SPACE_DEC;
+ }
+
+ /** Defeats instantiation. */
+ private Base64() {
+ // Suppress empty block warning.
+ }
+
+ /**
+ * Encodes up to three bytes of the array <var>source</var> and writes the
+ * resulting four Base64 bytes to <var>destination</var>. The source and
+ * destination arrays can be manipulated anywhere along their length by
+ * specifying <var>srcOffset</var> and <var>destOffset</var>. This method
+ * does not check to make sure your arrays are large enough to accommodate
+ * <var>srcOffset</var> + 3 for the <var>source</var> array or
+ * <var>destOffset</var> + 4 for the <var>destination</var> array. The
+ * actual number of significant bytes in your array is given by
+ * <var>numSigBytes</var>.
+ *
+ * @param source
+ * the array to convert
+ * @param srcOffset
+ * the index where conversion begins
+ * @param numSigBytes
+ * the number of significant bytes in your array
+ * @param destination
+ * the array to hold the conversion
+ * @param destOffset
+ * the index where output will be put
+ */
+ private static void encode3to4(byte[] source, int srcOffset, int numSigBytes,
+ byte[] destination, int destOffset) {
+ // We have to shift left 24 in order to flush out the 1's that appear
+ // when Java treats a value as negative that is cast from a byte.
+
+ int inBuff = 0;
+ switch (numSigBytes) {
+ case 3:
+ inBuff |= (source[srcOffset + 2] << 24) >>> 24;
+ //$FALL-THROUGH$
+
+ case 2:
+ inBuff |= (source[srcOffset + 1] << 24) >>> 16;
+ //$FALL-THROUGH$
+
+ case 1:
+ inBuff |= (source[srcOffset] << 24) >>> 8;
+ }
+
+ switch (numSigBytes) {
+ case 3:
+ destination[destOffset] = ENC[(inBuff >>> 18)];
+ destination[destOffset + 1] = ENC[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ENC[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = ENC[(inBuff) & 0x3f];
+ break;
+
+ case 2:
+ destination[destOffset] = ENC[(inBuff >>> 18)];
+ destination[destOffset + 1] = ENC[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ENC[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = EQUALS_SIGN;
+ break;
+
+ case 1:
+ destination[destOffset] = ENC[(inBuff >>> 18)];
+ destination[destOffset + 1] = ENC[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = EQUALS_SIGN;
+ destination[destOffset + 3] = EQUALS_SIGN;
+ break;
+ }
+ }
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source
+ * The data to convert
+ * @return encoded base64 representation of source.
+ */
+ public static String encodeBytes(byte[] source) {
+ return encodeBytes(source, 0, source.length);
+ }
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source
+ * The data to convert
+ * @param off
+ * Offset in array where conversion should begin
+ * @param len
+ * Length of data to convert
+ * @return encoded base64 representation of source.
+ */
+ public static String encodeBytes(byte[] source, int off, int len) {
+ final int len43 = len * 4 / 3;
+
+ byte[] outBuff = new byte[len43 + ((len % 3) > 0 ? 4 : 0)];
+ int d = 0;
+ int e = 0;
+ int len2 = len - 2;
+
+ for (; d < len2; d += 3, e += 4)
+ encode3to4(source, d + off, 3, outBuff, e);
+
+ if (d < len) {
+ encode3to4(source, d + off, len - d, outBuff, e);
+ e += 4;
+ }
+
+ try {
+ return new String(outBuff, 0, e, UTF_8);
+ } catch (UnsupportedEncodingException uue) {
+ return new String(outBuff, 0, e);
+ }
+ }
+
+ /**
+ * Decodes four bytes from array <var>source</var> and writes the resulting
+ * bytes (up to three of them) to <var>destination</var>. The source and
+ * destination arrays can be manipulated anywhere along their length by
+ * specifying <var>srcOffset</var> and <var>destOffset</var>. This method
+ * does not check to make sure your arrays are large enough to accommodate
+ * <var>srcOffset</var> + 4 for the <var>source</var> array or
+ * <var>destOffset</var> + 3 for the <var>destination</var> array. This
+ * method returns the actual number of bytes that were converted from the
+ * Base64 encoding.
+ *
+ * @param source
+ * the array to convert
+ * @param srcOffset
+ * the index where conversion begins
+ * @param destination
+ * the array to hold the conversion
+ * @param destOffset
+ * the index where output will be put
+ * @return the number of decoded bytes converted
+ */
+ private static int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset) {
+ // Example: Dk==
+ if (source[srcOffset + 2] == EQUALS_SIGN) {
+ int outBuff = ((DEC[source[srcOffset]] & 0xFF) << 18)
+ | ((DEC[source[srcOffset + 1]] & 0xFF) << 12);
+ destination[destOffset] = (byte) (outBuff >>> 16);
+ return 1;
+ }
+
+ // Example: DkL=
+ else if (source[srcOffset + 3] == EQUALS_SIGN) {
+ int outBuff = ((DEC[source[srcOffset]] & 0xFF) << 18)
+ | ((DEC[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DEC[source[srcOffset + 2]] & 0xFF) << 6);
+ destination[destOffset] = (byte) (outBuff >>> 16);
+ destination[destOffset + 1] = (byte) (outBuff >>> 8);
+ return 2;
+ }
+
+ // Example: DkLE
+ else {
+ int outBuff = ((DEC[source[srcOffset]] & 0xFF) << 18)
+ | ((DEC[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DEC[source[srcOffset + 2]] & 0xFF) << 6)
+ | ((DEC[source[srcOffset + 3]] & 0xFF));
+
+ destination[destOffset] = (byte) (outBuff >> 16);
+ destination[destOffset + 1] = (byte) (outBuff >> 8);
+ destination[destOffset + 2] = (byte) (outBuff);
+
+ return 3;
+ }
+ }
+
+ /**
+ * Low-level decoding ASCII characters from a byte array.
+ *
+ * @param source
+ * The Base64 encoded data
+ * @param off
+ * The offset of where to begin decoding
+ * @param len
+ * The length of characters to decode
+ * @return decoded data
+ * @throws IllegalArgumentException
+ * the input is not a valid Base64 sequence.
+ */
+ public static byte[] decode(byte[] source, int off, int len) {
+ byte[] outBuff = new byte[len * 3 / 4]; // Upper limit on size of output
+ int outBuffPosn = 0;
+
+ byte[] b4 = new byte[4];
+ int b4Posn = 0;
+
+ for (int i = off; i < off + len; i++) {
+ byte sbiCrop = (byte) (source[i] & 0x7f);
+ byte sbiDecode = DEC[sbiCrop];
+
+ if (EQUALS_SIGN_DEC <= sbiDecode) {
+ b4[b4Posn++] = sbiCrop;
+ if (b4Posn > 3) {
+ outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
+ b4Posn = 0;
+
+ // If that was the equals sign, break out of 'for' loop
+ if (sbiCrop == EQUALS_SIGN)
+ break;
+ }
+
+ } else if (sbiDecode != WHITE_SPACE_DEC)
+ throw new IllegalArgumentException(MessageFormat.format(
+ "bad base64 input character {1} at {0}", i, source[i] & 0xff));
+ }
+
+ if (outBuff.length == outBuffPosn)
+ return outBuff;
+
+ byte[] out = new byte[outBuffPosn];
+ System.arraycopy(outBuff, 0, out, 0, outBuffPosn);
+ return out;
+ }
+
+ /**
+ * Decodes data from Base64 notation.
+ *
+ * @param s
+ * the string to decode
+ * @return the decoded data
+ */
+ public static byte[] decode(String s) {
+ byte[] bytes;
+ try {
+ bytes = s.getBytes(UTF_8);
+ } catch (UnsupportedEncodingException uee) {
+ bytes = s.getBytes();
+ }
+ return decode(bytes, 0, bytes.length);
+ }
+}
diff --git a/src/com/gitblit/utils/ConnectionUtils.java b/src/com/gitblit/utils/ConnectionUtils.java
index 93693ab9..9ad62d0e 100644
--- a/src/com/gitblit/utils/ConnectionUtils.java
+++ b/src/com/gitblit/utils/ConnectionUtils.java
@@ -29,7 +29,6 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
-import org.eclipse.jgit.util.Base64;
/**
* Utility class for establishing HTTP/HTTPS connections.
diff --git a/src/com/gitblit/utils/RpcUtils.java b/src/com/gitblit/utils/RpcUtils.java
index c2f20d84..387433a0 100644
--- a/src/com/gitblit/utils/RpcUtils.java
+++ b/src/com/gitblit/utils/RpcUtils.java
@@ -146,6 +146,10 @@ public class RpcUtils {
*/
public static boolean createRepository(RepositoryModel repository, String serverUrl,
String account, char[] password) throws IOException {
+ // ensure repository name ends with .git
+ if (!repository.name.endsWith(".git")) {
+ repository.name += ".git";
+ }
return doAction(RpcRequest.CREATE_REPOSITORY, null, repository, serverUrl, account,
password);