use of com.twinsoft.convertigo.engine.AuthenticationException in project convertigo by convertigo.
the class GetSourcePackage method writeResponseResult.
@Override
protected void writeResponseResult(HttpServletRequest request, HttpServletResponse response) throws Exception {
MobileResourceHelper mobileResourceHelper = new MobileResourceHelper(request, "mobile/www");
if (mobileResourceHelper.mobileApplication == null) {
throw new ServiceException("no such mobile application");
} else {
boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
if (!bTpPrivateRole && mobileResourceHelper.mobileApplication.getAccessibility() == Accessibility.Private) {
throw new AuthenticationException("Authentication failure: user has not sufficient rights!");
}
}
File mobileArchiveFile = mobileResourceHelper.makeZipPackage();
try (FileInputStream archiveInputStream = new FileInputStream(mobileArchiveFile)) {
HeaderName.ContentDisposition.setHeader(response, "attachment; filename=\"" + mobileArchiveFile.getName() + "\"");
HeaderName.ContentLength.setHeader(response, Long.toString(mobileArchiveFile.length()));
response.setContentType(MimeType.OctetStream.value());
IOUtils.copy(archiveInputStream, response.getOutputStream());
}
}
use of com.twinsoft.convertigo.engine.AuthenticationException in project convertigo by convertigo.
the class LaunchBuild method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
synchronized (buildLock) {
final MobileResourceHelper mobileResourceHelper = new MobileResourceHelper(request, "mobile/www");
MobileApplication mobileApplication = mobileResourceHelper.mobileApplication;
if (mobileApplication == null) {
throw new ServiceException("no such mobile application");
} else {
boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
if (!bTpPrivateRole && mobileApplication.getAccessibility() == Accessibility.Private) {
throw new AuthenticationException("Authentication failure: user has not sufficient rights!");
}
}
String sResult = perform(mobileResourceHelper, request);
JSONObject jsonObject = new JSONObject(sResult);
Element statusElement = document.createElement("application");
statusElement.setAttribute("id", jsonObject.getString("id"));
document.getDocumentElement().appendChild(statusElement);
}
}
Aggregations