コード例 #1
0
        Core.ServiceResponse ISecurityService.AddProjectUser(SecurityServiceRequest securityServiceRequest)
        {
            if (string.IsNullOrEmpty(securityServiceRequest.Id)
                || string.IsNullOrEmpty(securityServiceRequest.Token)
                || string.IsNullOrEmpty(securityServiceRequest.Type))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Id Type and Token should not null" };
            }

            if (!securityServiceRequest.Type.Equals("Administrator") && !securityServiceRequest.Type.Equals("ProjectUser"))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "Type should be Administrator or ProjectUser" };
            }

            if (string.IsNullOrEmpty(securityServiceRequest.UserName))
            {
                return new Core.ServiceResponse() { Code = 400, Message = "UserName should not null" };
            }

            string message = string.Empty;
            if (HP.TS.Devops.Security.SecurityCode.Success != HP.TS.Devops.Security.SecurityAction.CheckAccess(this.ConnectString, securityServiceRequest, out message))
            {
                return new Core.ServiceResponse() { Code = 403, Message = securityServiceRequest.Id + " of type " + securityServiceRequest.Type + " have no access of " + message };
            }

            SecurityAction securityAction = new SecurityAction(this.ConnectString);
            if (securityAction.AddProjectUser(securityServiceRequest.UserName) <= 0)
            {
                return new Core.ServiceResponse() { Code = 500, Message = "Add ProjectUser Fail" };
            }
            return new Core.ServiceResponse()
            {
                Code = 0,
                Message = "Success"
            };
        }
コード例 #2
0
 public void TestAddProjectUser()
 {
     SecurityAction securityAction = new SecurityAction(ConnectString);
     System.Console.WriteLine(securityAction.AddProjectUser("CR59"));
 }