GetAccountName() public method

Gets the name of the Conjur organization account.
public GetAccountName ( ) : string
return string
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Conjur.Resource"/> class.
 /// </summary>
 /// <param name="client">Conjur client used to manipulate this resource.</param>
 /// <param name="kind">Resource kind.</param>
 /// <param name="name">Resource name.</param>
 internal Resource(Client client, string kind, string name)
 {
     this.Client = client;
     this.kind   = kind;
     this.Name   = name;
     this.Id     = $"{client.GetAccountName()}:{kind}:{Name}";
 }
Esempio n. 2
0
        internal static uint CountResources(Client client, string kind, string query = null)
        {
            string      pathCountResourceQuery = $"resources/{client.GetAccountName()}/{kind}?count=true" + ((query != null) ? $"&search={query}" : string.Empty);
            CountResult countJsonObj           = JsonSerializer <CountResult> .Read(client.AuthenticatedRequest(pathCountResourceQuery));

            return(Convert.ToUInt32(countJsonObj.Count));
        }
Esempio n. 3
0
 internal Policy(Client client, string name)
     : base(client, Constants.KIND_POLICY, name)
 {
     this.path = string.Join("/",
                             new string[]
     {
         "policies",
         Uri.EscapeDataString(client.GetAccountName()),
         Constants.KIND_POLICY,
         Uri.EscapeDataString(name)
     });
 }
Esempio n. 4
0
        internal static IEnumerable <T> ListResources <T, TResult>(Client client, string kind, Func <TResult, T> newT,
                                                                   string query = null, uint limit = 10000, uint offset = 0)
        {
            List <TResult> resultList;

            do
            {
                string pathListResourceQuery = $"resources/{client.GetAccountName()}/{kind}?offset={offset}&limit={limit}"
                                               + ((query != null) ? $"&search={query}" : string.Empty);

                resultList = JsonSerializer <List <TResult> > .Read(client.AuthenticatedRequest(pathListResourceQuery));

                foreach (TResult searchResult in resultList)
                {
                    yield return(newT(searchResult));
                }

                offset += (uint)resultList.Count;
            } while (resultList.Count > 0 && offset % limit == 0);
        }
Esempio n. 5
0
        /// <summary>
        /// List or Search for resources. Generic method that can be adapted to various kinds of resources.
        /// To reduce overhead, list is retrieved in chunks behind the scenes.
        /// </summary>
        /// <param name="newT">A method that gets as arguments TResult and returns new instance of type T.</param>
        /// <param name="client">Conjur client to query.</param>
        /// <param name="kind">Resource kind to query.</param>
        /// <param name="query">Query for search.</param>
        /// <returns>Returns IEnumerable<T>.</returns>
        internal static IEnumerable <T> ListResources <T, TResult>(Client client, string kind, Func <TResult, T> newT, string query = null)
        {
            uint           offset = 0;
            List <TResult> resultList;

            do
            {
                string urlWithParams = $"authz/{WebUtility.UrlEncode(client.GetAccountName())}/resources/{kind}?offset={offset}"
                                       + $"&limit={LIMIT_SEARCH_VAR_LIST_RETURNED}"
                                       + ((query != null) ? $"&search={query}" : string.Empty)
                                       + ((client.ActingAs != null) ? $"&acting_as={client.ActingAs}" : string.Empty);

                resultList = JsonSerializer <List <TResult> > .Read(client.AuthenticatedRequest(urlWithParams));

                foreach (TResult searchVarResult in resultList)
                {
                    yield return(newT(searchVarResult));
                }

                offset += (uint)resultList.Count;
            } while (resultList.Count > 0);
        }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Conjur.Role"/> class.
 /// </summary>
 /// <param name="client">Conjur client to use to connect.</param>
 /// <param name="kind">Kind of the role, for example 'group' or 'layer'.</param>
 /// <param name="name">The Role name.</param>
 internal Role(Client client, string kind, string name)
     : base(client, kind, name)
 {
     this.path = $"authz/{WebUtility.UrlEncode(client.GetAccountName())}/roles/{WebUtility.UrlEncode(kind)}/{WebUtility.UrlEncode(name)}";
 }
Esempio n. 7
0
        internal static IEnumerable <Variable> List(Client client, string query = null, uint limit = 10000, uint offset = 0)
        {
            Func <ResourceMetadata, Variable> newInst = (searchRes) => new Variable(client, IdToName(searchRes.Id, client.GetAccountName(), Constants.KIND_VARIABLE));

            return(ListResources <Variable, ResourceMetadata>(client, Constants.KIND_VARIABLE, newInst, query, limit, offset));
        }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Conjur.Variable"/> class.
 /// </summary>
 /// <param name="client">Conjur client to use to connect.</param>
 /// <param name="name">The variable name.</param>
 /// <seealso cref="Extensions.Variable"/>
 internal Variable(Client client, string name)
     : base(client, Constants.KIND_VARIABLE, name)
 {
     this.path = $"secrets/{Uri.EscapeDataString(client.GetAccountName())}/{Constants.KIND_VARIABLE}/{Uri.EscapeDataString(name)}";
 }
Esempio n. 9
0
        /// <summary>
        /// List of Users.
        /// </summary>
        /// <param name="client">Conjur Client to query.</param>
        /// <param name="query">Query to search.</param>
        /// <returns>Returns IEnumerable to User.</returns>
        internal static IEnumerable <User> List(Client client, string query = null, uint limit = 10000, uint offset = 0)
        {
            Func <ResourceMetadata, User> newInst = (searchRes) => new User(client,
                                                                            IdToName(searchRes.Id, client.GetAccountName(), Constants.KIND_USER));

            return(ListResources <User, ResourceMetadata>(client, Constants.KIND_USER, newInst, query, limit, offset));
        }