diff options
Diffstat (limited to 'src/main/java/com/gitblit/manager')
8 files changed, 1232 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/manager/IFederationManager.java b/src/main/java/com/gitblit/manager/IFederationManager.java new file mode 100644 index 00000000..debe362b --- /dev/null +++ b/src/main/java/com/gitblit/manager/IFederationManager.java @@ -0,0 +1,177 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.io.File; +import java.util.List; +import java.util.Map; + +import com.gitblit.Constants.FederationRequest; +import com.gitblit.Constants.FederationToken; +import com.gitblit.models.FederationModel; +import com.gitblit.models.FederationProposal; +import com.gitblit.models.FederationSet; +import com.gitblit.models.RepositoryModel; +import com.gitblit.models.UserModel; + +public interface IFederationManager { + + /** + * Returns the path of the proposals folder. This method checks to see if + * Gitblit is running on a cloud service and may return an adjusted path. + * + * @return the proposals folder path + */ + File getProposalsFolder(); + + UserModel getFederationUser(); + + boolean canFederate(); + + /** + * Returns the list of federated gitblit instances that this instance will + * try to pull. + * + * @return list of registered gitblit instances + */ + List<FederationModel> getFederationRegistrations(); + + /** + * Retrieve the specified federation registration. + * + * @param name + * the name of the registration + * @return a federation registration + */ + FederationModel getFederationRegistration(String url, String name); + + /** + * Returns the list of federation sets. + * + * @return list of federation sets + */ + List<FederationSet> getFederationSets(String gitblitUrl); + + /** + * Returns the list of possible federation tokens for this Gitblit instance. + * + * @return list of federation tokens + */ + List<String> getFederationTokens(); + + /** + * Returns the specified federation token for this Gitblit instance. + * + * @param type + * @return a federation token + */ + String getFederationToken(FederationToken type); + + /** + * Returns the specified federation token for this Gitblit instance. + * + * @param value + * @return a federation token + */ + String getFederationToken(String value); + + /** + * Compares the provided token with this Gitblit instance's tokens and + * determines if the requested permission may be granted to the token. + * + * @param req + * @param token + * @return true if the request can be executed + */ + boolean validateFederationRequest(FederationRequest req, String token); + + /** + * Acknowledge and cache the status of a remote Gitblit instance. + * + * @param identification + * the identification of the pulling Gitblit instance + * @param registration + * the registration from the pulling Gitblit instance + * @return true if acknowledged + */ + boolean acknowledgeFederationStatus(String identification, FederationModel registration); + + /** + * Returns the list of registration results. + * + * @return the list of registration results + */ + List<FederationModel> getFederationResultRegistrations(); + + /** + * Submit a federation proposal. The proposal is cached locally and the + * Gitblit administrator(s) are notified via email. + * + * @param proposal + * the proposal + * @param gitblitUrl + * the url of your gitblit instance to send an email to + * administrators + * @return true if the proposal was submitted + */ + boolean submitFederationProposal(FederationProposal proposal, String gitblitUrl); + + /** + * Returns the list of pending federation proposals + * + * @return list of federation proposals + */ + List<FederationProposal> getPendingFederationProposals(); + + /** + * Get repositories for the specified token. + * + * @param gitblitUrl + * the base url of this gitblit instance + * @param token + * the federation token + * @return a map of <cloneurl, RepositoryModel> + */ + Map<String, RepositoryModel> getRepositories(String gitblitUrl, String token); + + /** + * Creates a proposal from the token. + * + * @param gitblitUrl + * the url of this Gitblit instance + * @param token + * @return a potential proposal + */ + FederationProposal createFederationProposal(String gitblitUrl, String token); + + /** + * Returns the proposal identified by the supplied token. + * + * @param token + * @return the specified proposal or null + */ + FederationProposal getPendingFederationProposal(String token); + + /** + * Deletes a pending federation proposal. + * + * @param a + * proposal + * @return true if the proposal was deleted + */ + boolean deletePendingFederationProposal(FederationProposal proposal); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/IGitblitManager.java b/src/main/java/com/gitblit/manager/IGitblitManager.java new file mode 100644 index 00000000..2f5295bd --- /dev/null +++ b/src/main/java/com/gitblit/manager/IGitblitManager.java @@ -0,0 +1,83 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.util.Collection; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import com.gitblit.GitBlitException; +import com.gitblit.models.GitClientApplication; +import com.gitblit.models.RepositoryModel; +import com.gitblit.models.RepositoryUrl; +import com.gitblit.models.TeamModel; +import com.gitblit.models.UserModel; + +public interface IGitblitManager { + + /** + * Returns a list of repository URLs and the user access permission. + * + * @param request + * @param user + * @param repository + * @return a list of repository urls + */ + List<RepositoryUrl> getRepositoryUrls(HttpServletRequest request, UserModel user, RepositoryModel repository); + + /** + * Adds/updates a complete user object keyed by username. This method allows + * for renaming a user. + * + * @see IUserService.updateUserModel(String, UserModel) + * @param username + * @param user + * @param isCreate + * @throws GitBlitException + */ + void updateUserModel(String username, UserModel user, boolean isCreate) throws GitBlitException; + + /** + * Updates the TeamModel object for the specified name. + * + * @param teamname + * @param team + * @param isCreate + */ + void updateTeamModel(String teamname, TeamModel team, boolean isCreate) throws GitBlitException; + + /** + * Creates a personal fork of the specified repository. The clone is view + * restricted by default and the owner of the source repository is given + * access to the clone. + * + * @param repository + * @param user + * @return the repository model of the fork, if successful + * @throws GitBlitException + */ + RepositoryModel fork(RepositoryModel repository, UserModel user) throws GitBlitException; + + /** + * Returns the list of custom client applications to be used for the + * repository url panel; + * + * @return a collection of client applications + */ + Collection<GitClientApplication> getClientApplications(); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/INotificationManager.java b/src/main/java/com/gitblit/manager/INotificationManager.java new file mode 100644 index 00000000..f53ae68d --- /dev/null +++ b/src/main/java/com/gitblit/manager/INotificationManager.java @@ -0,0 +1,66 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.util.Collection; + +public interface INotificationManager { + + /** + * Notify the administrators by email. + * + * @param subject + * @param message + */ + void sendMailToAdministrators(String subject, String message); + + /** + * Notify users by email of something. + * + * @param subject + * @param message + * @param toAddresses + */ + void sendMail(String subject, String message, Collection<String> toAddresses); + + /** + * Notify users by email of something. + * + * @param subject + * @param message + * @param toAddresses + */ + void sendMail(String subject, String message, String... toAddresses); + + /** + * Notify users by email of something. + * + * @param subject + * @param message + * @param toAddresses + */ + void sendHtmlMail(String subject, String message, Collection<String> toAddresses); + + /** + * Notify users by email of something. + * + * @param subject + * @param message + * @param toAddresses + */ + void sendHtmlMail(String subject, String message, String... toAddresses); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/IProjectManager.java b/src/main/java/com/gitblit/manager/IProjectManager.java new file mode 100644 index 00000000..b2577f56 --- /dev/null +++ b/src/main/java/com/gitblit/manager/IProjectManager.java @@ -0,0 +1,63 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.util.List; + +import com.gitblit.models.ProjectModel; +import com.gitblit.models.RepositoryModel; +import com.gitblit.models.UserModel; + +public interface IProjectManager { + + /** + * Returns a list of project models for the user. + * + * @param user + * @param includeUsers + * @return list of projects that are accessible to the user + */ + List<ProjectModel> getProjectModels(UserModel user, boolean includeUsers); + + /** + * Returns the project model for the specified user. + * + * @param name + * @param user + * @return a project model, or null if it does not exist + */ + ProjectModel getProjectModel(String name, UserModel user); + + /** + * Returns a project model for the Gitblit/system user. + * + * @param name a project name + * @return a project model or null if the project does not exist + */ + ProjectModel getProjectModel(String name); + + /** + * Returns the list of project models that are referenced by the supplied + * repository model list. This is an alternative method exists to ensure + * Gitblit does not call getRepositoryModels(UserModel) twice in a request. + * + * @param repositoryModels + * @param includeUsers + * @return a list of project models + */ + List<ProjectModel> getProjectModels(List<RepositoryModel> repositoryModels, boolean includeUsers); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/IRepositoryManager.java b/src/main/java/com/gitblit/manager/IRepositoryManager.java new file mode 100644 index 00000000..383ca0d5 --- /dev/null +++ b/src/main/java/com/gitblit/manager/IRepositoryManager.java @@ -0,0 +1,396 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.io.File; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.eclipse.jgit.lib.Repository; + +import com.gitblit.GitBlitException; +import com.gitblit.models.ForkModel; +import com.gitblit.models.Metric; +import com.gitblit.models.RegistrantAccessPermission; +import com.gitblit.models.RepositoryModel; +import com.gitblit.models.SearchResult; +import com.gitblit.models.UserModel; + +public interface IRepositoryManager { + + /** + * Returns the path of the repositories folder. This method checks to see if + * Gitblit is running on a cloud service and may return an adjusted path. + * + * @return the repositories folder path + */ + File getRepositoriesFolder(); + + /** + * Returns the path of the hooks folder. This method checks to see if + * Gitblit is running on a cloud service and may return an adjusted path. + * + * @return the Groovy hook scripts folder path + */ + File getHooksFolder(); + + /** + * Returns the path of the grapes folder. This method checks to see if + * Gitblit is running on a cloud service and may return an adjusted path. + * + * @return the Groovy grapes folder path + */ + File getGrapesFolder(); + + /** + * Returns the most recent change date of any repository served by Gitblit. + * + * @return a date + */ + Date getLastActivityDate(); + + /** + * Returns the effective list of permissions for this user, taking into account + * team memberships, ownerships. + * + * @param user + * @return the effective list of permissions for the user + */ + List<RegistrantAccessPermission> getUserAccessPermissions(UserModel user); + + /** + * Returns the list of users and their access permissions for the specified + * repository including permission source information such as the team or + * regular expression which sets the permission. + * + * @param repository + * @return a list of RegistrantAccessPermissions + */ + List<RegistrantAccessPermission> getUserAccessPermissions(RepositoryModel repository); + + /** + * Sets the access permissions to the specified repository for the specified users. + * + * @param repository + * @param permissions + * @return true if the user models have been updated + */ + boolean setUserAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions); + + /** + * Returns the list of all users who have an explicit access permission + * for the specified repository. + * + * @see IUserService.getUsernamesForRepositoryRole(String) + * @param repository + * @return list of all usernames that have an access permission for the repository + */ + List<String> getRepositoryUsers(RepositoryModel repository); + + /** + * Returns the list of teams and their access permissions for the specified + * repository including the source of the permission such as the admin flag + * or a regular expression. + * + * @param repository + * @return a list of RegistrantAccessPermissions + */ + List<RegistrantAccessPermission> getTeamAccessPermissions(RepositoryModel repository); + + /** + * Sets the access permissions to the specified repository for the specified teams. + * + * @param repository + * @param permissions + * @return true if the team models have been updated + */ + boolean setTeamAccessPermissions(RepositoryModel repository, Collection<RegistrantAccessPermission> permissions); + + /** + * Returns the list of all teams who have an explicit access permission for + * the specified repository. + * + * @see IUserService.getTeamnamesForRepositoryRole(String) + * @param repository + * @return list of all teamnames with explicit access permissions to the repository + */ + List<String> getRepositoryTeams(RepositoryModel repository); + + /** + * Adds the repository to the list of cached repositories if Gitblit is + * configured to cache the repository list. + * + * @param model + */ + void addToCachedRepositoryList(RepositoryModel model); + + /** + * Resets the repository list cache. + * + */ + void resetRepositoryListCache(); + + /** + * Returns the list of all repositories available to Gitblit. This method + * does not consider user access permissions. + * + * @return list of all repositories + */ + List<String> getRepositoryList(); + + /** + * Returns the JGit repository for the specified name. + * + * @param repositoryName + * @return repository or null + */ + Repository getRepository(String repositoryName); + + /** + * Returns the JGit repository for the specified name. + * + * @param repositoryName + * @param logError + * @return repository or null + */ + Repository getRepository(String repositoryName, boolean logError); + + /** + * Returns the list of repository models that are accessible to the user. + * + * @param user + * @return list of repository models accessible to user + */ + List<RepositoryModel> getRepositoryModels(UserModel user); + + /** + * Returns a repository model if the repository exists and the user may + * access the repository. + * + * @param user + * @param repositoryName + * @return repository model or null + */ + RepositoryModel getRepositoryModel(UserModel user, String repositoryName); + + /** + * Returns the repository model for the specified repository. This method + * does not consider user access permissions. + * + * @param repositoryName + * @return repository model or null + */ + RepositoryModel getRepositoryModel(String repositoryName); + + /** + * Returns the star count of the repository. + * + * @param repository + * @return the star count + */ + long getStarCount(RepositoryModel repository); + + /** + * Determines if this server has the requested repository. + * + * @param n + * @return true if the repository exists + */ + boolean hasRepository(String repositoryName); + + /** + * Determines if this server has the requested repository. + * + * @param n + * @param caseInsensitive + * @return true if the repository exists + */ + boolean hasRepository(String repositoryName, boolean caseSensitiveCheck); + + /** + * Determines if the specified user has a fork of the specified origin + * repository. + * + * @param username + * @param origin + * @return true the if the user has a fork + */ + boolean hasFork(String username, String origin); + + /** + * Gets the name of a user's fork of the specified origin + * repository. + * + * @param username + * @param origin + * @return the name of the user's fork, null otherwise + */ + String getFork(String username, String origin); + + /** + * Returns the fork network for a repository by traversing up the fork graph + * to discover the root and then down through all children of the root node. + * + * @param repository + * @return a ForkModel + */ + ForkModel getForkNetwork(String repository); + + /** + * Updates the last changed fields and optionally calculates the size of the + * repository. Gitblit caches the repository sizes to reduce the performance + * penalty of recursive calculation. The cache is updated if the repository + * has been changed since the last calculation. + * + * @param model + * @return size in bytes of the repository + */ + long updateLastChangeFields(Repository r, RepositoryModel model); + + /** + * Returns the metrics for the default branch of the specified repository. + * This method builds a metrics cache. The cache is updated if the + * repository is updated. A new copy of the metrics list is returned on each + * call so that modifications to the list are non-destructive. + * + * @param model + * @param repository + * @return a new array list of metrics + */ + List<Metric> getRepositoryDefaultMetrics(RepositoryModel model, Repository repository); + + /** + * Creates/updates the repository model keyed by reopsitoryName. Saves all + * repository settings in .git/config. This method allows for renaming + * repositories and will update user access permissions accordingly. + * + * All repositories created by this method are bare and automatically have + * .git appended to their names, which is the standard convention for bare + * repositories. + * + * @param repositoryName + * @param repository + * @param isCreate + * @throws GitBlitException + */ + void updateRepositoryModel(String repositoryName, RepositoryModel repository, boolean isCreate) + throws GitBlitException; + + /** + * Updates the Gitblit configuration for the specified repository. + * + * @param r + * the Git repository + * @param repository + * the Gitblit repository model + */ + void updateConfiguration(Repository r, RepositoryModel repository); + + /** + * Deletes the repository from the file system and removes the repository + * permission from all repository users. + * + * @param model + * @return true if successful + */ + boolean deleteRepositoryModel(RepositoryModel model); + + /** + * Deletes the repository from the file system and removes the repository + * permission from all repository users. + * + * @param repositoryName + * @return true if successful + */ + boolean deleteRepository(String repositoryName); + + /** + * Returns the list of all Groovy push hook scripts. Script files must have + * .groovy extension + * + * @return list of available hook scripts + */ + List<String> getAllScripts(); + + /** + * Returns the list of pre-receive scripts the repository inherited from the + * global settings and team affiliations. + * + * @param repository + * if null only the globally specified scripts are returned + * @return a list of scripts + */ + List<String> getPreReceiveScriptsInherited(RepositoryModel repository); + + /** + * Returns the list of all available Groovy pre-receive push hook scripts + * that are not already inherited by the repository. Script files must have + * .groovy extension + * + * @param repository + * optional parameter + * @return list of available hook scripts + */ + List<String> getPreReceiveScriptsUnused(RepositoryModel repository); + + /** + * Returns the list of post-receive scripts the repository inherited from + * the global settings and team affiliations. + * + * @param repository + * if null only the globally specified scripts are returned + * @return a list of scripts + */ + List<String> getPostReceiveScriptsInherited(RepositoryModel repository); + + /** + * Returns the list of unused Groovy post-receive push hook scripts that are + * not already inherited by the repository. Script files must have .groovy + * extension + * + * @param repository + * optional parameter + * @return list of available hook scripts + */ + List<String> getPostReceiveScriptsUnused(RepositoryModel repository); + + /** + * Search the specified repositories using the Lucene query. + * + * @param query + * @param page + * @param pageSize + * @param repositories + * @return + */ + List<SearchResult> search(String query, int page, int pageSize, List<String> repositories); + + /** + * + * @return true if we are running the gc executor + */ + boolean isCollectingGarbage(); + + /** + * Returns true if Gitblit is actively collecting garbage in this repository. + * + * @param repositoryName + * @return true if actively collecting garbage + */ + boolean isCollectingGarbage(String repositoryName); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/IRuntimeManager.java b/src/main/java/com/gitblit/manager/IRuntimeManager.java new file mode 100644 index 00000000..178b93ca --- /dev/null +++ b/src/main/java/com/gitblit/manager/IRuntimeManager.java @@ -0,0 +1,103 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.io.File; +import java.util.Date; +import java.util.Map; +import java.util.TimeZone; + +import com.gitblit.IStoredSettings; +import com.gitblit.models.ServerSettings; +import com.gitblit.models.ServerStatus; + +public interface IRuntimeManager { + + void setBaseFolder(File folder); + + File getBaseFolder(); + + /** + * Returns the preferred timezone for the Gitblit instance. + * + * @return a timezone + */ + TimeZone getTimezone(); + + /** + * Determine if this Gitblit instance is actively serving git repositories + * or if it is merely a repository viewer. + * + * @return true if Gitblit is serving repositories + */ + boolean isServingRepositories(); + + /** + * Determine if this Gitblit instance is running in debug mode + * + * @return true if Gitblit is running in debug mode + */ + boolean isDebugMode(); + + /** + * Returns the boot date of the Gitblit server. + * + * @return the boot date of Gitblit + */ + Date getBootDate(); + + ServerStatus getStatus(); + + /** + * Returns the descriptions/comments of the Gitblit config settings. + * + * @return SettingsModel + */ + ServerSettings getSettingsModel(); + + /** + * Returns the file object for the specified configuration key. + * + * @return the file + */ + File getFileOrFolder(String key, String defaultFileOrFolder); + + /** + * Returns the file object which may have it's base-path determined by + * environment variables for running on a cloud hosting service. All Gitblit + * file or folder retrievals are (at least initially) funneled through this + * method so it is the correct point to globally override/alter filesystem + * access based on environment or some other indicator. + * + * @return the file + */ + File getFileOrFolder(String fileOrFolder); + + /** + * Returns the runtime settings. + * + * @return settings + */ + IStoredSettings getSettings(); + + /** + * Updates the runtime settings. + * + * @param settings + * @return true if the update succeeded + */ + boolean updateSettings(Map<String, String> updatedSettings); +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/ISessionManager.java b/src/main/java/com/gitblit/manager/ISessionManager.java new file mode 100644 index 00000000..09e306ac --- /dev/null +++ b/src/main/java/com/gitblit/manager/ISessionManager.java @@ -0,0 +1,64 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.gitblit.models.UserModel; + +public interface ISessionManager { + + /** + * Authenticate a user based on HTTP request parameters. + * + * Authentication by X509Certificate is tried first and then by cookie. + * + * @param httpRequest + * @return a user object or null + */ + UserModel authenticate(HttpServletRequest httpRequest); + + /** + * Authenticate a user based on HTTP request parameters. + * + * Authentication by X509Certificate, servlet container principal, cookie, + * and BASIC header. + * + * @param httpRequest + * @param requiresCertificate + * @return a user object or null + */ + UserModel authenticate(HttpServletRequest httpRequest, boolean requiresCertificate); + + UserModel authenticate(String username, char[] password); + + /** + * Sets a cookie for the specified user. + * + * @param response + * @param user + */ + void setCookie(HttpServletResponse response, UserModel user); + + /** + * Logout a user. + * + * @param user + */ + void logout(HttpServletResponse response, UserModel user); + +}
\ No newline at end of file diff --git a/src/main/java/com/gitblit/manager/IUserManager.java b/src/main/java/com/gitblit/manager/IUserManager.java new file mode 100644 index 00000000..3ce1e744 --- /dev/null +++ b/src/main/java/com/gitblit/manager/IUserManager.java @@ -0,0 +1,280 @@ +/* + * Copyright 2013 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.manager; + +import java.util.Collection; +import java.util.List; + +import com.gitblit.models.TeamModel; +import com.gitblit.models.UserModel; + +public interface IUserManager { + + boolean supportsAddUser(); + + /** + * Does the user service support changes to credentials? + * + * @return true or false + * @since 1.0.0 + */ + boolean supportsCredentialChanges(UserModel user); + + /** + * Returns true if the user's display name can be changed. + * + * @param user + * @return true if the user service supports display name changes + */ + boolean supportsDisplayNameChanges(UserModel user); + + /** + * Returns true if the user's email address can be changed. + * + * @param user + * @return true if the user service supports email address changes + */ + boolean supportsEmailAddressChanges(UserModel user); + + /** + * Returns true if the user's team memberships can be changed. + * + * @param user + * @return true if the user service supports team membership changes + */ + boolean supportsTeamMembershipChanges(UserModel user); + + /** + * Does the user service support cookie authentication? + * + * @return true or false + */ + boolean supportsCookies(); + + /** + * Returns the cookie value for the specified user. + * + * @param model + * @return cookie value + */ + String getCookie(UserModel model); + + /** + * Authenticate a user based on their cookie. + * + * @param cookie + * @return a user object or null + */ + UserModel authenticate(char[] cookie); + + /** + * Authenticate a user based on a username and password. + * + * @param username + * @param password + * @return a user object or null + */ + UserModel authenticate(String username, char[] password); + + /** + * Logout a user. + * + * @param user + */ + void logout(UserModel user); + + /** + * Retrieve the user object for the specified username. + * + * @param username + * @return a user object or null + */ + UserModel getUserModel(String username); + + /** + * Updates/writes a complete user object. + * + * @param model + * @return true if update is successful + */ + boolean updateUserModel(UserModel model); + + /** + * Updates/writes all specified user objects. + * + * @param models a list of user models + * @return true if update is successful + * @since 1.2.0 + */ + boolean updateUserModels(Collection<UserModel> models); + + /** + * Adds/updates a user object keyed by username. This method allows for + * renaming a user. + * + * @param username + * the old username + * @param model + * the user object to use for username + * @return true if update is successful + */ + boolean updateUserModel(String username, UserModel model); + + /** + * Deletes the user object from the user service. + * + * @param model + * @return true if successful + */ + boolean deleteUserModel(UserModel model); + + /** + * Delete the user object with the specified username + * + * @param username + * @return true if successful + */ + boolean deleteUser(String username); + + /** + * Returns the list of all users available to the login service. + * + * @return list of all usernames + */ + List<String> getAllUsernames(); + + /** + * Returns the list of all users available to the login service. + * + * @return list of all users + * @since 0.8.0 + */ + List<UserModel> getAllUsers(); + + /** + * Returns the list of all teams available to the login service. + * + * @return list of all teams + * @since 0.8.0 + */ + List<String> getAllTeamNames(); + + /** + * Returns the list of all teams available to the login service. + * + * @return list of all teams + * @since 0.8.0 + */ + List<TeamModel> getAllTeams(); + + /** + * Returns the list of all users who are allowed to bypass the access + * restriction placed on the specified repository. + * + * @param role + * the repository name + * @return list of all usernames that can bypass the access restriction + * @since 0.8.0 + */ + List<String> getTeamnamesForRepositoryRole(String role); + + /** + * Retrieve the team object for the specified team name. + * + * @param teamname + * @return a team object or null + * @since 0.8.0 + */ + TeamModel getTeamModel(String teamname); + + /** + * Updates/writes a complete team object. + * + * @param model + * @return true if update is successful + * @since 0.8.0 + */ + boolean updateTeamModel(TeamModel model); + + /** + * Updates/writes all specified team objects. + * + * @param models a list of team models + * @return true if update is successful + * @since 1.2.0 + */ + boolean updateTeamModels(Collection<TeamModel> models); + + /** + * Updates/writes and replaces a complete team object keyed by teamname. + * This method allows for renaming a team. + * + * @param teamname + * the old teamname + * @param model + * the team object to use for teamname + * @return true if update is successful + * @since 0.8.0 + */ + boolean updateTeamModel(String teamname, TeamModel model); + + /** + * Deletes the team object from the user service. + * + * @param model + * @return true if successful + * @since 0.8.0 + */ + boolean deleteTeamModel(TeamModel model); + + /** + * Delete the team object with the specified teamname + * + * @param teamname + * @return true if successful + * @since 0.8.0 + */ + boolean deleteTeam(String teamname); + + /** + * Returns the list of all users who are allowed to bypass the access + * restriction placed on the specified repository. + * + * @param role + * the repository name + * @return list of all usernames that can bypass the access restriction + * @since 0.8.0 + */ + List<String> getUsernamesForRepositoryRole(String role); + + /** + * Renames a repository role. + * + * @param oldRole + * @param newRole + * @return true if successful + */ + boolean renameRepositoryRole(String oldRole, String newRole); + + /** + * Removes a repository role from all users. + * + * @param role + * @return true if successful + */ + boolean deleteRepositoryRole(String role); + +}
\ No newline at end of file |