Search in sources :

Example 1 with Signature

use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.

the class PlainTextSignature method preModify.

@Override
public void preModify(CallbackContext context, String attrName, Object value, Map attrsToModify, Entry entry) throws ServiceException {
    SingleValueMod mod = singleValueMod(attrName, value);
    if (mod.unsetting())
        return;
    Account account;
    if (entry instanceof Account) {
        account = (Account) entry;
    } else if (entry instanceof Identity) {
        account = ((Identity) entry).getAccount();
    } else if (entry instanceof DataSource) {
        account = ((DataSource) entry).getAccount();
    } else {
        return;
    }
    Signature sig = Provisioning.getInstance().get(account, Key.SignatureBy.id, mod.value());
    if (sig == null) {
        throw ServiceException.INVALID_REQUEST("No such signature " + mod.value() + " for account " + account.getName(), null);
    }
    String sigAttr = SignatureUtil.mimeTypeToAttrName(MimeConstants.CT_TEXT_PLAIN);
    String plainSig = sig.getAttr(sigAttr, null);
    if (StringUtil.isNullOrEmpty(plainSig)) {
        throw ServiceException.INVALID_REQUEST("Signature " + mod.value() + " must have plain text content", null);
    }
}
Also used : Account(com.zimbra.cs.account.Account) Signature(com.zimbra.cs.account.Signature) Identity(com.zimbra.cs.account.Identity) DataSource(com.zimbra.cs.account.DataSource)

Example 2 with Signature

use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.

the class CalendarMailSender method getSignatureText.

private static String getSignatureText(Account acct, Identity identity, String signatureKey) throws ServiceException {
    String sigId = identity.getAttr(signatureKey);
    if (sigId == null)
        return null;
    Signature sig = Provisioning.getInstance().get(acct, Key.SignatureBy.id, sigId);
    if (sig == null) {
        ZimbraLog.calendar.warn("No such signature " + sigId + " for account " + acct.getName());
        return null;
    }
    String attr = SignatureUtil.mimeTypeToAttrName(MimeConstants.CT_TEXT_PLAIN);
    return sig.getAttr(attr, null);
}
Also used : Signature(com.zimbra.cs.account.Signature)

Example 3 with Signature

use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.

the class TestLdapProvSearchDirectory method accountsOnServerAndCosHasSubordinates.

@Test
public void accountsOnServerAndCosHasSubordinates() throws Exception {
    /*
         *  X.501: 14.4.4 Has Subordinates operational attribute
         *  is not supported in ubid InMemoryLdapServer
         */
    SKIP_FOR_INMEM_LDAP_SERVER(SkipTestReason.SUBORDINATES_OPERTIONAL_ATTRIBUTE);
    String COS_ID = prov.get(CosBy.name, Provisioning.DEFAULT_COS_NAME).getId();
    Account acct = createAccount(genAcctNameLocalPart());
    Signature sig1 = prov.createSignature(acct, "sig1", new HashMap<String, Object>());
    Signature sig2 = prov.createSignature(acct, "sig2", new HashMap<String, Object>());
    SearchAccountsOptions searchOpts = new SearchAccountsOptions();
    ZLdapFilter filter = ZLdapFilterFactory.getInstance().accountsOnServerAndCosHasSubordinates(prov.getLocalServer().getServiceHostname(), COS_ID);
    searchOpts.setFilter(filter);
    List<NamedEntry> accounts = prov.searchDirectory(searchOpts);
    Verify.verifyEquals(Lists.newArrayList(acct), accounts, false);
    deleteAccount(acct);
}
Also used : ZLdapFilter(com.zimbra.cs.ldap.ZLdapFilter) Account(com.zimbra.cs.account.Account) NamedEntry(com.zimbra.cs.account.NamedEntry) SearchAccountsOptions(com.zimbra.cs.account.SearchAccountsOptions) Signature(com.zimbra.cs.account.Signature) ProvTest(com.zimbra.qa.unittest.prov.ProvTest)

Example 4 with Signature

use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.

the class TestLdapProvRenameDomain method createSignatures.

private String[] createSignatures(Account acct) throws Exception {
    String[] sigIds = new String[NUM_SIGNATURES];
    for (int i = 0; i < NUM_SIGNATURES; i++) {
        Map<String, Object> attrs = new HashMap<String, Object>();
        attrs.put(Provisioning.A_zimbraPrefMailSignature, SIGNATURE_CONTENT(acct, i));
        Signature entry = prov.createSignature(acct, SIGNATURE_NAME(acct, i), attrs);
        sigIds[i] = entry.getId();
    }
    return sigIds;
}
Also used : HashMap(java.util.HashMap) Signature(com.zimbra.cs.account.Signature)

Example 5 with Signature

use of com.zimbra.cs.account.Signature in project zm-mailbox by Zimbra.

the class TestLdapProvSignature method createSignature.

private Signature createSignature(Account acct, String signatureName) throws Exception {
    Signature signature = prov.get(acct, Key.SignatureBy.name, signatureName);
    assertNull(signature);
    createSignatureRaw(acct, signatureName);
    signature = prov.get(acct, Key.SignatureBy.name, signatureName);
    assertNotNull(signature);
    assertEquals(signatureName, signature.getName());
    return signature;
}
Also used : Signature(com.zimbra.cs.account.Signature)

Aggregations

Signature (com.zimbra.cs.account.Signature)25 Account (com.zimbra.cs.account.Account)14 Element (com.zimbra.common.soap.Element)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)6 AccountServiceException (com.zimbra.cs.account.AccountServiceException)5 LdapSignature (com.zimbra.cs.account.ldap.entry.LdapSignature)5 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 ServiceException (com.zimbra.common.service.ServiceException)3 XMLElement (com.zimbra.common.soap.Element.XMLElement)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)3 Identity (com.zimbra.cs.account.Identity)2 Provisioning (com.zimbra.cs.account.Provisioning)2 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)2 ArrayList (java.util.ArrayList)2 DataSource (com.zimbra.cs.account.DataSource)1 DistributionList (com.zimbra.cs.account.DistributionList)1 NamedEntry (com.zimbra.cs.account.NamedEntry)1 SearchAccountsOptions (com.zimbra.cs.account.SearchAccountsOptions)1