Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public class ReportTemplateEditPane extends TemplateTypeEditPane implements HasE
private TextItem jasperDataSourceAttributeNameField;
/** Jasper PasswordAttributeName */
private TextItem jasperPasswordAttributeNameField;
/** Jasper AdminPasswordAttributeName */
private TextItem jasperAdminPasswordAttributeNameField;

/** Poi PasswordAttributeName */
private DynamicForm poiPasswordAttributeNameForm;
Expand Down Expand Up @@ -226,8 +228,10 @@ public void onSubmit(SubmitEvent event) {
jasperDataSourceAttributeNameField.setTitle("DataSource AttributeName");
jasperPasswordAttributeNameField = new MtpTextItem();
jasperPasswordAttributeNameField.setTitle("Password AttributeName");
jasperAdminPasswordAttributeNameField = new MtpTextItem();
jasperAdminPasswordAttributeNameField.setTitle("Admin Password AttributeName");

jasperAttributeForm.setItems(jasperDataSourceAttributeNameField, jasperPasswordAttributeNameField);
jasperAttributeForm.setItems(jasperDataSourceAttributeNameField, jasperPasswordAttributeNameField, jasperAdminPasswordAttributeNameField);

//Jasper ParamMap部分
jasperParamMapPane = new JasperReportParamMapGridPane();
Expand Down Expand Up @@ -329,6 +333,8 @@ public TemplateDefinition getEditDefinition(TemplateDefinition definition) {

//PasswordAttributeName
jasperTemplate.setPasswordAttributeName(SmartGWTUtil.getStringValue(jasperPasswordAttributeNameField, true));
//AdminPasswordAttributeName
jasperTemplate.setAdminPasswordAttributeName(SmartGWTUtil.getStringValue(jasperAdminPasswordAttributeNameField, true));
//パラメータマッピング設定
jasperTemplate.setParamMap(jasperParamMapPane.getParamMap());

Expand Down Expand Up @@ -447,6 +453,9 @@ private void addReportTypeParameter(ReportType type, String prefix) {
if (!SmartGWTUtil.isEmpty(jasRepo.getPasswordAttributeName())) {
addUploadParameter(prefix + ReportTemplateUploadProperty.JASPER_PASSWORD_ATTRIBUTE_NAME, jasRepo.getPasswordAttributeName());
}
if (!SmartGWTUtil.isEmpty(jasRepo.getAdminPasswordAttributeName())) {
addUploadParameter(prefix + ReportTemplateUploadProperty.JASPER_ADMIN_PASSWORD_ATTRIBUTE_NAME, jasRepo.getAdminPasswordAttributeName());
}

} else if (type instanceof PoiReportType) {
addUploadParameter(prefix + ReportTemplateUploadProperty.REPORT_TYPE, PoiReportType.class.getName());
Expand Down Expand Up @@ -557,6 +566,7 @@ private void setReportType(ReportType type) {
jasperParamMapPane.setParamMap(jasRepo.getParamMap());
jasperDataSourceAttributeNameField.setValue(jasRepo.getDataSourceAttributeName());
jasperPasswordAttributeNameField.setValue(jasRepo.getPasswordAttributeName());
jasperAdminPasswordAttributeNameField.setValue(jasRepo.getAdminPasswordAttributeName());
removeMembers(poiPasswordAttributeNameForm, reportOutPane);
removeMembers(jxlsPasswordAttributeNameForm, jxlsContextParamMapPane, jxlsReportOutputLogicPane);
beforeReportType = JasperReportType.class.getName();
Expand Down Expand Up @@ -653,6 +663,8 @@ public LocalizedReportDefinition getEditLocalizedReportDefinition(LocalizedRepor
jasperTemplate.setDataSourceAttributeName(SmartGWTUtil.getStringValue(jasperDataSourceAttributeNameField, true));
//PasswordAttributeName
jasperTemplate.setPasswordAttributeName(SmartGWTUtil.getStringValue(jasperPasswordAttributeNameField, true));
//AdminPasswordAttributeName
jasperTemplate.setAdminPasswordAttributeName(SmartGWTUtil.getStringValue(jasperAdminPasswordAttributeNameField, true));

definition.setReportType(jasperTemplate);
} else if (JxlsReportType.class.getName().equals(reportTypeField.getValueAsString())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ private ReportType createReportType(HashMap<String, Object> args) {
if (StringUtil.isNotEmpty(passwordAttributeName)) {
jasperTemplate.setPasswordAttributeName(passwordAttributeName);
}
String adminPasswordAttributeName = (String) args.get(ReportTemplateUploadProperty.JASPER_ADMIN_PASSWORD_ATTRIBUTE_NAME);
if (StringUtil.isNotEmpty(adminPasswordAttributeName)) {
jasperTemplate.setAdminPasswordAttributeName(adminPasswordAttributeName);
}

return jasperTemplate;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public interface ReportTemplateUploadProperty extends UploadProperty {
public static final String JASPER_DATASOURCE_ATTRIBUTE_NAME = "jasperDataSourceAttributeName";
/** Jasper PasswordAttributeName */
public static final String JASPER_PASSWORD_ATTRIBUTE_NAME = "jasperPasswordAttributeName";
/** Jasper AdminPasswordAttributeName */
public static final String JASPER_ADMIN_PASSWORD_ATTRIBUTE_NAME = "jasperAdminPasswordAttributeName";

/** Poiレポート出力ロジック形式 */
public static final String POI_LOGIC_NAME = "poiLogicName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.List;

import org.iplass.mtp.ManagerLocator;
import org.iplass.mtp.auth.AuthContext;
import org.iplass.mtp.command.RequestContext;
import org.iplass.mtp.impl.core.ExecuteContext;
import org.iplass.mtp.impl.web.WebRequestStack;
Expand Down Expand Up @@ -157,7 +158,13 @@ public void exportReport( WebRequestStack context, ReportingOutputModel model )
}

String password = null;
if (StringUtil.isNotEmpty(jasperModel.getPasswordAttributeName())) {
// 管理者フラグをチェックし、管理者の場合は管理者用パスワード、それ以外はユーザー用パスワードを使用
boolean isAdmin = AuthContext.getCurrentContext().getUser().isAdmin();
if (isAdmin && StringUtil.isNotEmpty(jasperModel.getAdminPasswordAttributeName())) {
password = (String)getAttribute(request, jasperModel.getAdminPasswordAttributeName());
}
// 管理者用パスワードが取得できなかった場合はユーザー用パスワードにフォールバック
if (StringUtil.isEmpty(password) && StringUtil.isNotEmpty(jasperModel.getPasswordAttributeName())) {
password = (String)getAttribute(request, jasperModel.getPasswordAttributeName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class JasperReportingOutputModel implements ReportingOutputModel{
private MetaReportParamMap[] maps;
private String dataSourceAttributeName;
private String passwordAttributeName;
private String adminPasswordAttributeName;

private final String JASPER_STR = "jasper";
private final String JRXML_STR = "jrxml";
Expand Down Expand Up @@ -107,4 +108,12 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getAdminPasswordAttributeName() {
return adminPasswordAttributeName;
}

public void setAdminPasswordAttributeName(String adminPasswordAttributeName) {
this.adminPasswordAttributeName = adminPasswordAttributeName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class MetaJasperReportType extends MetaReportType {
/** パスワードAttribute名 */
private String passwordAttributeName;

/** 管理者用パスワードAttribute名 */
private String adminPasswordAttributeName;

public MetaReportParamMap[] getParamMap() {
return paramMap;
}
Expand All @@ -65,6 +68,14 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getAdminPasswordAttributeName() {
return adminPasswordAttributeName;
}

public void setAdminPasswordAttributeName(String adminPasswordAttributeName) {
this.adminPasswordAttributeName = adminPasswordAttributeName;
}

@Override
public void applyConfig(ReportType reportType) {
JasperReportType def = (JasperReportType)reportType;
Expand All @@ -85,6 +96,8 @@ public void applyConfig(ReportType reportType) {
dataSourceAttributeName = def.getDataSourceAttributeName();

passwordAttributeName = def.getPasswordAttributeName();

adminPasswordAttributeName = def.getAdminPasswordAttributeName();
}

@Override
Expand All @@ -104,6 +117,7 @@ public ReportType currentConfig() {

definition.setDataSourceAttributeName(dataSourceAttributeName);
definition.setPasswordAttributeName(passwordAttributeName);
definition.setAdminPasswordAttributeName(adminPasswordAttributeName);

return definition;
}
Expand Down Expand Up @@ -136,6 +150,7 @@ public void setParam(ReportingOutputModel createOutputModel) {
model.setMaps(paramMap);
}
model.setPasswordAttributeName(passwordAttributeName);
model.setAdminPasswordAttributeName(adminPasswordAttributeName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class JasperReportType extends ReportType {
/** パスワードAttribute名 */
private String passwordAttributeName;

/** 管理者用パスワードAttribute名 */
private String adminPasswordAttributeName;

public ReportParamMapDefinition[] getParamMap() {
return paramMap;
}
Expand All @@ -68,4 +71,12 @@ public void setPasswordAttributeName(String passwordAttributeName) {
this.passwordAttributeName = passwordAttributeName;
}

public String getAdminPasswordAttributeName() {
return adminPasswordAttributeName;
}

public void setAdminPasswordAttributeName(String adminPasswordAttributeName) {
this.adminPasswordAttributeName = adminPasswordAttributeName;
}

}
Loading