Search in sources :

Example 6 with AuthorityException

use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.

the class ServiceAuthorityCheckAspect method logicServiceProcess.

@Around(AspectConstants.LOGIC_SERVICE_PACKAGE)
public Object logicServiceProcess(ProceedingJoinPoint pjp) throws AuthorityException, ServiceException, Throwable {
    MethodSignature signature = (MethodSignature) pjp.getSignature();
    Annotation[] annotations = pjp.getTarget().getClass().getAnnotations();
    String serviceId = AspectConstants.getServiceId(annotations);
    Subject subject = SecurityUtils.getSubject();
    Method method = signature.getMethod();
    if (subject.hasRole(Constants.SUPER_ROLE_ALL) || subject.hasRole(Constants.SUPER_ROLE_ADMIN)) {
        SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
        return pjp.proceed();
    }
    if (StringUtils.isBlank(serviceId)) {
        // 沒有 service id 無法判斷檢查 
        SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
        return pjp.proceed();
    }
    if (!this.isServiceAuthorityCheck(annotations)) {
        // 沒有 ServiceAuthority 或 check=false 就不用檢查了 
        SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
        return pjp.proceed();
    }
    Annotation[] methodAnnotations = method.getAnnotations();
    if (this.isServiceMethodAuthority(serviceId, methodAnnotations, subject)) {
        SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), true);
        return pjp.proceed();
    }
    logger.warn("[decline] user[" + subject.getPrincipal() + "] " + pjp.getTarget().getClass().getName() + " - " + signature.getMethod().getName());
    SysEventLogSupport.log((String) subject.getPrincipal(), Constants.getSystem(), this.getEventId(serviceId, method.getName()), false);
    throw new AuthorityException(SysMessageUtil.get(GreenStepSysMsgConstants.NO_PERMISSION));
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Subject(org.apache.shiro.subject.Subject) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) Around(org.aspectj.lang.annotation.Around)

Example 7 with AuthorityException

use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.

the class AnalyticsProcessAction method exportExcel.

private void exportExcel(File catalogFile) throws ControllerException, AuthorityException, ServiceException, Exception {
    this.oid = "";
    this.checkFields("query");
    boolean showDimensionTitle = true;
    boolean showParentMembers = true;
    if (!"true".equals(this.getFields().get("showDimensionTitle"))) {
        showDimensionTitle = false;
    }
    if (!"true".equals(this.getFields().get("showParentMembers"))) {
        showParentMembers = false;
    }
    OlapCatalogVO catalog = this.loadOlapCatalog(this.getFields().get("catalogOid"));
    OlapConfVO config = this.loadOlapConfig(this.getFields().get("configOid"));
    catalogFile = OlapUtils.writeCatalogContentToFile(catalog.getId() + "_" + super.getAccountOid(), new String(catalog.getContent(), Constants.BASE_ENCODING));
    String mondrianUrl = OlapUtils.getMondrianUrl(config.getJdbcUrl(), config.getJdbcDrivers(), catalogFile.getPath());
    File file = null;
    try {
        file = Pivot4JUtils.exportExcelFile(mondrianUrl, this.getFields().get("expression"), showDimensionTitle, showParentMembers);
        this.oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, file, "analytics-export.xlsx");
    } catch (Exception e) {
        throw e;
    } finally {
        file = null;
    }
    this.message = this.getText("MESSAGE.QCHARTS_PROG002D0002Q_msg1") + super.getHtmlBr();
    this.success = IS_YES;
}
Also used : OlapConfVO(com.netsteadfast.greenstep.vo.OlapConfVO) OlapCatalogVO(com.netsteadfast.greenstep.vo.OlapCatalogVO) File(java.io.File) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException)

Example 8 with AuthorityException

use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.

the class AnalyticsProcessAction method rendererHtmlExport.

private void rendererHtmlExport(File catalogFile) throws ControllerException, AuthorityException, ServiceException, Exception {
    this.rendererHtml(catalogFile);
    String datas = Pivot4JUtils.wrapRendererHtml(this.content);
    File file = null;
    try {
        file = new File(Constants.getWorkTmpDir() + "/" + super.getUuid() + ".htm");
        FileUtils.writeStringToFile(file, datas, Constants.BASE_ENCODING);
        this.oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, file, "analytics-export.htm");
    } catch (Exception e) {
        throw e;
    } finally {
        file = null;
    }
}
Also used : File(java.io.File) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException)

Example 9 with AuthorityException

use of com.netsteadfast.greenstep.base.exception.AuthorityException in project bamboobsc by billchen198318.

the class AnalyticsProcessAction method doHtmlExport.

/**
	 * qcharts.analyticsHtmlExportAction.action
	 * 
	 * @return
	 * @throws Exception
	 */
@JSON(serialize = false)
@ControllerMethodAuthority(programId = "QCHARTS_PROG002D0002Q")
public String doHtmlExport() throws Exception {
    File catalogFile = null;
    try {
        if (!this.allowJob()) {
            this.message = this.getNoAllowMessage();
            return SUCCESS;
        }
        this.rendererHtmlExport(catalogFile);
    } catch (AuthorityException | ControllerException | ServiceException e) {
        this.message = e.getMessage().toString();
    } catch (Exception e) {
        this.message = this.logException(e);
        this.success = IS_EXCEPTION;
    }
    catalogFile = null;
    return SUCCESS;
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) File(java.io.File) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerMethodAuthority(com.netsteadfast.greenstep.base.model.ControllerMethodAuthority) JSON(org.apache.struts2.json.annotations.JSON)

Aggregations

AuthorityException (com.netsteadfast.greenstep.base.exception.AuthorityException)9 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)8 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)7 File (java.io.File)5 JSON (org.apache.struts2.json.annotations.JSON)4 ControllerMethodAuthority (com.netsteadfast.greenstep.base.model.ControllerMethodAuthority)3 Annotation (java.lang.annotation.Annotation)2 Method (java.lang.reflect.Method)2 MethodSignature (org.aspectj.lang.reflect.MethodSignature)2 HessianProxyFactory (com.caucho.hessian.client.HessianProxyFactory)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)1 SystemForm (com.netsteadfast.greenstep.base.model.SystemForm)1 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 GreenStepHessianProxyFactory (com.netsteadfast.greenstep.sys.GreenStepHessianProxyFactory)1 OlapCatalogVO (com.netsteadfast.greenstep.vo.OlapCatalogVO)1 OlapConfVO (com.netsteadfast.greenstep.vo.OlapConfVO)1 SysFormMethodVO (com.netsteadfast.greenstep.vo.SysFormMethodVO)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Subject (org.apache.shiro.subject.Subject)1