import javax.servlet.http.HttpServletRequest;
+import com.gitblit.Constants.Transport;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.RepositoryUrl;
import com.gitblit.models.UserModel;
*/
boolean isServingHTTP();
+ /**
+ * Determine if this Gitblit instance is actively serving git repositories
+ * over HTTP.
+ *
+ * @return true if Gitblit is serving repositories over HTTPS
+ * @since 1.7.0
+ */
+ boolean isServingHTTPS();
+
/**
* Determine if this Gitblit instance is actively serving git repositories
* over the GIT Daemon protocol.
*/
List<RepositoryUrl> getRepositoryUrls(HttpServletRequest request, UserModel user, RepositoryModel repository);
+ /**
+ * Returns true if the transport may be used for pushing.
+ *
+ * @param byTransport
+ * @return true if the transport can be used for pushes.
+ * @since 1.7.0
+ */
+ boolean acceptsPush(Transport byTransport);
+
}
\ No newline at end of file
AccessPermission permission = user.getRepositoryPermission(repository).permission;
if (permission.exceeds(AccessPermission.NONE)) {
Transport transport = Transport.fromString(request.getScheme());
- if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(transport)) {
+ if (permission.atLeast(AccessPermission.PUSH) && !acceptsPush(transport)) {
// downgrade the repo permission for this transport
// because it is not an acceptable PUSH transport
permission = AccessPermission.CLONE;
if (!StringUtils.isEmpty(sshDaemonUrl)) {
AccessPermission permission = user.getRepositoryPermission(repository).permission;
if (permission.exceeds(AccessPermission.NONE)) {
- if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.SSH)) {
+ if (permission.atLeast(AccessPermission.PUSH) && !acceptsPush(Transport.SSH)) {
// downgrade the repo permission for this transport
// because it is not an acceptable PUSH transport
permission = AccessPermission.CLONE;
if (!StringUtils.isEmpty(gitDaemonUrl)) {
AccessPermission permission = getGitDaemonAccessPermission(user, repository);
if (permission.exceeds(AccessPermission.NONE)) {
- if (permission.atLeast(AccessPermission.PUSH) && !acceptPush(Transport.GIT)) {
+ if (permission.atLeast(AccessPermission.PUSH) && !acceptsPush(Transport.GIT)) {
// downgrade the repo permission for this transport
// because it is not an acceptable PUSH transport
permission = AccessPermission.CLONE;
*/
@Override
public boolean isServingRepositories() {
- return isServingHTTP()
+ return isServingHTTPS()
+ || isServingHTTP()
|| isServingGIT()
|| isServingSSH();
}
*/
@Override
public boolean isServingHTTP() {
- return settings.getBoolean(Keys.git.enableGitServlet, true);
+ return settings.getBoolean(Keys.git.enableGitServlet, true)
+ && ((gitblit.getStatus().isGO && settings.getInteger(Keys.server.httpPort, 0) > 0)
+ || !gitblit.getStatus().isGO);
+ }
+
+ /* (non-Javadoc)
+ * @see com.gitblit.manager.IServicesManager#isServingHTTPS()
+ */
+ @Override
+ public boolean isServingHTTPS() {
+ return settings.getBoolean(Keys.git.enableGitServlet, true)
+ && ((gitblit.getStatus().isGO && settings.getInteger(Keys.server.httpsPort, 0) > 0)
+ || !gitblit.getStatus().isGO);
}
/* (non-Javadoc)
}
}
- protected boolean acceptPush(Transport byTransport) {
+ @Override
+ public boolean acceptsPush(Transport byTransport) {
if (byTransport == null) {
logger.info("Unknown transport, push rejected!");
return false;