| | |
| | | import com.gitblit.Constants.FederationToken;
|
| | | import com.gitblit.Constants.PermissionType;
|
| | | import com.gitblit.Constants.RegistrantType;
|
| | | import com.gitblit.fanout.FanoutNioService;
|
| | | import com.gitblit.fanout.FanoutService;
|
| | | import com.gitblit.fanout.FanoutSocketService;
|
| | | import com.gitblit.models.FederationModel;
|
| | | import com.gitblit.models.FederationProposal;
|
| | | import com.gitblit.models.FederationSet;
|
| | |
| | | private TimeZone timezone;
|
| | |
|
| | | private FileBasedConfig projectConfigs;
|
| | | |
| | | private FanoutService fanoutService;
|
| | |
|
| | | public GitBlit() {
|
| | | if (gitblit == null) {
|
| | |
| | | this.userService.setup(settings);
|
| | | }
|
| | |
|
| | | public boolean supportsAddUser() {
|
| | | return supportsCredentialChanges(new UserModel(""));
|
| | | }
|
| | | |
| | | /**
|
| | | * Returns true if the user's credentials can be changed.
|
| | | *
|
| | | * @param user
|
| | | * @return true if the user service supports credential changes
|
| | | */
|
| | | public boolean supportsCredentialChanges() {
|
| | | return userService.supportsCredentialChanges();
|
| | | public boolean supportsCredentialChanges(UserModel user) {
|
| | | return (user != null && user.isLocalAccount()) || userService.supportsCredentialChanges();
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if the user's display name can be changed.
|
| | | *
|
| | | * @param user
|
| | | * @return true if the user service supports display name changes
|
| | | */
|
| | | public boolean supportsDisplayNameChanges() {
|
| | | return userService.supportsDisplayNameChanges();
|
| | | public boolean supportsDisplayNameChanges(UserModel user) {
|
| | | return (user != null && user.isLocalAccount()) || userService.supportsDisplayNameChanges();
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if the user's email address can be changed.
|
| | | *
|
| | | * @param user
|
| | | * @return true if the user service supports email address changes
|
| | | */
|
| | | public boolean supportsEmailAddressChanges() {
|
| | | return userService.supportsEmailAddressChanges();
|
| | | public boolean supportsEmailAddressChanges(UserModel user) {
|
| | | return (user != null && user.isLocalAccount()) || userService.supportsEmailAddressChanges();
|
| | | }
|
| | |
|
| | | /**
|
| | | * Returns true if the user's team memberships can be changed.
|
| | | *
|
| | | * @param user
|
| | | * @return true if the user service supports team membership changes
|
| | | */
|
| | | public boolean supportsTeamMembershipChanges() {
|
| | | return userService.supportsTeamMembershipChanges();
|
| | | public boolean supportsTeamMembershipChanges(UserModel user) {
|
| | | return (user != null && user.isLocalAccount()) || userService.supportsTeamMembershipChanges();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | * @return the effective list of permissions for the user
|
| | | */
|
| | | public List<RegistrantAccessPermission> getUserAccessPermissions(UserModel user) {
|
| | | if (StringUtils.isEmpty(user.username)) {
|
| | | // new user
|
| | | return new ArrayList<RegistrantAccessPermission>();
|
| | | }
|
| | | Set<RegistrantAccessPermission> set = new LinkedHashSet<RegistrantAccessPermission>();
|
| | | set.addAll(user.getRepositoryPermissions());
|
| | | // Flag missing repositories
|
| | |
| | | if (config.isOutdated()) {
|
| | | // reload model
|
| | | logger.info(MessageFormat.format("Config for \"{0}\" has changed. Reloading model and updating cache.", repositoryName));
|
| | | model = loadRepositoryModel(repositoryName);
|
| | | removeFromCachedRepositoryList(repositoryName);
|
| | | model = loadRepositoryModel(model.name);
|
| | | removeFromCachedRepositoryList(model.name);
|
| | | addToCachedRepositoryList(model);
|
| | | } else {
|
| | | // update a few repository parameters
|
| | |
| | | }
|
| | | model.HEAD = JGitUtils.getHEADRef(r);
|
| | | model.availableRefs = JGitUtils.getAvailableHeadTargets(r);
|
| | | model.sparkleshareId = JGitUtils.getSparkleshareId(r);
|
| | | r.close();
|
| | |
|
| | | if (model.origin != null && model.origin.startsWith("file://")) {
|
| | |
| | | }
|
| | |
|
| | | ContainerUtils.CVE_2007_0450.test();
|
| | | |
| | | // startup Fanout PubSub service
|
| | | if (settings.getInteger(Keys.fanout.port, 0) > 0) {
|
| | | String bindInterface = settings.getString(Keys.fanout.bindInterface, null);
|
| | | int port = settings.getInteger(Keys.fanout.port, FanoutService.DEFAULT_PORT);
|
| | | boolean useNio = settings.getBoolean(Keys.fanout.useNio, true);
|
| | | int limit = settings.getInteger(Keys.fanout.connectionLimit, 0);
|
| | | |
| | | if (useNio) {
|
| | | if (StringUtils.isEmpty(bindInterface)) {
|
| | | fanoutService = new FanoutNioService(port);
|
| | | } else {
|
| | | fanoutService = new FanoutNioService(bindInterface, port);
|
| | | }
|
| | | } else {
|
| | | if (StringUtils.isEmpty(bindInterface)) {
|
| | | fanoutService = new FanoutSocketService(port);
|
| | | } else {
|
| | | fanoutService = new FanoutSocketService(bindInterface, port);
|
| | | }
|
| | | }
|
| | | |
| | | fanoutService.setConcurrentConnectionLimit(limit);
|
| | | fanoutService.setAllowAllChannelAnnouncements(false);
|
| | | fanoutService.start();
|
| | | }
|
| | | }
|
| | |
|
| | | private void logTimezone(String type, TimeZone zone) {
|
| | |
| | | scheduledExecutor.shutdownNow();
|
| | | luceneExecutor.close();
|
| | | gcExecutor.close();
|
| | | if (fanoutService != null) {
|
| | | fanoutService.stop();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|