| | |
| | | import java.net.URL;
|
| | | import java.text.MessageFormat;
|
| | |
|
| | | import com.google.inject.Inject;
|
| | | import com.google.inject.Singleton;
|
| | | import javax.servlet.ServletException;
|
| | | import javax.servlet.http.HttpServlet;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.UserModel;
|
| | | import com.gitblit.utils.StringUtils;
|
| | | import com.google.inject.Inject;
|
| | | import com.google.inject.Singleton;
|
| | |
|
| | | /**
|
| | | * Handles requests for Sparkleshare Invites
|
| | |
| | | response.getWriter().append("SSH is not active on this server!");
|
| | | return;
|
| | | }
|
| | | int sshDisplayPort = settings.getInteger(Keys.git.sshAdvertisedPort, sshPort);
|
| | |
|
| | | // extract repo name from request
|
| | | String repoUrl = request.getPathInfo().substring(1);
|
| | |
|
| | |
| | | String url = settings.getString(Keys.web.canonicalUrl, "https://localhost:8443");
|
| | | if (!StringUtils.isEmpty(url) && url.indexOf("localhost") == -1) {
|
| | | host = new URL(url).getHost();
|
| | | }
|
| | | String sshDisplayHost = settings.getString(Keys.git.sshAdvertisedHost, "");
|
| | | if(sshDisplayHost.isEmpty()) {
|
| | | sshDisplayHost = host;
|
| | | }
|
| | |
|
| | | UserModel user;
|
| | |
| | | StringBuilder sb = new StringBuilder();
|
| | | sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
| | | sb.append("<sparkleshare><invite>\n");
|
| | | sb.append(MessageFormat.format("<address>ssh://{0}@{1}:{2,number,0}/</address>\n", user.username, host, sshPort));
|
| | | sb.append(MessageFormat.format("<address>ssh://{0}@{1}:{2,number,0}/</address>\n", user.username, sshDisplayHost, sshDisplayPort));
|
| | | sb.append(MessageFormat.format("<remote_path>/{0}</remote_path>\n", model.name));
|
| | | int fanoutPort = settings.getInteger(Keys.fanout.port, 0);
|
| | | if (fanoutPort > 0) {
|