use of com.zimbra.soap.admin.message.CreateAccountRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method createAdminConsoleStyleDomainAdmin.
public String createAdminConsoleStyleDomainAdmin(String domAdminName) throws ServiceException {
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "accountListView"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "downloadsView"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "DLListView"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "aliasListView"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "resourceListView"));
attrs.add(new Attr(Provisioning.A_zimbraAdminConsoleUIComponents, "saveSearch"));
CreateAccountRequest caReq = new CreateAccountRequest(domAdminName, TestUtil.DEFAULT_PASSWORD, attrs);
CreateAccountResponse caResp = adminSoapProv.invokeJaxb(caReq);
assertNotNull("CreateAccountResponse for " + domAdminName, caResp);
grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, domAdminName, RightConsts.RT_domainAdminConsoleRights);
grantRight(adminSoapProv, TargetType.global, "globalacltarget", domAdminName, RightConsts.RT_domainAdminZimletRights);
grantRight(adminSoapProv, TargetType.global, "globalacltarget", domAdminName, RightConsts.RT_adminLoginCalendarResourceAs);
adminSoapProv.flushCache(CacheEntryType.acl, null);
return caResp.getAccount().getId();
}
use of com.zimbra.soap.admin.message.CreateAccountRequest in project zm-mailbox by Zimbra.
the class TestCookieReuse method testUnauthorizedAdminPostWithCsrf.
/**
* Verify that we CANNOT make an admin POST request by reusing a valid csrf-enabled cookie without a csrf token
*/
@Test
public void testUnauthorizedAdminPostWithCsrf() throws Exception {
AuthToken at = AuthProvider.getAdminAuthToken();
at.setCsrfTokenEnabled(true);
SoapTransport transport = TestUtil.getAdminSoapTransport();
transport.setAuthToken(at.getEncoded());
Map<String, Object> attrs = null;
CreateAccountRequest request = new CreateAccountRequest(UNAUTHORIZED_USER, "test123", attrs);
try {
transport.invoke(JaxbUtil.jaxbToElement(request));
} catch (ServiceException e) {
Assert.assertEquals("should be catching AUTH EXPIRED here", ServiceException.AUTH_REQUIRED, e.getCode());
return;
}
Assert.fail("should have caught an exception");
}
use of com.zimbra.soap.admin.message.CreateAccountRequest in project zm-mailbox by Zimbra.
the class JaxbToElementTest method jaxbSubclassFixupTest.
/**
* Check that @{link JaxbUtil.elementToJaxb} will accept XML where
* JAXB expects various attributes that have been specified as elements.
* Ensure that attributes in elements of superclasses are handled
* In this case:
* <a><n>attrName1</n></a>
* should be recognised as meaning:
* <a n="attrName1"></a>
* @throws Exception
*/
@Test
public void jaxbSubclassFixupTest() throws Exception {
Element rootElem = Element.XMLElement.mFactory.createElement(AdminConstants.CREATE_ACCOUNT_REQUEST);
// JAXB Attribute E_NAME
rootElem.addNonUniqueElement(AdminConstants.E_NAME).addText("acctName");
// JAXB Attribute E_PASSWORD
rootElem.addNonUniqueElement(AdminConstants.E_PASSWORD).addText("AcctPassword");
// JAXB Element E_A ---> Attr (actually a List)
Element a1 = rootElem.addNonUniqueElement(AdminConstants.E_A);
// JAXB Attribute A_N
a1.addNonUniqueElement(AdminConstants.A_N).addText("attrName1");
// value can't be set when we've specified an attribute as an element
CreateAccountRequest req = JaxbUtil.elementToJaxb(rootElem);
Assert.assertEquals("Account name", "acctName", req.getName());
Assert.assertEquals("Account Password", "AcctPassword", req.getPassword());
List<Attr> attrs = req.getAttrs();
Assert.assertEquals("Number of attrs", 1, attrs.size());
Assert.assertEquals("attr 1 name", "attrName1", attrs.get(0).getKey());
Assert.assertEquals("attr 1 value", "", attrs.get(0).getValue());
}
use of com.zimbra.soap.admin.message.CreateAccountRequest in project zm-mailbox by Zimbra.
the class CreateAccount method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Provisioning prov = Provisioning.getInstance();
CreateAccountRequest req = zsc.elementToJaxb(request);
String name = req.getName().toLowerCase();
Map<String, Object> attrs = req.getAttrsAsOldMultimap(true);
checkDomainRightByEmail(zsc, name, Admin.R_createAccount);
checkSetAttrsOnCreate(zsc, TargetType.account, name, attrs);
checkCos(zsc, attrs);
Account account = prov.createAccount(name, req.getPassword(), attrs);
ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateAccount", "name", name }, attrs));
Element response = zsc.createElement(AdminConstants.CREATE_ACCOUNT_RESPONSE);
ToXML.encodeAccount(response, account);
return response;
}
use of com.zimbra.soap.admin.message.CreateAccountRequest in project zm-mailbox by Zimbra.
the class TestDomainAdmin method testViaGroupDelegatedAdminAssignSendToDistList.
/**
* Test that delegated admin with adminConsoleDLACLTabRights can grant sendToDistList right
* @throws Exception
*/
@Test
public void testViaGroupDelegatedAdminAssignSendToDistList() throws Exception {
String domAdminGroupId = createAdminConsoleStyleDomainAdminGroup(DOMADMINGROUP);
CreateAccountResponse caResp;
List<Attr> attrs = Lists.newArrayList();
attrs.add(new Attr(Provisioning.A_zimbraIsDelegatedAdminAccount, "TRUE"));
CreateAccountRequest caReq = new CreateAccountRequest(DOMADMIN, TestUtil.DEFAULT_PASSWORD, attrs);
caResp = adminSoapProv.invokeJaxb(caReq);
assertNotNull("CreateAccountResponse for " + DOMADMIN + " Admin", caResp);
AddDistributionListMemberResponse adlmResp;
adlmResp = adminSoapProv.invokeJaxb(new AddDistributionListMemberRequest(domAdminGroupId, Lists.newArrayList(DOMADMIN)));
assertNotNull("AddDistributionListMemberResponse for " + DOMADMIN + " Admin", adlmResp);
adminSoapProv.createAccount(TARGET_ACCT, TestUtil.DEFAULT_PASSWORD, null);
SoapProvisioning domAdminSoapProv = getSoapProvisioning(DOMADMIN, TestUtil.DEFAULT_PASSWORD);
CreateDistributionListResponse cdlResp;
cdlResp = domAdminSoapProv.invokeJaxb(new CreateDistributionListRequest(TARGET_DL));
assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
cdlResp = adminSoapProv.invokeJaxb(new CreateDistributionListRequest(DIFF_DL));
assertNotNull("CreateDistributionListResponse for " + TARGET_DL + " simple as domAdmin", cdlResp);
failToGrantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
grantRight(adminSoapProv, TargetType.domain, ADMINISTERED_DOMAIN, GranteeType.grp, DOMADMINGROUP, RightConsts.RT_adminConsoleDLACLTabRights);
grantRight(domAdminSoapProv, TargetType.dl, TARGET_DL, TARGET_ACCT, RightConsts.RT_sendToDistList);
/* Check that doesn't allow it for a dl in a different domain */
failToGrantRight(domAdminSoapProv, TargetType.dl, DIFF_DL, TARGET_ACCT, RightConsts.RT_sendToDistList, "permission denied: insufficient right to grant 'sendToDistList' right");
}
Aggregations