use of com.zimbra.common.auth.ZAuthToken in project zm-mailbox by Zimbra.
the class LmcAdminAuthRequest method parseResponseXML.
protected LmcSoapResponse parseResponseXML(Element responseXML) throws ServiceException {
// get the auth token out, no default, must be present or a service exception is thrown
String authToken = DomUtil.getString(responseXML, AdminConstants.E_AUTH_TOKEN);
ZAuthToken zat = new ZAuthToken(null, authToken, null);
// get the session id, if not present, default to null
String sessionId = DomUtil.getString(responseXML, HeaderConstants.E_SESSION, null);
LmcAdminAuthResponse responseObj = new LmcAdminAuthResponse();
LmcSession sess = new LmcSession(zat, sessionId);
responseObj.setSession(sess);
return responseObj;
}
use of com.zimbra.common.auth.ZAuthToken in project zm-mailbox by Zimbra.
the class LmcAuthRequest method parseResponseXML.
protected LmcSoapResponse parseResponseXML(Element responseXML) throws ServiceException {
// get the auth token out, no default, must be present or a service exception is thrown
String authToken = DomUtil.getString(responseXML, AccountConstants.E_AUTH_TOKEN);
ZAuthToken zat = new ZAuthToken(null, authToken, null);
// get the session id, if not present, default to null
String sessionId = DomUtil.getString(responseXML, HeaderConstants.E_SESSION, null);
LmcAuthResponse responseObj = new LmcAuthResponse();
LmcSession sess = new LmcSession(zat, sessionId);
responseObj.setSession(sess);
return responseObj;
}
use of com.zimbra.common.auth.ZAuthToken in project zm-mailbox by Zimbra.
the class SoapCLI method auth.
/**
* Authenticates using the provided ZAuthToken
* @throws IOException
* @throws com.zimbra.common.soap.SoapFaultException
* @throws ServiceException
*/
protected LmcSession auth(ZAuthToken zAuthToken) throws SoapFaultException, IOException, ServiceException {
if (zAuthToken == null)
return auth();
URL url = new URL("https", mHost, mPort, AdminConstants.ADMIN_SERVICE_URI);
mServerUrl = url.toExternalForm();
SoapTransport trans = getTransport();
mAuth = false;
Element authReq = new Element.XMLElement(AdminConstants.AUTH_REQUEST);
zAuthToken.encodeAuthReq(authReq, true);
try {
Element authResp = trans.invokeWithoutSession(authReq);
ZAuthToken zat = new ZAuthToken(authResp.getElement(AdminConstants.E_AUTH_TOKEN), true);
trans.setAuthToken(zat);
mAuth = true;
return new LmcSession(zat, null);
} catch (UnknownHostException e) {
// UnknownHostException's error message is not clear; rethrow with a more descriptive message
throw new IOException("Unknown host: " + mHost);
}
}
use of com.zimbra.common.auth.ZAuthToken in project zm-mailbox by Zimbra.
the class SoapCLI method auth.
/**
* Authenticates using the username and password from the local config.
* @throws IOException
* @throws com.zimbra.common.soap.SoapFaultException
* @throws ServiceException
*/
protected LmcSession auth() throws SoapFaultException, IOException, ServiceException {
URL url = new URL("https", mHost, mPort, AdminConstants.ADMIN_SERVICE_URI);
mServerUrl = url.toExternalForm();
SoapTransport trans = getTransport();
mAuth = false;
Element authReq = new Element.XMLElement(AdminConstants.AUTH_REQUEST);
authReq.addAttribute(AdminConstants.E_NAME, mUser, Element.Disposition.CONTENT);
authReq.addAttribute(AdminConstants.E_PASSWORD, mPassword, Element.Disposition.CONTENT);
try {
Element authResp = trans.invokeWithoutSession(authReq);
String authToken = authResp.getAttribute(AdminConstants.E_AUTH_TOKEN);
ZAuthToken zat = new ZAuthToken(null, authToken, null);
trans.setAuthToken(authToken);
mAuth = true;
return new LmcSession(zat, null);
} catch (UnknownHostException e) {
// UnknownHostException's error message is not clear; rethrow with a more descriptive message
throw new IOException("Unknown host: " + mHost);
}
}
use of com.zimbra.common.auth.ZAuthToken in project zm-mailbox by Zimbra.
the class Mailbox method refreshMountpoint.
/**
* Updates the remote owner and item id stored in the mountpoint to match the current location of the
* target folder. The target folder is identified by the remote UUID stored in the mountpoint's metadata.
* @param octxt
* @param mountpointId item id of the Mountpoint
* @return
* @throws ServiceException
*/
public Mountpoint refreshMountpoint(OperationContext octxt, int mountpointId) throws ServiceException {
Mountpoint mp = getMountpointById(octxt, mountpointId);
Provisioning prov = Provisioning.getInstance();
ShareLocator shloc = prov.getShareLocatorById(mp.getRemoteUuid());
if (shloc == null || mp.getOwnerId().equalsIgnoreCase(shloc.getShareOwnerAccountId())) {
// Share apparently did not move.
return mp;
}
// Look up remote folder by UUID to discover the new numeric id.
Account shareOwner = Provisioning.getInstance().get(Key.AccountBy.id, shloc.getShareOwnerAccountId());
AuthToken at = AuthToken.getCsrfUnsecuredAuthToken(octxt.getAuthToken());
String pxyAuthToken = Provisioning.onLocalServer(shareOwner) ? null : at.getProxyAuthToken();
ZAuthToken zat = null;
if (pxyAuthToken == null) {
zat = at.toZAuthToken();
zat.resetProxyAuthToken();
} else {
zat = new ZAuthToken(pxyAuthToken);
}
ZMailbox.Options zoptions = new ZMailbox.Options(zat, AccountUtil.getSoapUri(shareOwner));
zoptions.setNoSession(true);
zoptions.setTargetAccount(shareOwner.getId());
zoptions.setTargetAccountBy(Key.AccountBy.id);
ZMailbox zmbx = ZMailbox.getMailbox(zoptions);
ZFolder zfolder = zmbx.getFolderByUuid(shloc.getUuid());
if (zfolder != null) {
ItemId fid = new ItemId(zfolder.getId(), shareOwner.getId());
return refreshMountpoint(octxt, mountpointId, shareOwner.getId(), fid.getId());
} else {
return null;
}
}
Aggregations