Ejemplo n.º 1
0
        /// <summary>
        /// Gets the groups.
        /// </summary>
        /// <returns>The groups.</returns>
        public List <string> GetGroups()
        {
            List <string> groups            = new List <string>();
            var           artifactoryGroups = ArtifactoryBaseUrl.Security().GetGroups();

            foreach (var g in artifactoryGroups)
            {
                groups.Add(g.Name);
            }
            return(groups);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the local repository.
        /// </summary>
        /// <param name="repo">Repo.</param>
        /// <param name="removeOld">If set to <c>true</c> remove old.</param>
        public void CreateLocalRepository(string repo, bool removeOld = false)
        {
            if (removeOld || !RepositoryExists(repo))
            {
                var config = new LocalRepositoryConfiguration {
                    Key         = repo,
                    packageType = RepositoryConfiguration.PackageType.generic
                };

                ArtifactoryBaseUrl.Repositories().CreateRepository(config);
            }
        }
Ejemplo n.º 3
0
        /***************************************************************************************************************************************/

        #region Group

        /// <summary>
        /// Creates the group.
        /// </summary>
        /// <param name="group">Group.</param>
        public void CreateGroup(string group, string dn)
        {
            SecurityGroup config = new SecurityGroup {
                Name            = group,
                Description     = "Group synchronized from LDAP",
                Realm           = "ldap",
                AutoJoin        = false,
                RealmAttributes = string.Format("ldapGroupName={0};groupsStrategy=STATIC;groupDn={1}", group, dn)
            };

            ArtifactoryBaseUrl.Security().CreateOrReplaceGroup(config);
        }
Ejemplo n.º 4
0
        internal static ShareRequest LoadFromJsonString(string payload, ArtifactoryBaseUrl storeBaseUrl)
        {
            JsonSerializer serializer = new JsonSerializer();

            serializer.ContractResolver  = new CamelCasePropertyNamesContractResolver();
            serializer.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;

            ShareRequest shareRequest = (ShareRequest)serializer.Deserialize(new StringReader(payload), typeof(ShareRequest));

            shareRequest.storeBaseUrl = storeBaseUrl;

            return(shareRequest);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Generates the token.
        /// </summary>
        /// <returns>The token.</returns>
        /// <param name="username">Username.</param>
        /// <param name="domains">Domains.</param>
        /// <param name="expires_in">Expires in.</param>
        public Token GenerateToken(string username, List <string> domains, int expires_in = 3600)
        {
            var          scope  = string.Format("member-of-groups:{0}", string.Join(",", domains));
            TokenRequest config = new TokenRequest {
                username   = username,
                scope      = scope,
                expires_in = expires_in
            };

            var token = ArtifactoryBaseUrl.Security().GenerateToken(config);

            return(token);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Repositories the exists.
 /// </summary>
 /// <returns><c>true</c>, if exists was repositoryed, <c>false</c> otherwise.</returns>
 /// <param name="repo">Repo.</param>
 public bool RepositoryExists(string repo)
 {
     try {
         var repository = ArtifactoryBaseUrl.Repositories().RepositoryConfiguration(repo);
         if (repository != null)
         {
             return(true);
         }
     } catch (Exception) {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the storage info.
        /// </summary>
        /// <param name="repo">Repo.</param>
        public RepositoriesSummary GetStorageInfo(string repo)
        {
            if (string.IsNullOrEmpty(repo))
            {
                throw new Exception("Invalid storage name : " + repo);
            }
            var info = ArtifactoryBaseUrl.Storage().StorageInfo();

            foreach (var storage in info.repositoriesSummaryList)
            {
                if (repo.Equals(storage.repoKey))
                {
                    return(storage);
                }
            }
            return(null);
        }
Ejemplo n.º 8
0
        /***************************************************************************************************************************************/

        #region Permissions

        /// <summary>
        /// Creates the permission for group on repo.
        /// </summary>
        /// <param name="group">Group.</param>
        /// <param name="repo">Repo.</param>
        public void CreatePermissionForGroupOnRepo(string group, string repo)
        {
            PermissionTarget permissionTarget = new PermissionTarget {
                Name         = group,
                Repositories = new List <string> {
                    repo
                }
            };

            Permissions permissions = new Permissions();

            permissions.Add(PERMISSION_DELETE);
            permissions.Add(PERMISSION_READ);
            permissions.Add(PERMISSION_DEPLOY);
            permissions.Add(PERMISSION_ANNOTATE);
            permissionTarget.Principals.Groups.Clear();
            permissionTarget.Principals.Groups.Add(group, permissions);

            ArtifactoryBaseUrl.Security().CreateOrReplacePermissionTarget(permissionTarget);
        }
Ejemplo n.º 9
0
 public Stream DownloadItem(string repoKey, string path)
 {
     return(ArtifactoryBaseUrl.Download(repoKey, path));
 }
Ejemplo n.º 10
0
 public MessageContainer MoveItem(string srcRepoKey, string srcFilePath, string targetRepoKey, string targetFilePath, int dry)
 {
     return(ArtifactoryBaseUrl.Storage().MoveItem(srcRepoKey, srcFilePath, targetRepoKey, targetFilePath, dry));
 }
Ejemplo n.º 11
0
 public FolderInfo CreateFolder(string repoKey, string path)
 {
     return(ArtifactoryBaseUrl.Storage().CreateFolder(repoKey, path));
 }
Ejemplo n.º 12
0
        public void UploadFile(string repoKey, string path, string filename)
        {
            TextReader reader = File.OpenText(filename);

            ArtifactoryBaseUrl.Deploy(repoKey, path, reader);
        }
Ejemplo n.º 13
0
 public StoreFactory(IfyContext context, string userApikey)
 {
     this.Context       = context;
     ArtifactoryBaseUrl = new ArtifactoryBaseUrl(storeBaseUrl, userApikey);
     Serializer         = ArtifactoryBaseUrl.Serializer;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Revokes the API key.
        /// </summary>
        /// <param name="username">Username.</param>
        /// <param name="password">Password.</param>
        public void RevokeApiKey(string username, string password)
        {
            var userArtifactoryBaseUrl = new ArtifactoryBaseUrl(this.Context.GetConfigValue("artifactory-APIurl"), username, password);

            userArtifactoryBaseUrl.Security().RevokeApiKey();
        }
Ejemplo n.º 15
0
        /***************************************************************************************************************************************/

        #region User

        /// <summary>
        /// Gets the user info.
        /// </summary>
        /// <returns>The user info.</returns>
        /// <param name="username">Username.</param>
        public SecurityUser GetUserInfo(string username)
        {
            return(ArtifactoryBaseUrl.Security().GetUserDetails(username));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Deletes the user.
 /// </summary>
 /// <param name="username">Username.</param>
 public void DeleteUser(string username)
 {
     ArtifactoryBaseUrl.Security().DeleteUser(username);
 }
Ejemplo n.º 17
0
 public RepositoryInfoList GetRepositoriesToDeploy()
 {
     return(ArtifactoryBaseUrl.Repositories().GetRepositoriesToDeploy());
 }
Ejemplo n.º 18
0
 public void DeleteFile(string repoKey, string path)
 {
     ArtifactoryBaseUrl.Storage().DeleteItem(repoKey, path);
 }
Ejemplo n.º 19
0
 public ShareRequest(ArtifactoryBaseUrl baseUrl)
 {
     storeBaseUrl = baseUrl;
 }