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); }
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); } }
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(); }
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); }
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; }
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); }
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); } }
public String toString() { return String.format("[ZGrant %s %s %s]", mGranteeType.name(), mGranteeName, mPermissions); }