Exemplo n.º 1
0
 public static GranteeType fromJaxb(com.zimbra.soap.type.GrantGranteeType jaxbGT) {
   for (GranteeType gt : GranteeType.values()) {
     if (gt.toJaxb() == jaxbGT) {
       return gt;
     }
   }
   throw new IllegalArgumentException("Unrecognised GranteeType:" + jaxbGT);
 }
Exemplo n.º 2
0
 public static GranteeType fromString(String s) throws ServiceException {
   try {
     return GranteeType.valueOf(s);
   } catch (IllegalArgumentException e) {
     throw ZClientException.CLIENT_ERROR(
         "invalid grantee: " + s + ", valid values: " + Arrays.asList(GranteeType.values()), e);
   }
 }
Exemplo n.º 3
0
 public ZGrant(Grant grant) throws ServiceException {
   mPermissions = grant.getPerm();
   mGranteeName = grant.getGranteeName();
   mGranteeId = grant.getGranteeId();
   mGranteeType = GranteeType.fromString(grant.getGranteeType().toString());
   if (mGranteeType == GranteeType.key) mArgs = grant.getAccessKey();
   else mArgs = grant.getGuestPassword();
 }
Exemplo n.º 4
0
 public ZAce(Element e) throws ServiceException {
   mRight = e.getAttribute(MailConstants.A_RIGHT);
   mDeny = e.getAttributeBool(MailConstants.A_DENY, false);
   mGranteeName = e.getAttribute(MailConstants.A_DISPLAY, null);
   mGranteeId = e.getAttribute(MailConstants.A_ZIMBRA_ID, null);
   mGranteeType = GranteeType.fromString(e.getAttribute(MailConstants.A_GRANT_TYPE));
   mSecret = e.getAttribute(MailConstants.A_PASSWORD, null);
 }
Exemplo n.º 5
0
 public ZJSONObject toZJSONObject() throws JSONException {
   ZJSONObject jo = new ZJSONObject();
   jo.put("type", mGranteeType.name());
   jo.put("name", mGranteeName);
   jo.put("id", mGranteeId);
   jo.put("permissions", mPermissions);
   jo.put("args", mArgs);
   return jo;
 }
Exemplo n.º 6
0
  public ZGrant(Element e) throws ServiceException {
    mPermissions = e.getAttribute(MailConstants.A_RIGHTS);
    mGranteeName = e.getAttribute(MailConstants.A_DISPLAY, null);
    mGranteeId = e.getAttribute(MailConstants.A_ZIMBRA_ID, null);
    mGranteeType = GranteeType.fromString(e.getAttribute(MailConstants.A_GRANT_TYPE));

    if (mGranteeType == GranteeType.key) mArgs = e.getAttribute(MailConstants.A_ACCESSKEY, null);
    else mArgs = e.getAttribute(MailConstants.A_PASSWORD, null);
  }
Exemplo n.º 7
0
  public void toElement(Element parent) {
    Element grant = parent.addElement(MailConstants.E_GRANT);
    if (mPermissions != null) grant.addAttribute(MailConstants.A_RIGHTS, mPermissions);

    grant.addAttribute(MailConstants.A_GRANT_TYPE, mGranteeType.name());

    if (mGranteeId != null) grant.addAttribute(MailConstants.A_ZIMBRA_ID, mGranteeId);

    if (mGranteeName != null) grant.addAttribute(MailConstants.A_DISPLAY, mGranteeName);

    if (mArgs != null && mArgs.length() > 0) {
      if (mGranteeType == GranteeType.key) grant.addAttribute(MailConstants.A_ACCESSKEY, mArgs);
      else grant.addAttribute(MailConstants.A_ARGS, mArgs);
    }
  }
Exemplo n.º 8
0
 public String toString() {
   return String.format("[ZGrant %s %s %s]", mGranteeType.name(), mGranteeName, mPermissions);
 }