Search in sources :

Example 6 with AuthenticationException

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());
    }
}
Also used : ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) AuthenticationException(com.twinsoft.convertigo.engine.AuthenticationException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 7 with AuthenticationException

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);
    }
}
Also used : ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) JSONObject(org.codehaus.jettison.json.JSONObject) AuthenticationException(com.twinsoft.convertigo.engine.AuthenticationException) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element)

Aggregations

AuthenticationException (com.twinsoft.convertigo.engine.AuthenticationException)7 ServiceException (com.twinsoft.convertigo.engine.admin.services.ServiceException)5 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)4 Element (org.w3c.dom.Element)4 IOException (java.io.IOException)2 JSONObject (org.codehaus.jettison.json.JSONObject)2 Role (com.twinsoft.convertigo.engine.AuthenticatedSessionManager.Role)1 EngineException (com.twinsoft.convertigo.engine.EngineException)1 PropertyName (com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName)1 Service (com.twinsoft.convertigo.engine.admin.services.Service)1 ServiceDefinition (com.twinsoft.convertigo.engine.admin.services.at.ServiceDefinition)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 OutputStream (java.io.OutputStream)1 InvalidParameterException (java.security.InvalidParameterException)1 ServletException (javax.servlet.ServletException)1 HttpMethod (org.apache.commons.httpclient.HttpMethod)1 Document (org.w3c.dom.Document)1 NodeList (org.w3c.dom.NodeList)1