Exemplo n.º 1
0
  def InitFromAff4Object(self, approval_obj, approval_subject_obj=None):
    if not approval_subject_obj:
      approval_subject_obj = aff4.FACTORY.Open(
          approval_obj.Get(approval_obj.Schema.SUBJECT),
          aff4_type=aff4_grr.VFSGRRClient.__name__,
          token=approval_obj.token)

    self.subject = api_client.ApiClient().InitFromAff4Object(
        approval_subject_obj)
    self.reason = approval_obj.Get(approval_obj.Schema.REASON)

    try:
      approval_obj.CheckAccess(approval_obj.token)
      self.is_valid = True
    except access_control.UnauthorizedAccess as e:
      self.is_valid = False
      self.is_valid_message = utils.SmartStr(e)

    notified_users = approval_obj.Get(approval_obj.Schema.NOTIFIED_USERS)
    if notified_users:
      self.notified_users = sorted(u.strip() for u in notified_users.split(","))

    email_cc = approval_obj.Get(approval_obj.Schema.EMAIL_CC)
    email_cc_addresses = sorted(s.strip() for s in email_cc.split(","))
    self.email_cc_addresses = set(email_cc_addresses) - set(self.notified_users)

    self.approvers = sorted(approval_obj.GetNonExpiredApprovers())

    return self
Exemplo n.º 2
0
    def InitFromAff4Object(self, approval_obj, approval_subject_obj=None):
        if not approval_subject_obj:
            approval_subject_obj = aff4.FACTORY.Open(
                approval_obj.Get(approval_obj.Schema.SUBJECT),
                aff4_type=aff4_grr.VFSGRRClient,
                token=approval_obj.token)
        self.subject = api_client.ApiClient().InitFromAff4Object(
            approval_subject_obj)

        return _InitApiApprovalFromAff4Object(self, approval_obj)