diff options
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data')
20 files changed, 5645 insertions, 5410 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java index ca0bb8ac4..a45bec654 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/FormularCustomization.java @@ -34,8 +34,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.auth.frontend.utils.FormBuildUtils; import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; @@ -52,821 +50,815 @@ import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.validation.FormularCustomizationValitator; import at.gv.egovernment.moa.id.configuration.validation.oa.OAFileUploadValidation; import at.gv.egovernment.moa.util.MiscUtil; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class FormularCustomization implements IOnlineApplicationData { - private static final Logger log = Logger.getLogger(FormularCustomization.class); - - private boolean showMandateLoginButton = true; - private boolean onlyMandateAllowed = false; - - private String fontType = null; - - private String frontColor = null; - private String backGroundColor = null; - private String header_FrontColor = null; - private String header_BackGroundColor = null; - private String header_text = null; - private String button_BackGroundColor = null; - private String button_BackGroundColorFocus = null; - private String button_FrontColor = null; - private String applet_height = null; - private String applet_width = null; - - private Map<String, String> map = null; - - private String appletRedirectTarget = null; - public static List<String> appletRedirectTargetList = null; - - public static List<String> fontTypeList = null; - public String fontTypeListValue = null; - - private Map<String, byte[]> sendAssertionForm = new HashMap<String, byte[]>(); - private Map<String, byte[]> bkuSelectionForm = new HashMap<String, byte[]>(); - - private List<File> bkuSelectionFileUpload = null; - private List<String> bkuSelectionFileUploadContentType = null; - private List<String> bkuSelectionFileUploadFileName = new ArrayList<String>(); - private boolean deleteBKUTemplate = false; - - private List<File> sendAssertionFileUpload = null; - private List<String> sendAssertionFileUploadContentType = null; - private List<String> sendAssertionFileUploadFileName = new ArrayList<String>();; - private boolean deleteSendAssertionTemplate = false; - - private String aditionalAuthBlockText = null; - private boolean isHideBPKAuthBlock = false; - - private String saml2PostBindingTemplate = null; - private String mandateServiceSelectionTemplate = null; - - public FormularCustomization() { - new FormularCustomization(null); - } - - public FormularCustomization(Map<String, String> map) { - appletRedirectTargetList = Arrays.asList("","_blank","_self","_parent","_top"); - fontTypeList = Arrays.asList("","Verdana","Geneva","Arial","Helvetica","sans-serif","Times New Roman"); - Collections.sort(fontTypeList); - - if (map == null) - this.map = FormBuildUtils.getDefaultMap(); - else - this.map = map; - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OAFormularCustomization"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA auth = dbOA.getAuthComponentOA(); - - mandateServiceSelectionTemplate = dbOA.getMandateServiceSelectionTemplateURL(); - saml2PostBindingTemplate = dbOA.getSaml2PostBindingTemplateURL(); - - if (dbOA.getAuthComponentOA() != null) - isHideBPKAuthBlock = dbOA.isRemoveBPKFromAuthBlock(); - - if (auth != null) { - TemplatesType templates = auth.getTemplates(); - - if (templates != null) { - aditionalAuthBlockText = templates.getAditionalAuthBlockText(); - - TransformsInfoType bkuSelectTemplate = templates.getBKUSelectionTemplate(); - if (bkuSelectTemplate != null - && MiscUtil.isNotEmpty(bkuSelectTemplate.getFilename()) - && !bkuSelectTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) - && !bkuSelectTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { - bkuSelectionFileUploadFileName.add(bkuSelectTemplate.getFilename()); - } - - TransformsInfoType sendAssertionTemplate = templates.getSendAssertionTemplate(); - if (sendAssertionTemplate != null - && MiscUtil.isNotEmpty(sendAssertionTemplate.getFilename()) - && !sendAssertionTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) - && !sendAssertionTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { - sendAssertionFileUploadFileName.add(sendAssertionTemplate.getFilename()); - } - - BKUSelectionCustomizationType formcustom = templates.getBKUSelectionCustomization(); - if (formcustom != null) { - - if (formcustom.isMandateLoginButton() != null) { - showMandateLoginButton = formcustom.isMandateLoginButton(); - } - - if (formcustom.isOnlyMandateLoginAllowed() != null) { - onlyMandateAllowed = formcustom.isOnlyMandateLoginAllowed(); - } - - if (formcustom.getAppletHeight() != null) { - applet_height = formcustom.getAppletHeight(); - } - - if (formcustom.getAppletHeight() != null) { - applet_width = formcustom.getAppletWidth(); - } - - if (MiscUtil.isNotEmpty(formcustom.getAppletRedirectTarget())) - appletRedirectTarget = formcustom.getAppletRedirectTarget(); - - if (MiscUtil.isNotEmpty(formcustom.getBackGroundColor())) { - backGroundColor = formcustom.getBackGroundColor(); - map.put(FormBuildUtils.PARAM_MAIN_BACKGROUNDCOLOR, formcustom.getBackGroundColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColor())) { - button_BackGroundColor = formcustom.getButtonBackGroundColor(); - map.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR, formcustom.getButtonBackGroundColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColorFocus())) { - button_BackGroundColorFocus = formcustom.getButtonBackGroundColorFocus(); - map.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR_FOCUS, formcustom.getButtonBackGroundColorFocus()); - } - - if (MiscUtil.isNotEmpty(formcustom.getButtonFontColor())) { - button_FrontColor = formcustom.getButtonFontColor(); - map.put(FormBuildUtils.PARAM_BUTTON_COLOR, formcustom.getButtonFontColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getFontType())) { - fontType = formcustom.getFontType(); - map.put(FormBuildUtils.PARAM_FONTFAMILY, formcustom.getFontType()); - } - - if (MiscUtil.isNotEmpty(formcustom.getFrontColor())) { - frontColor = formcustom.getFrontColor(); - map.put(FormBuildUtils.PARAM_MAIN_COLOR, formcustom.getFrontColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getHeaderBackGroundColor())) { - header_BackGroundColor = formcustom.getHeaderBackGroundColor(); - map.put(FormBuildUtils.PARAM_HEADER_BACKGROUNDCOLOR, formcustom.getHeaderBackGroundColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getHeaderFrontColor())) { - header_FrontColor = formcustom.getHeaderFrontColor(); - map.put(FormBuildUtils.PARAM_HEADER_COLOR, formcustom.getHeaderFrontColor()); - } - - if (MiscUtil.isNotEmpty(formcustom.getHeaderText())) { - header_text = formcustom.getHeaderText(); - map.put(FormBuildUtils.PARAM_HEADER_TEXT, formcustom.getHeaderText()); - } - } - } - } - - request.getSession().setAttribute(Constants.SESSION_BKUFORMPREVIEW, map); - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); - } - - dbOA.setRemoveBPKFromAuthBlock(isHideBPKAuthBlock()); - - dbOA.setMandateServiceSelectionTemplateURL(mandateServiceSelectionTemplate); - dbOA.setSaml2PostBindingTemplateURL(saml2PostBindingTemplate); - - TemplatesType templates = authoa.getTemplates(); - if (templates == null) { - templates = new TemplatesType(); - authoa.setTemplates(templates); - } - - templates.setAditionalAuthBlockText(getAditionalAuthBlockText()); - - //store BKU-selection and send-assertion templates - if (authUser.isAdmin()) { - - if (isDeleteBKUTemplate() && templates.getBKUSelectionTemplate() != null) { - //templates.setBKUSelectionTemplate(null); - templates.getBKUSelectionTemplate().setDelete(true); - } - - if (isDeleteSendAssertionTemplate() && templates.getSendAssertionTemplate() != null) { - //templates.setSendAssertionTemplate(null); - templates.getSendAssertionTemplate().setDelete(true); - } - - - if (bkuSelectionForm != null && bkuSelectionForm.size() > 0) { - TransformsInfoType template = new TransformsInfoType(); - - Iterator<String> interator = bkuSelectionForm.keySet().iterator(); - template.setFilename(interator.next()); - template.setTransformation(bkuSelectionForm.get( - template.getFilename())); - - templates.setBKUSelectionTemplate(template); - } - - if (sendAssertionForm != null && sendAssertionForm.size() > 0) { - TransformsInfoType template = new TransformsInfoType(); - - Iterator<String> interator = sendAssertionForm.keySet().iterator(); - template.setFilename(interator.next()); - template.setTransformation(sendAssertionForm.get( - template.getFilename())); - - templates.setSendAssertionTemplate(template); - } + private boolean showMandateLoginButton = true; + private boolean onlyMandateAllowed = false; + + private String fontType = null; + + private String frontColor = null; + private String backGroundColor = null; + private String header_FrontColor = null; + private String header_BackGroundColor = null; + private String header_text = null; + private String button_BackGroundColor = null; + private String button_BackGroundColorFocus = null; + private String button_FrontColor = null; + private String applet_height = null; + private String applet_width = null; + + private Map<String, String> map = null; + + private String appletRedirectTarget = null; + public static List<String> appletRedirectTargetList = null; + + public static List<String> fontTypeList = null; + public String fontTypeListValue = null; + + private Map<String, byte[]> sendAssertionForm = new HashMap<>(); + private Map<String, byte[]> bkuSelectionForm = new HashMap<>(); + + private List<File> bkuSelectionFileUpload = null; + private List<String> bkuSelectionFileUploadContentType = null; + private List<String> bkuSelectionFileUploadFileName = new ArrayList<>(); + private boolean deleteBKUTemplate = false; + + private List<File> sendAssertionFileUpload = null; + private List<String> sendAssertionFileUploadContentType = null; + private List<String> sendAssertionFileUploadFileName = new ArrayList<>(); + private boolean deleteSendAssertionTemplate = false; + + private String aditionalAuthBlockText = null; + private boolean isHideBPKAuthBlock = false; + + private String saml2PostBindingTemplate = null; + private String mandateServiceSelectionTemplate = null; + + public FormularCustomization() { + new FormularCustomization(null); + } + + public FormularCustomization(Map<String, String> map) { + appletRedirectTargetList = Arrays.asList("", "_blank", "_self", "_parent", "_top"); + fontTypeList = Arrays.asList("", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif", + "Times New Roman"); + Collections.sort(fontTypeList); + + if (map == null) { + this.map = FormBuildUtils.getDefaultMap(); + } else { + this.map = map; + } + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OAFormularCustomization"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { + final AuthComponentOA auth = dbOA.getAuthComponentOA(); + + mandateServiceSelectionTemplate = dbOA.getMandateServiceSelectionTemplateURL(); + saml2PostBindingTemplate = dbOA.getSaml2PostBindingTemplateURL(); + + if (dbOA.getAuthComponentOA() != null) { + isHideBPKAuthBlock = dbOA.isRemoveBPKFromAuthBlock(); + } + + if (auth != null) { + final TemplatesType templates = auth.getTemplates(); + + if (templates != null) { + aditionalAuthBlockText = templates.getAditionalAuthBlockText(); + + final TransformsInfoType bkuSelectTemplate = templates.getBKUSelectionTemplate(); + if (bkuSelectTemplate != null + && MiscUtil.isNotEmpty(bkuSelectTemplate.getFilename()) + && !bkuSelectTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) + && !bkuSelectTemplate.getFilename().equals( + MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { + bkuSelectionFileUploadFileName.add(bkuSelectTemplate.getFilename()); } - - BKUSelectionCustomizationType bkuselectioncustom = templates.getBKUSelectionCustomization(); - if (bkuselectioncustom == null) { - bkuselectioncustom = new BKUSelectionCustomizationType(); - templates.setBKUSelectionCustomization(bkuselectioncustom); + + final TransformsInfoType sendAssertionTemplate = templates.getSendAssertionTemplate(); + if (sendAssertionTemplate != null + && MiscUtil.isNotEmpty(sendAssertionTemplate.getFilename()) + && !sendAssertionTemplate.getFilename().equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT) + && !sendAssertionTemplate.getFilename().equals( + MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT_EMPTY)) { + sendAssertionFileUploadFileName.add(sendAssertionTemplate.getFilename()); } - - if (authoa.getMandates() != null && - ((authoa.getMandates().getProfileName() != null - && authoa.getMandates().getProfileName().size() > 0) - || MiscUtil.isNotEmpty(authoa.getMandates().getProfiles()))) - - bkuselectioncustom.setMandateLoginButton(true); - else - bkuselectioncustom.setMandateLoginButton(false); - - bkuselectioncustom.setOnlyMandateLoginAllowed(isOnlyMandateAllowed()); - - bkuselectioncustom.setBackGroundColor(parseColor(getBackGroundColor())); - bkuselectioncustom.setFrontColor(parseColor(getFrontColor())); - - bkuselectioncustom.setHeaderBackGroundColor(parseColor(getHeader_BackGroundColor())); - bkuselectioncustom.setHeaderFrontColor(parseColor(getHeader_FrontColor())); - bkuselectioncustom.setHeaderText(getHeader_text()); - - bkuselectioncustom.setButtonBackGroundColor(parseColor(getButton_BackGroundColor())); - bkuselectioncustom.setButtonBackGroundColorFocus(parseColor(getButton_BackGroundColorFocus())); - bkuselectioncustom.setButtonFontColor(parseColor(getButton_FrontColor())); - - if (MiscUtil.isNotEmpty(getAppletRedirectTarget())) - bkuselectioncustom.setAppletRedirectTarget(getAppletRedirectTarget()); - - bkuselectioncustom.setFontType(getFontType()); - - bkuselectioncustom.setAppletHeight(getApplet_height()); - bkuselectioncustom.setAppletWidth(getApplet_width()); - - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - - HttpSession session = request.getSession(); - List<String> errors = new ArrayList<String>(); - - String check = null; - if (authUser.isAdmin()) { - //validate aditionalAuthBlockText - check = getAditionalAuthBlockText(); - if (MiscUtil.isNotEmpty(check)) { - if (ValidationHelper.containsNotValidCharacter(check, false)) { - log.warn("AditionalAuthBlockText contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.general.aditionalauthblocktext", - new Object[] {ValidationHelper.getNotValidCharacter(false)}, request )); - } - } - } - - OAFileUploadValidation valiator_fileUpload = new OAFileUploadValidation(); - //validate BKU-selection template - List<String> templateError = valiator_fileUpload.validate(getBkuSelectionFileUploadFileName() - , getBkuSelectionFileUpload(), "validation.general.bkuselection", bkuSelectionForm, request); - if (templateError != null && templateError.size() == 0) { - if (bkuSelectionForm != null && bkuSelectionForm.size() > 0) - session.setAttribute(Constants.SESSION_BKUSELECTIONTEMPLATE, bkuSelectionForm); - - else - bkuSelectionForm = (Map<String, byte[]>) session.getAttribute(Constants.SESSION_BKUSELECTIONTEMPLATE); - - } else { - errors.addAll(templateError); + final BKUSelectionCustomizationType formcustom = templates.getBKUSelectionCustomization(); + if (formcustom != null) { + + if (formcustom.isMandateLoginButton() != null) { + showMandateLoginButton = formcustom.isMandateLoginButton(); + } + + if (formcustom.isOnlyMandateLoginAllowed() != null) { + onlyMandateAllowed = formcustom.isOnlyMandateLoginAllowed(); + } + + if (formcustom.getAppletHeight() != null) { + applet_height = formcustom.getAppletHeight(); + } + + if (formcustom.getAppletHeight() != null) { + applet_width = formcustom.getAppletWidth(); + } + + if (MiscUtil.isNotEmpty(formcustom.getAppletRedirectTarget())) { + appletRedirectTarget = formcustom.getAppletRedirectTarget(); + } + + if (MiscUtil.isNotEmpty(formcustom.getBackGroundColor())) { + backGroundColor = formcustom.getBackGroundColor(); + map.put(FormBuildUtils.PARAM_MAIN_BACKGROUNDCOLOR, formcustom.getBackGroundColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColor())) { + button_BackGroundColor = formcustom.getButtonBackGroundColor(); + map.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR, formcustom.getButtonBackGroundColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getButtonBackGroundColorFocus())) { + button_BackGroundColorFocus = formcustom.getButtonBackGroundColorFocus(); + map.put(FormBuildUtils.PARAM_BUTTON_BACKGROUNDCOLOR_FOCUS, formcustom + .getButtonBackGroundColorFocus()); + } + + if (MiscUtil.isNotEmpty(formcustom.getButtonFontColor())) { + button_FrontColor = formcustom.getButtonFontColor(); + map.put(FormBuildUtils.PARAM_BUTTON_COLOR, formcustom.getButtonFontColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getFontType())) { + fontType = formcustom.getFontType(); + map.put(FormBuildUtils.PARAM_FONTFAMILY, formcustom.getFontType()); + } + + if (MiscUtil.isNotEmpty(formcustom.getFrontColor())) { + frontColor = formcustom.getFrontColor(); + map.put(FormBuildUtils.PARAM_MAIN_COLOR, formcustom.getFrontColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getHeaderBackGroundColor())) { + header_BackGroundColor = formcustom.getHeaderBackGroundColor(); + map.put(FormBuildUtils.PARAM_HEADER_BACKGROUNDCOLOR, formcustom.getHeaderBackGroundColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getHeaderFrontColor())) { + header_FrontColor = formcustom.getHeaderFrontColor(); + map.put(FormBuildUtils.PARAM_HEADER_COLOR, formcustom.getHeaderFrontColor()); + } + + if (MiscUtil.isNotEmpty(formcustom.getHeaderText())) { + header_text = formcustom.getHeaderText(); + map.put(FormBuildUtils.PARAM_HEADER_TEXT, formcustom.getHeaderText()); + } } + } + } + + request.getSession().setAttribute(Constants.SESSION_BKUFORMPREVIEW, map); + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } - //validate send-assertion template - templateError = valiator_fileUpload.validate(getSendAssertionFileUploadFileName() - , getSendAssertionFileUpload(), "validation.general.sendassertion", sendAssertionForm, request); - if (templateError != null && templateError.size() == 0) { - if (sendAssertionForm != null && sendAssertionForm.size() > 0) - session.setAttribute(Constants.SESSION_SENDASSERTIONTEMPLATE, sendAssertionForm); + dbOA.setRemoveBPKFromAuthBlock(isHideBPKAuthBlock()); - else - sendAssertionForm = (Map<String, byte[]>) session.getAttribute(Constants.SESSION_SENDASSERTIONTEMPLATE); + dbOA.setMandateServiceSelectionTemplateURL(mandateServiceSelectionTemplate); + dbOA.setSaml2PostBindingTemplateURL(saml2PostBindingTemplate); - } else { - errors.addAll(templateError); + TemplatesType templates = authoa.getTemplates(); + if (templates == null) { + templates = new TemplatesType(); + authoa.setTemplates(templates); + } - } - - check = getSaml2PostBindingTemplate(); - if (MiscUtil.isNotEmpty(check) && ValidationHelper.isNotValidIdentityLinkSigner(check) ) { - log.info("URL to SAML2 POST-Binding template is not valid"); - errors.add(LanguageHelper.getErrorString("validation.general.templates.saml2.postbinding.valid", request)); - - } - - check = getMandateServiceSelectionTemplate(); - if (MiscUtil.isNotEmpty(check) && ValidationHelper.isNotValidIdentityLinkSigner(check) ) { - log.info("URL to mandate-service selection-template is not valid"); - errors.add(LanguageHelper.getErrorString("validation.general.templates.mandateserviceselection.valid", request)); - - } - - - //validate BKUFormCustomization - errors.addAll(new FormularCustomizationValitator().validate(this, request)); - - return errors; - } - - private String parseColor(String color) { - String value = ""; - - if (MiscUtil.isNotEmpty(color)) { - if (!color.startsWith("#")) - value = "#" + color; - else - value = color; - } - return value; + templates.setAditionalAuthBlockText(getAditionalAuthBlockText()); + + // store BKU-selection and send-assertion templates + if (authUser.isAdmin()) { + + if (isDeleteBKUTemplate() && templates.getBKUSelectionTemplate() != null) { + // templates.setBKUSelectionTemplate(null); + templates.getBKUSelectionTemplate().setDelete(true); + } + + if (isDeleteSendAssertionTemplate() && templates.getSendAssertionTemplate() != null) { + // templates.setSendAssertionTemplate(null); + templates.getSendAssertionTemplate().setDelete(true); + } + + if (bkuSelectionForm != null && bkuSelectionForm.size() > 0) { + final TransformsInfoType template = new TransformsInfoType(); + + final Iterator<String> interator = bkuSelectionForm.keySet().iterator(); + template.setFilename(interator.next()); + template.setTransformation(bkuSelectionForm.get( + template.getFilename())); + + templates.setBKUSelectionTemplate(template); + } + + if (sendAssertionForm != null && sendAssertionForm.size() > 0) { + final TransformsInfoType template = new TransformsInfoType(); + + final Iterator<String> interator = sendAssertionForm.keySet().iterator(); + template.setFilename(interator.next()); + template.setTransformation(sendAssertionForm.get( + template.getFilename())); + + templates.setSendAssertionTemplate(template); + } } - /** - * @return the showMandateLoginButton - */ - public boolean isShowMandateLoginButton() { - return showMandateLoginButton; - } + BKUSelectionCustomizationType bkuselectioncustom = templates.getBKUSelectionCustomization(); + if (bkuselectioncustom == null) { + bkuselectioncustom = new BKUSelectionCustomizationType(); + templates.setBKUSelectionCustomization(bkuselectioncustom); + } + + if (authoa.getMandates() != null && + (authoa.getMandates().getProfileName() != null + && authoa.getMandates().getProfileName().size() > 0 + || MiscUtil.isNotEmpty(authoa.getMandates().getProfiles()))) { + bkuselectioncustom.setMandateLoginButton(true); + } else { + bkuselectioncustom.setMandateLoginButton(false); + } + bkuselectioncustom.setOnlyMandateLoginAllowed(isOnlyMandateAllowed()); - /** - * @param showMandateLoginButton the showMandateLoginButton to set - */ - public void setShowMandateLoginButton(boolean showMandateLoginButton) { - this.showMandateLoginButton = showMandateLoginButton; - } + bkuselectioncustom.setBackGroundColor(parseColor(getBackGroundColor())); + bkuselectioncustom.setFrontColor(parseColor(getFrontColor())); + bkuselectioncustom.setHeaderBackGroundColor(parseColor(getHeader_BackGroundColor())); + bkuselectioncustom.setHeaderFrontColor(parseColor(getHeader_FrontColor())); + bkuselectioncustom.setHeaderText(getHeader_text()); - /** - * @return the onlyMandateAllowed - */ - public boolean isOnlyMandateAllowed() { - return onlyMandateAllowed; - } + bkuselectioncustom.setButtonBackGroundColor(parseColor(getButton_BackGroundColor())); + bkuselectioncustom.setButtonBackGroundColorFocus(parseColor(getButton_BackGroundColorFocus())); + bkuselectioncustom.setButtonFontColor(parseColor(getButton_FrontColor())); + if (MiscUtil.isNotEmpty(getAppletRedirectTarget())) { + bkuselectioncustom.setAppletRedirectTarget(getAppletRedirectTarget()); + } + + bkuselectioncustom.setFontType(getFontType()); + + bkuselectioncustom.setAppletHeight(getApplet_height()); + bkuselectioncustom.setAppletWidth(getApplet_width()); + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + + final HttpSession session = request.getSession(); + final List<String> errors = new ArrayList<>(); + + String check = null; + if (authUser.isAdmin()) { + // validate aditionalAuthBlockText + check = getAditionalAuthBlockText(); + if (MiscUtil.isNotEmpty(check)) { + if (ValidationHelper.containsNotValidCharacter(check, false)) { + log.warn("AditionalAuthBlockText contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.general.aditionalauthblocktext", + new Object[] { ValidationHelper.getNotValidCharacter(false) }, request)); + } + } + } - /** - * @param onlyMandateAllowed the onlyMandateAllowed to set - */ - public void setOnlyMandateAllowed(boolean onlyMandateAllowed) { - this.onlyMandateAllowed = onlyMandateAllowed; - } + final OAFileUploadValidation valiator_fileUpload = new OAFileUploadValidation(); + // validate BKU-selection template + List<String> templateError = valiator_fileUpload.validate(getBkuSelectionFileUploadFileName(), + getBkuSelectionFileUpload(), "validation.general.bkuselection", bkuSelectionForm, request); + if (templateError != null && templateError.size() == 0) { + if (bkuSelectionForm != null && bkuSelectionForm.size() > 0) { + session.setAttribute(Constants.SESSION_BKUSELECTIONTEMPLATE, bkuSelectionForm); + } else { + bkuSelectionForm = (Map<String, byte[]>) session.getAttribute(Constants.SESSION_BKUSELECTIONTEMPLATE); + } + } else { + errors.addAll(templateError); - /** - * @return the fontType - */ - public String getFontType() { - return fontType; - } + } + // validate send-assertion template + templateError = valiator_fileUpload.validate(getSendAssertionFileUploadFileName(), + getSendAssertionFileUpload(), "validation.general.sendassertion", sendAssertionForm, request); + if (templateError != null && templateError.size() == 0) { + if (sendAssertionForm != null && sendAssertionForm.size() > 0) { + session.setAttribute(Constants.SESSION_SENDASSERTIONTEMPLATE, sendAssertionForm); + } else { + sendAssertionForm = (Map<String, byte[]>) session.getAttribute( + Constants.SESSION_SENDASSERTIONTEMPLATE); + } - /** - * @param fontType the fontType to set - */ - public void setFontType(String fontType) { - this.fontType = fontType; - } + } else { + errors.addAll(templateError); + } - /** - * @return the frontColor - */ - public String getFrontColor() { - return frontColor; - } + check = getSaml2PostBindingTemplate(); + if (MiscUtil.isNotEmpty(check) && ValidationHelper.isNotValidIdentityLinkSigner(check)) { + log.info("URL to SAML2 POST-Binding template is not valid"); + errors.add(LanguageHelper.getErrorString("validation.general.templates.saml2.postbinding.valid", + request)); + } - /** - * @param frontColor the frontColor to set - */ - public void setFrontColor(String frontColor) { - this.frontColor = frontColor; - } + check = getMandateServiceSelectionTemplate(); + if (MiscUtil.isNotEmpty(check) && ValidationHelper.isNotValidIdentityLinkSigner(check)) { + log.info("URL to mandate-service selection-template is not valid"); + errors.add(LanguageHelper.getErrorString("validation.general.templates.mandateserviceselection.valid", + request)); + } - /** - * @return the backGroundColor - */ - public String getBackGroundColor() { - return backGroundColor; - } + // validate BKUFormCustomization + errors.addAll(new FormularCustomizationValitator().validate(this, request)); + return errors; + } - /** - * @param backGroundColor the backGroundColor to set - */ - public void setBackGroundColor(String backGroundColor) { - this.backGroundColor = backGroundColor; - } + private String parseColor(String color) { + String value = ""; + if (MiscUtil.isNotEmpty(color)) { + if (!color.startsWith("#")) { + value = "#" + color; + } else { + value = color; + } + } + return value; + } + + /** + * @return the showMandateLoginButton + */ + public boolean isShowMandateLoginButton() { + return showMandateLoginButton; + } + + /** + * @param showMandateLoginButton the showMandateLoginButton to set + */ + public void setShowMandateLoginButton(boolean showMandateLoginButton) { + this.showMandateLoginButton = showMandateLoginButton; + } + + /** + * @return the onlyMandateAllowed + */ + public boolean isOnlyMandateAllowed() { + return onlyMandateAllowed; + } + + /** + * @param onlyMandateAllowed the onlyMandateAllowed to set + */ + public void setOnlyMandateAllowed(boolean onlyMandateAllowed) { + this.onlyMandateAllowed = onlyMandateAllowed; + } + + /** + * @return the fontType + */ + public String getFontType() { + return fontType; + } + + /** + * @param fontType the fontType to set + */ + public void setFontType(String fontType) { + this.fontType = fontType; + } + + /** + * @return the frontColor + */ + public String getFrontColor() { + return frontColor; + } + + /** + * @param frontColor the frontColor to set + */ + public void setFrontColor(String frontColor) { + this.frontColor = frontColor; + } + + /** + * @return the backGroundColor + */ + public String getBackGroundColor() { + return backGroundColor; + } + + /** + * @param backGroundColor the backGroundColor to set + */ + public void setBackGroundColor(String backGroundColor) { + this.backGroundColor = backGroundColor; + } + + /** + * @return the header_FrontColor + */ + public String getHeader_FrontColor() { + return header_FrontColor; + } + + /** + * @param header_FrontColor the header_FrontColor to set + */ + public void setHeader_FrontColor(String header_FrontColor) { + this.header_FrontColor = header_FrontColor; + } + + /** + * @return the header_BackGroundColor + */ + public String getHeader_BackGroundColor() { + return header_BackGroundColor; + } + + /** + * @param header_BackGroundColor the header_BackGroundColor to set + */ + public void setHeader_BackGroundColor(String header_BackGroundColor) { + this.header_BackGroundColor = header_BackGroundColor; + } + + /** + * @return the header_text + */ + public String getHeader_text() { + return header_text; + } + + /** + * @param header_text the header_text to set + */ + public void setHeader_text(String header_text) { + this.header_text = header_text; + } + + /** + * @return the button_BackGroundColor + */ + public String getButton_BackGroundColor() { + return button_BackGroundColor; + } + + /** + * @param button_BackGroundColor the button_BackGroundColor to set + */ + public void setButton_BackGroundColor(String button_BackGroundColor) { + this.button_BackGroundColor = button_BackGroundColor; + } + + /** + * @return the button_BackGroundColorFocus + */ + public String getButton_BackGroundColorFocus() { + return button_BackGroundColorFocus; + } + + /** + * @param button_BackGroundColorFocus the button_BackGroundColorFocus to set + */ + public void setButton_BackGroundColorFocus(String button_BackGroundColorFocus) { + this.button_BackGroundColorFocus = button_BackGroundColorFocus; + } + + /** + * @return the button_FrontColor + */ + public String getButton_FrontColor() { + return button_FrontColor; + } + + /** + * @param button_FrontColor the button_FrontColor to set + */ + public void setButton_FrontColor(String button_FrontColor) { + this.button_FrontColor = button_FrontColor; + } + + /** + * @return the appletRedirectTarget + */ + public String getAppletRedirectTarget() { + return appletRedirectTarget; + } + + /** + * @param appletRedirectTarget the appletRedirectTarget to set + */ + public void setAppletRedirectTarget(String appletRedirectTarget) { + this.appletRedirectTarget = appletRedirectTarget; + } + + /** + * @return the appletredirecttargetlist + */ + public List<String> getAppletRedirectTargetList() { + return appletRedirectTargetList; + } + + /** + * @return the fontTypeList + */ + public List<String> getFontTypeList() { + return fontTypeList; + } + + /** + * @return the fontTypeListValue + */ + public String getFontTypeListValue() { + return fontTypeListValue; + } + + /** + * @param fontTypeListValue the fontTypeListValue to set + */ + public void setFontTypeListValue(String fontTypeListValue) { + this.fontTypeListValue = fontTypeListValue; + } + + /** + * @return the applet_height + */ + public String getApplet_height() { + return applet_height; + } + + /** + * @param applet_height the applet_height to set + */ + public void setApplet_height(String applet_height) { + this.applet_height = applet_height; + } + + /** + * @return the applet_width + */ + public String getApplet_width() { + return applet_width; + } + + /** + * @param applet_width the applet_width to set + */ + public void setApplet_width(String applet_width) { + this.applet_width = applet_width; + } + + /** + * @return the bkuSelectionFileUpload + */ + public List<File> getBkuSelectionFileUpload() { + return bkuSelectionFileUpload; + } + + /** + * @param bkuSelectionFileUpload the bkuSelectionFileUpload to set + */ + public void setBkuSelectionFileUpload(List<File> bkuSelectionFileUpload) { + this.bkuSelectionFileUpload = bkuSelectionFileUpload; + } + + /** + * @return the bkuSelectionFileUploadContentType + */ + public List<String> getBkuSelectionFileUploadContentType() { + return bkuSelectionFileUploadContentType; + } + + /** + * @param bkuSelectionFileUploadContentType the + * bkuSelectionFileUploadContentType to + * set + */ + public void setBkuSelectionFileUploadContentType( + List<String> bkuSelectionFileUploadContentType) { + this.bkuSelectionFileUploadContentType = bkuSelectionFileUploadContentType; + } + + /** + * @return the bkuSelectionFileUploadFileName + */ + public List<String> getBkuSelectionFileUploadFileName() { + return bkuSelectionFileUploadFileName; + } + + /** + * @param bkuSelectionFileUploadFileName the bkuSelectionFileUploadFileName to + * set + */ + public void setBkuSelectionFileUploadFileName( + List<String> bkuSelectionFileUploadFileName) { + this.bkuSelectionFileUploadFileName = bkuSelectionFileUploadFileName; + } + + /** + * @return the sendAssertionFileUpload + */ + public List<File> getSendAssertionFileUpload() { + return sendAssertionFileUpload; + } + + /** + * @param sendAssertionFileUpload the sendAssertionFileUpload to set + */ + public void setSendAssertionFileUpload(List<File> sendAssertionFileUpload) { + this.sendAssertionFileUpload = sendAssertionFileUpload; + } + + /** + * @return the sendAssertionFileUploadContentType + */ + public List<String> getSendAssertionFileUploadContentType() { + return sendAssertionFileUploadContentType; + } + + /** + * @param sendAssertionFileUploadContentType the + * sendAssertionFileUploadContentType + * to set + */ + public void setSendAssertionFileUploadContentType( + List<String> sendAssertionFileUploadContentType) { + this.sendAssertionFileUploadContentType = sendAssertionFileUploadContentType; + } + + /** + * @return the sendAssertionFileUploadFileName + */ + public List<String> getSendAssertionFileUploadFileName() { + return sendAssertionFileUploadFileName; + } + + /** + * @param sendAssertionFileUploadFileName the sendAssertionFileUploadFileName to + * set + */ + public void setSendAssertionFileUploadFileName( + List<String> sendAssertionFileUploadFileName) { + this.sendAssertionFileUploadFileName = sendAssertionFileUploadFileName; + } + + /** + * @return the deleteBKUTemplate + */ + public boolean isDeleteBKUTemplate() { + return deleteBKUTemplate; + } + + /** + * @param deleteBKUTemplate the deleteBKUTemplate to set + */ + public void setDeleteBKUTemplate(boolean deleteBKUTemplate) { + this.deleteBKUTemplate = deleteBKUTemplate; + } + + /** + * @return the deleteSendAssertionTemplate + */ + public boolean isDeleteSendAssertionTemplate() { + return deleteSendAssertionTemplate; + } + + /** + * @param deleteSendAssertionTemplate the deleteSendAssertionTemplate to set + */ + public void setDeleteSendAssertionTemplate(boolean deleteSendAssertionTemplate) { + this.deleteSendAssertionTemplate = deleteSendAssertionTemplate; + } + + /** + * @return the aditionalAuthBlockText + */ + public String getAditionalAuthBlockText() { + return aditionalAuthBlockText; + } + + /** + * @param aditionalAuthBlockText the aditionalAuthBlockText to set + */ + public void setAditionalAuthBlockText(String aditionalAuthBlockText) { + this.aditionalAuthBlockText = aditionalAuthBlockText; + } + + /** + * @return the isHideBPKAuthBlock + */ + public boolean isHideBPKAuthBlock() { + return isHideBPKAuthBlock; + } + + /** + * @param isHideBPKAuthBlock the isHideBPKAuthBlock to set + */ + public void setHideBPKAuthBlock(boolean isHideBPKAuthBlock) { + this.isHideBPKAuthBlock = isHideBPKAuthBlock; + } + + /** + * @return the map + */ + public Map<String, String> getFormMap() { + return map; + } + + /** + * @return the saml2PostBindingTemplate + */ + public String getSaml2PostBindingTemplate() { + return saml2PostBindingTemplate; + } + + /** + * @param saml2PostBindingTemplate the saml2PostBindingTemplate to set + */ + public void setSaml2PostBindingTemplate(String saml2PostBindingTemplate) { + this.saml2PostBindingTemplate = saml2PostBindingTemplate; + } + + /** + * @return the mandateServiceSelectionTemplate + */ + public String getMandateServiceSelectionTemplate() { + return mandateServiceSelectionTemplate; + } + + /** + * @param mandateServiceSelectionTemplate the mandateServiceSelectionTemplate to + * set + */ + public void setMandateServiceSelectionTemplate(String mandateServiceSelectionTemplate) { + this.mandateServiceSelectionTemplate = mandateServiceSelectionTemplate; + } - /** - * @return the header_FrontColor - */ - public String getHeader_FrontColor() { - return header_FrontColor; - } - - - /** - * @param header_FrontColor the header_FrontColor to set - */ - public void setHeader_FrontColor(String header_FrontColor) { - this.header_FrontColor = header_FrontColor; - } - - - /** - * @return the header_BackGroundColor - */ - public String getHeader_BackGroundColor() { - return header_BackGroundColor; - } - - - /** - * @param header_BackGroundColor the header_BackGroundColor to set - */ - public void setHeader_BackGroundColor(String header_BackGroundColor) { - this.header_BackGroundColor = header_BackGroundColor; - } - - - /** - * @return the header_text - */ - public String getHeader_text() { - return header_text; - } - - - /** - * @param header_text the header_text to set - */ - public void setHeader_text(String header_text) { - this.header_text = header_text; - } - - - /** - * @return the button_BackGroundColor - */ - public String getButton_BackGroundColor() { - return button_BackGroundColor; - } - - - /** - * @param button_BackGroundColor the button_BackGroundColor to set - */ - public void setButton_BackGroundColor(String button_BackGroundColor) { - this.button_BackGroundColor = button_BackGroundColor; - } - - - /** - * @return the button_BackGroundColorFocus - */ - public String getButton_BackGroundColorFocus() { - return button_BackGroundColorFocus; - } - - - /** - * @param button_BackGroundColorFocus the button_BackGroundColorFocus to set - */ - public void setButton_BackGroundColorFocus(String button_BackGroundColorFocus) { - this.button_BackGroundColorFocus = button_BackGroundColorFocus; - } - - - /** - * @return the button_FrontColor - */ - public String getButton_FrontColor() { - return button_FrontColor; - } - - - /** - * @param button_FrontColor the button_FrontColor to set - */ - public void setButton_FrontColor(String button_FrontColor) { - this.button_FrontColor = button_FrontColor; - } - - - /** - * @return the appletRedirectTarget - */ - public String getAppletRedirectTarget() { - return appletRedirectTarget; - } - - /** - * @param appletRedirectTarget the appletRedirectTarget to set - */ - public void setAppletRedirectTarget(String appletRedirectTarget) { - this.appletRedirectTarget = appletRedirectTarget; - } - - - /** - * @return the appletredirecttargetlist - */ - public List<String> getAppletRedirectTargetList() { - return appletRedirectTargetList; - } - - /** - * @return the fontTypeList - */ - public List<String> getFontTypeList() { - return fontTypeList; - } - - /** - * @return the fontTypeListValue - */ - public String getFontTypeListValue() { - return fontTypeListValue; - } - - /** - * @param fontTypeListValue the fontTypeListValue to set - */ - public void setFontTypeListValue(String fontTypeListValue) { - this.fontTypeListValue = fontTypeListValue; - } - - /** - * @return the applet_height - */ - public String getApplet_height() { - return applet_height; - } - - /** - * @param applet_height the applet_height to set - */ - public void setApplet_height(String applet_height) { - this.applet_height = applet_height; - } - - /** - * @return the applet_width - */ - public String getApplet_width() { - return applet_width; - } - - /** - * @param applet_width the applet_width to set - */ - public void setApplet_width(String applet_width) { - this.applet_width = applet_width; - } - - - - /** - * @return the bkuSelectionFileUpload - */ - public List<File> getBkuSelectionFileUpload() { - return bkuSelectionFileUpload; - } - - - /** - * @param bkuSelectionFileUpload the bkuSelectionFileUpload to set - */ - public void setBkuSelectionFileUpload(List<File> bkuSelectionFileUpload) { - this.bkuSelectionFileUpload = bkuSelectionFileUpload; - } - - - /** - * @return the bkuSelectionFileUploadContentType - */ - public List<String> getBkuSelectionFileUploadContentType() { - return bkuSelectionFileUploadContentType; - } - - - /** - * @param bkuSelectionFileUploadContentType the bkuSelectionFileUploadContentType to set - */ - public void setBkuSelectionFileUploadContentType( - List<String> bkuSelectionFileUploadContentType) { - this.bkuSelectionFileUploadContentType = bkuSelectionFileUploadContentType; - } - - - /** - * @return the bkuSelectionFileUploadFileName - */ - public List<String> getBkuSelectionFileUploadFileName() { - return bkuSelectionFileUploadFileName; - } - - - /** - * @param bkuSelectionFileUploadFileName the bkuSelectionFileUploadFileName to set - */ - public void setBkuSelectionFileUploadFileName( - List<String> bkuSelectionFileUploadFileName) { - this.bkuSelectionFileUploadFileName = bkuSelectionFileUploadFileName; - } - - - /** - * @return the sendAssertionFileUpload - */ - public List<File> getSendAssertionFileUpload() { - return sendAssertionFileUpload; - } - - - /** - * @param sendAssertionFileUpload the sendAssertionFileUpload to set - */ - public void setSendAssertionFileUpload(List<File> sendAssertionFileUpload) { - this.sendAssertionFileUpload = sendAssertionFileUpload; - } - - - /** - * @return the sendAssertionFileUploadContentType - */ - public List<String> getSendAssertionFileUploadContentType() { - return sendAssertionFileUploadContentType; - } - - - /** - * @param sendAssertionFileUploadContentType the sendAssertionFileUploadContentType to set - */ - public void setSendAssertionFileUploadContentType( - List<String> sendAssertionFileUploadContentType) { - this.sendAssertionFileUploadContentType = sendAssertionFileUploadContentType; - } - - - /** - * @return the sendAssertionFileUploadFileName - */ - public List<String> getSendAssertionFileUploadFileName() { - return sendAssertionFileUploadFileName; - } - - - /** - * @param sendAssertionFileUploadFileName the sendAssertionFileUploadFileName to set - */ - public void setSendAssertionFileUploadFileName( - List<String> sendAssertionFileUploadFileName) { - this.sendAssertionFileUploadFileName = sendAssertionFileUploadFileName; - } - - - /** - * @return the deleteBKUTemplate - */ - public boolean isDeleteBKUTemplate() { - return deleteBKUTemplate; - } - - - /** - * @param deleteBKUTemplate the deleteBKUTemplate to set - */ - public void setDeleteBKUTemplate(boolean deleteBKUTemplate) { - this.deleteBKUTemplate = deleteBKUTemplate; - } - - - /** - * @return the deleteSendAssertionTemplate - */ - public boolean isDeleteSendAssertionTemplate() { - return deleteSendAssertionTemplate; - } - - - /** - * @param deleteSendAssertionTemplate the deleteSendAssertionTemplate to set - */ - public void setDeleteSendAssertionTemplate(boolean deleteSendAssertionTemplate) { - this.deleteSendAssertionTemplate = deleteSendAssertionTemplate; - } - - /** - * @return the aditionalAuthBlockText - */ - public String getAditionalAuthBlockText() { - return aditionalAuthBlockText; - } - - /** - * @param aditionalAuthBlockText the aditionalAuthBlockText to set - */ - public void setAditionalAuthBlockText(String aditionalAuthBlockText) { - this.aditionalAuthBlockText = aditionalAuthBlockText; - } - - /** - * @return the isHideBPKAuthBlock - */ - public boolean isHideBPKAuthBlock() { - return isHideBPKAuthBlock; - } - - /** - * @param isHideBPKAuthBlock the isHideBPKAuthBlock to set - */ - public void setHideBPKAuthBlock(boolean isHideBPKAuthBlock) { - this.isHideBPKAuthBlock = isHideBPKAuthBlock; - } - - /** - * @return the map - */ - public Map<String, String> getFormMap() { - return map; - } - - /** - * @return the saml2PostBindingTemplate - */ - public String getSaml2PostBindingTemplate() { - return saml2PostBindingTemplate; - } - - /** - * @param saml2PostBindingTemplate the saml2PostBindingTemplate to set - */ - public void setSaml2PostBindingTemplate(String saml2PostBindingTemplate) { - this.saml2PostBindingTemplate = saml2PostBindingTemplate; - } - - /** - * @return the mandateServiceSelectionTemplate - */ - public String getMandateServiceSelectionTemplate() { - return mandateServiceSelectionTemplate; - } - - /** - * @param mandateServiceSelectionTemplate the mandateServiceSelectionTemplate to set - */ - public void setMandateServiceSelectionTemplate(String mandateServiceSelectionTemplate) { - this.mandateServiceSelectionTemplate = mandateServiceSelectionTemplate; - } - - - } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java index 3929238f6..e7b4bfa3b 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralMOAIDConfig.java @@ -63,434 +63,444 @@ import at.gv.egovernment.moa.util.MiscUtil; public class GeneralMOAIDConfig { - public static final long DEFAULTTIMEOUTASSERTION = 120; //sec - public static final long DEFAULTTIMEOUTMOASESSIONCREATED = 1200; //sec - public static final long DEFAULTTIMEOUTMOASESSIONUPDATED = 2700; //sec - - public static final String LINE_DELIMITER = ";"; - - private String alternativeSourceID = null; + public static final long DEFAULTTIMEOUTASSERTION = 120; // sec + public static final long DEFAULTTIMEOUTMOASESSIONCREATED = 1200; // sec + public static final long DEFAULTTIMEOUTMOASESSIONUPDATED = 2700; // sec + + public static final String LINE_DELIMITER = ";"; + + private String alternativeSourceID = null; // private String certStoreDirectory = null; - private boolean trustmanagerrevocationcheck = true; - - private String timeoutAssertion = String.valueOf(DEFAULTTIMEOUTASSERTION); - private String timeoutMOASessionCreated = String.valueOf(DEFAULTTIMEOUTMOASESSIONCREATED); - private String timeoutMOASessionUpdated = String.valueOf(DEFAULTTIMEOUTMOASESSIONUPDATED); - - private String moaspssURL = null; - private String moaspssAuthTrustProfile = null; - private String moaspssAuthTransformations = ""; - private List<String> authTransformList = null; - private String moaspssIdlTrustProfile = null; - - private String moaspssIdlTrustProfileTest = null; - private String moaspssAuthTrustProfileTest = null; - - private String mandateURL = null; - private String szrgwURL = null; - private String elgaMandateServiceURL = null; - private String eidSystemServiceURL = null; - - private boolean protocolActiveSAML1 = false; - private boolean protocolActivePVP21 = true; - private boolean protocolActiveOAuth = true; - - private boolean legacy_saml1 = false; - private boolean legacy_pvp2 = false; - - private String saml1SourceID = null; - - private String pvp2IssuerName = null; - private String pvp2OrgName = null; - private String pvp2OrgDisplayName = null; - private String pvp2OrgURL = null; - private ContactForm pvp2Contact = null; - - private List<File> fileUpload = null; - private List<String> fileUploadContentType; - private List<String> fileUploadFileName = new ArrayList<String>(); - private Map<String, byte[]> secLayerTransformation = null; - - private String ssoTarget = null; - private String ssoFriendlyName = null; - private String ssoSpecialText = null; - private String ssoIdentificationNumber = null; - - private String defaultchainigmode = null; - private static Map<String, String> chainigmodelist; - - private String trustedCACerts = null; - - - private String defaultBKUOnline = ""; - private String defaultBKULocal = "https://127.0.0.1:3496/https-security-layer-request"; - private String defaultBKUHandy = "https://www.handy-signatur.at/mobile/https-security-layer-request/default.aspx"; - - private String SLRequestTemplateOnline = "SLTemplates/template_onlineBKU.html"; - private String SLRequestTemplateLocal = "SLTemplates/template_handyBKU.html"; - private String SLRequestTemplateHandy = "SLTemplates/template_handyBKU.html"; - - private String publicURLPrefix = null; - private boolean virtualPublicURLPrefixEnabled = false; - - private boolean moaidMode = false; - - public GeneralMOAIDConfig() { - try { - this.moaidMode = ConfigurationProvider.getInstance().isMOAIDMode(); - } catch (ConfigurationException e) { - e.printStackTrace(); - - } - - chainigmodelist = new HashMap<String, String>(); - ChainingModeType[] values = ChainingModeType.values(); - for (int i=0; i<values.length; i++) { - chainigmodelist.put(values[i].value(), values[i].value()); - } - - try { - ConfigurationProvider config = ConfigurationProvider.getInstance(); - if (config != null) { - MOAIDConfiguration dbconfig = config.getDbRead().getMOAIDConfiguration(); - List<TransformsInfoType> authBlockTrans = dbconfig.getAuthComponentGeneral().getSecurityLayer().getTransformsInfo(); - - if (authBlockTrans != null && !authBlockTrans.isEmpty()) { - if (secLayerTransformation == null) - secLayerTransformation = new HashMap<String, byte[]>(); - for (TransformsInfoType el : authBlockTrans) - secLayerTransformation.put(el.getFilename(), el.getTransformation()); - - } - } - - } catch (Exception e) { - - } - - } - - public void parse(MOAIDConfiguration config) { - - if (config != null) { - AuthComponentGeneral auth = config.getAuthComponentGeneral(); - - //get ELGA mandate service URLs from configuration - if (MiscUtil.isNotEmpty(config.getEidSystemServiceURLs())) { - if (KeyValueUtils.isCSVValueString(config.getEidSystemServiceURLs())) - eidSystemServiceURL = KeyValueUtils.normalizeCSVValueString(config.getEidSystemServiceURLs()); - - else { - if (config.getEidSystemServiceURLs().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - eidSystemServiceURL = config.getEidSystemServiceURLs().substring(0, - config.getEidSystemServiceURLs().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - eidSystemServiceURL = config.getEidSystemServiceURLs(); - - } - } - - - //get ELGA mandate service URLs from configuration - if (MiscUtil.isNotEmpty(config.getElgaMandateServiceURLs())) { - if (KeyValueUtils.isCSVValueString(config.getElgaMandateServiceURLs())) - elgaMandateServiceURL = KeyValueUtils.normalizeCSVValueString(config.getElgaMandateServiceURLs()); - - else { - if (config.getElgaMandateServiceURLs().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - elgaMandateServiceURL = config.getElgaMandateServiceURLs().substring(0, - config.getElgaMandateServiceURLs().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - elgaMandateServiceURL = config.getElgaMandateServiceURLs(); - - } - } - - - - if (auth != null) { - - GeneralConfiguration authgen = auth.getGeneralConfiguration(); - if (authgen != null) { - alternativeSourceID = authgen.getAlternativeSourceID(); - //certStoreDirectory = authgen.getCertStoreDirectory(); - if (authgen.isTrustManagerRevocationChecking() != null) - trustmanagerrevocationcheck = authgen.isTrustManagerRevocationChecking(); - - virtualPublicURLPrefixEnabled = - KeyValueUtils.isCSVValueString(authgen.getPublicURLPreFix()); - - if (virtualPublicURLPrefixEnabled) { - //format CSV values with newlines - publicURLPrefix = KeyValueUtils.normalizeCSVValueString( - authgen.getPublicURLPreFix()); - - } else { - String tmp = authgen.getPublicURLPreFix(); - if (tmp.contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - publicURLPrefix = tmp.substring(0, - tmp.indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - publicURLPrefix = tmp; - } - - TimeOuts timeouts = authgen.getTimeOuts(); - if (timeouts != null) { - - if(timeouts.getAssertion() != null) - timeoutAssertion = String.valueOf(timeouts.getAssertion().longValue()); - if(timeouts.getMOASessionCreated() != null) - timeoutMOASessionCreated = String.valueOf(timeouts.getMOASessionCreated().longValue()); - if(timeouts.getMOASessionUpdated() != null) - timeoutMOASessionUpdated = String.valueOf(timeouts.getMOASessionUpdated().longValue()); - - } - - - //deactive STORK - if (isMoaidMode()) { - ForeignIdentities foreign = auth.getForeignIdentities(); - if (foreign != null) { - ConnectionParameterClientAuthType connect_foreign = foreign.getConnectionParameter(); - if (connect_foreign != null) { - if (MiscUtil.isNotEmpty(connect_foreign.getURL())) { - if (KeyValueUtils.isCSVValueString(connect_foreign.getURL())) - szrgwURL = KeyValueUtils.normalizeCSVValueString(connect_foreign.getURL()); - - else { - if (connect_foreign.getURL().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - szrgwURL = connect_foreign.getURL().substring(0, - connect_foreign.getURL().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - szrgwURL = connect_foreign.getURL(); - - } - - } - } - - STORK stork = foreign.getSTORK(); - if (stork != null) { - //TODO: add Stork config - - } - } - } - - } - - if (isMoaidMode()) { - MOASP moaspss = auth.getMOASP(); - if (moaspss != null) { - ConnectionParameterClientAuthType con = moaspss.getConnectionParameter(); - if (con != null) - moaspssURL = con.getURL(); - - VerifyAuthBlock authblock = moaspss.getVerifyAuthBlock(); - if (authblock != null) { - moaspssAuthTrustProfile = authblock.getTrustProfileID(); - moaspssAuthTrustProfileTest = authblock.getTestTrustProfileID(); - - List<String> list = authblock.getVerifyTransformsInfoProfileID(); - if (list.size() == 1) - moaspssAuthTransformations += list.get(0); - else { - for (String el : list) - moaspssAuthTransformations += el + LINE_DELIMITER + "\n"; - } - } - - VerifyIdentityLink idl = moaspss.getVerifyIdentityLink(); - if (idl != null) { - moaspssIdlTrustProfile = idl.getTrustProfileID(); - moaspssIdlTrustProfileTest = idl.getTestTrustProfileID(); - } - } - - OnlineMandates mandates = auth.getOnlineMandates(); - if (mandates != null) { - ConnectionParameterClientAuthType con = mandates.getConnectionParameter(); - if (con != null) { - if (MiscUtil.isNotEmpty(con.getURL())) { - if (KeyValueUtils.isCSVValueString(con.getURL())) - mandateURL = KeyValueUtils.normalizeCSVValueString(con.getURL()); - - else { - if (con.getURL().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - mandateURL = con.getURL().substring(0, - con.getURL().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - mandateURL = con.getURL(); - - } - - } - - } - } - } - - Protocols protocols = auth.getProtocols(); - if (protocols != null) { - LegacyAllowed legacy = protocols.getLegacyAllowed(); - - if (legacy != null) { - List<String> list = legacy.getProtocolName(); - if (list.contains(Constants.MOA_CONFIG_PROTOCOL_SAML1)) - legacy_saml1 = true; - - if (list.contains(Constants.MOA_CONFIG_PROTOCOL_PVP2)) - legacy_pvp2 = true; - } - - SAML1 saml1 = protocols.getSAML1(); - if (saml1 != null) { - protocolActiveSAML1 = saml1.isIsActive(); - saml1SourceID = saml1.getSourceID(); - - //TODO: could removed in a later version - if (MiscUtil.isEmpty(saml1SourceID) && MiscUtil.isNotEmpty(alternativeSourceID)) - saml1SourceID = alternativeSourceID; - - } - - if (isMoaidMode()) { - OAuth oauth = protocols.getOAuth(); - if (oauth != null) { - protocolActiveOAuth = oauth.isIsActive(); - - } - - } - - PVP2 pvp2 = protocols.getPVP2(); - if (pvp2 != null) { - - protocolActivePVP21 = pvp2.isIsActive(); - - //INFO: only for backup - if (MiscUtil.isEmpty(publicURLPrefix)) - publicURLPrefix = pvp2.getPublicURLPrefix(); - - pvp2IssuerName = pvp2.getIssuerName(); - - List<Contact> con = pvp2.getContact(); - - //TODO: change to support more contacts - if (con != null && con.size() > 0) { - pvp2Contact = new ContactForm(con.get(0)); - - } - - Organization org = pvp2.getOrganization(); - if (org != null) { - pvp2OrgDisplayName = org.getDisplayName(); - pvp2OrgName = org.getName(); - pvp2OrgURL = org.getURL(); - } - } - - } - - if (isMoaidMode()) { - SecurityLayer seclayer = auth.getSecurityLayer(); - if (seclayer != null) { - List<TransformsInfoType> list = seclayer.getTransformsInfo(); - - for (TransformsInfoType el : list) { - fileUploadFileName.add(el.getFilename()); - } - } - - SSO sso = auth.getSSO(); - if (sso != null) { - ssoFriendlyName = sso.getFriendlyName(); - - // IdentificationNumber idl = sso.getIdentificationNumber(); - // if (idl != null) - // ssoIdentificationNumber = idl.getValue(); - - //INFO: only for backup - if (MiscUtil.isEmpty(publicURLPrefix)) - publicURLPrefix = sso.getPublicURL(); - - ssoSpecialText = sso.getSpecialText(); - - if (MiscUtil.isNotEmpty(sso.getTarget()) && - sso.getTarget().startsWith(Constants.PREFIX_WPBK)) { - ssoTarget = sso.getTarget().substring(Constants.PREFIX_WPBK.length()). - replace("+", ""); - - } else - ssoTarget = sso.getTarget(); - - } - } - - ChainingModes modes = config.getChainingModes(); - if (modes != null) { - ChainingModeType defaultmode = modes.getSystemDefaultMode(); - if (defaultmode != null) { - - defaultchainigmode = defaultmode.value(); - - } - - List<TrustAnchor> trustanchor = modes.getTrustAnchor(); - if (trustanchor != null) { - //TODO: set addional trust anchors!!!! - } - } - - DefaultBKUs defaultbkus = config.getDefaultBKUs(); - if (defaultbkus != null) { - defaultBKUHandy = defaultbkus.getHandyBKU(); - defaultBKULocal = defaultbkus.getLocalBKU(); - defaultBKUOnline = defaultbkus.getOnlineBKU(); - } - - SLRequestTemplates slreq = config.getSLRequestTemplates(); - if (slreq != null) { - SLRequestTemplateHandy = slreq.getHandyBKU(); - SLRequestTemplateLocal = slreq.getLocalBKU(); - SLRequestTemplateOnline = slreq.getOnlineBKU(); - } - - } - - trustedCACerts = config.getTrustedCACertificates(); - - - - } - } - - /** - * @return the szrgwURL - */ - public String getSzrgwURL() { - return szrgwURL; - } - - /** - * @param szrgwURL the szrgwURL to set - */ - public void setSzrgwURL(String szrgwURL) { - if (MiscUtil.isNotEmpty(szrgwURL)) - this.szrgwURL = KeyValueUtils.removeAllNewlineFromString(szrgwURL); - else - this.szrgwURL = szrgwURL; - } + private boolean trustmanagerrevocationcheck = true; + + private String timeoutAssertion = String.valueOf(DEFAULTTIMEOUTASSERTION); + private String timeoutMOASessionCreated = String.valueOf(DEFAULTTIMEOUTMOASESSIONCREATED); + private String timeoutMOASessionUpdated = String.valueOf(DEFAULTTIMEOUTMOASESSIONUPDATED); + + private String moaspssURL = null; + private String moaspssAuthTrustProfile = null; + private String moaspssAuthTransformations = ""; + private List<String> authTransformList = null; + private String moaspssIdlTrustProfile = null; + + private String moaspssIdlTrustProfileTest = null; + private String moaspssAuthTrustProfileTest = null; + + private String mandateURL = null; + private String szrgwURL = null; + private String elgaMandateServiceURL = null; + private String eidSystemServiceURL = null; + + private boolean protocolActiveSAML1 = false; + private boolean protocolActivePVP21 = true; + private boolean protocolActiveOAuth = true; + + private boolean legacy_saml1 = false; + private boolean legacy_pvp2 = false; + + private String saml1SourceID = null; + + private String pvp2IssuerName = null; + private String pvp2OrgName = null; + private String pvp2OrgDisplayName = null; + private String pvp2OrgURL = null; + private ContactForm pvp2Contact = null; + + private List<File> fileUpload = null; + private List<String> fileUploadContentType; + private List<String> fileUploadFileName = new ArrayList<>(); + private Map<String, byte[]> secLayerTransformation = null; + + private String ssoTarget = null; + private String ssoFriendlyName = null; + private String ssoSpecialText = null; + private String ssoIdentificationNumber = null; + + private String defaultchainigmode = null; + private static Map<String, String> chainigmodelist; + + private String trustedCACerts = null; + + private String defaultBKUOnline = ""; + private String defaultBKULocal = "https://127.0.0.1:3496/https-security-layer-request"; + private String defaultBKUHandy = + "https://www.handy-signatur.at/mobile/https-security-layer-request/default.aspx"; + + private String SLRequestTemplateOnline = "SLTemplates/template_onlineBKU.html"; + private String SLRequestTemplateLocal = "SLTemplates/template_handyBKU.html"; + private String SLRequestTemplateHandy = "SLTemplates/template_handyBKU.html"; + + private String publicURLPrefix = null; + private boolean virtualPublicURLPrefixEnabled = false; + + private boolean moaidMode = false; + + public GeneralMOAIDConfig() { + try { + this.moaidMode = ConfigurationProvider.getInstance().isMOAIDMode(); + } catch (final ConfigurationException e) { + e.printStackTrace(); + + } + + chainigmodelist = new HashMap<>(); + final ChainingModeType[] values = ChainingModeType.values(); + for (final ChainingModeType value : values) { + chainigmodelist.put(value.value(), value.value()); + } + + try { + final ConfigurationProvider config = ConfigurationProvider.getInstance(); + if (config != null) { + final MOAIDConfiguration dbconfig = config.getDbRead().getMOAIDConfiguration(); + final List<TransformsInfoType> authBlockTrans = dbconfig.getAuthComponentGeneral().getSecurityLayer() + .getTransformsInfo(); + + if (authBlockTrans != null && !authBlockTrans.isEmpty()) { + if (secLayerTransformation == null) { + secLayerTransformation = new HashMap<>(); + } + for (final TransformsInfoType el : authBlockTrans) { + secLayerTransformation.put(el.getFilename(), el.getTransformation()); + } + + } + } + + } catch (final Exception e) { + + } + + } + + public void parse(MOAIDConfiguration config) { + + if (config != null) { + final AuthComponentGeneral auth = config.getAuthComponentGeneral(); + + // get ELGA mandate service URLs from configuration + if (MiscUtil.isNotEmpty(config.getEidSystemServiceURLs())) { + if (KeyValueUtils.isCSVValueString(config.getEidSystemServiceURLs())) { + eidSystemServiceURL = KeyValueUtils.normalizeCSVValueString(config.getEidSystemServiceURLs()); + } else { + if (config.getEidSystemServiceURLs().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + eidSystemServiceURL = config.getEidSystemServiceURLs().substring(0, + config.getEidSystemServiceURLs().indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + eidSystemServiceURL = config.getEidSystemServiceURLs(); + } + + } + } + + // get ELGA mandate service URLs from configuration + if (MiscUtil.isNotEmpty(config.getElgaMandateServiceURLs())) { + if (KeyValueUtils.isCSVValueString(config.getElgaMandateServiceURLs())) { + elgaMandateServiceURL = KeyValueUtils.normalizeCSVValueString(config.getElgaMandateServiceURLs()); + } else { + if (config.getElgaMandateServiceURLs().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + elgaMandateServiceURL = config.getElgaMandateServiceURLs().substring(0, + config.getElgaMandateServiceURLs().indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + elgaMandateServiceURL = config.getElgaMandateServiceURLs(); + } + + } + } + + if (auth != null) { + + final GeneralConfiguration authgen = auth.getGeneralConfiguration(); + if (authgen != null) { + alternativeSourceID = authgen.getAlternativeSourceID(); + // certStoreDirectory = authgen.getCertStoreDirectory(); + if (authgen.isTrustManagerRevocationChecking() != null) { + trustmanagerrevocationcheck = authgen.isTrustManagerRevocationChecking(); + } + + virtualPublicURLPrefixEnabled = + KeyValueUtils.isCSVValueString(authgen.getPublicURLPreFix()); + + if (virtualPublicURLPrefixEnabled) { + // format CSV values with newlines + publicURLPrefix = KeyValueUtils.normalizeCSVValueString( + authgen.getPublicURLPreFix()); + + } else { + final String tmp = authgen.getPublicURLPreFix(); + if (tmp.contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + publicURLPrefix = tmp.substring(0, + tmp.indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + publicURLPrefix = tmp; + } + } + + final TimeOuts timeouts = authgen.getTimeOuts(); + if (timeouts != null) { + + if (timeouts.getAssertion() != null) { + timeoutAssertion = String.valueOf(timeouts.getAssertion().longValue()); + } + if (timeouts.getMOASessionCreated() != null) { + timeoutMOASessionCreated = String.valueOf(timeouts.getMOASessionCreated().longValue()); + } + if (timeouts.getMOASessionUpdated() != null) { + timeoutMOASessionUpdated = String.valueOf(timeouts.getMOASessionUpdated().longValue()); + } + + } + + // deactive STORK + if (isMoaidMode()) { + final ForeignIdentities foreign = auth.getForeignIdentities(); + if (foreign != null) { + final ConnectionParameterClientAuthType connect_foreign = foreign.getConnectionParameter(); + if (connect_foreign != null) { + if (MiscUtil.isNotEmpty(connect_foreign.getURL())) { + if (KeyValueUtils.isCSVValueString(connect_foreign.getURL())) { + szrgwURL = KeyValueUtils.normalizeCSVValueString(connect_foreign.getURL()); + } else { + if (connect_foreign.getURL().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + szrgwURL = connect_foreign.getURL().substring(0, + connect_foreign.getURL().indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + szrgwURL = connect_foreign.getURL(); + } + + } + + } + } + + final STORK stork = foreign.getSTORK(); + if (stork != null) { + // TODO: add Stork config + + } + } + } + + } + + if (isMoaidMode()) { + final MOASP moaspss = auth.getMOASP(); + if (moaspss != null) { + final ConnectionParameterClientAuthType con = moaspss.getConnectionParameter(); + if (con != null) { + moaspssURL = con.getURL(); + } + + final VerifyAuthBlock authblock = moaspss.getVerifyAuthBlock(); + if (authblock != null) { + moaspssAuthTrustProfile = authblock.getTrustProfileID(); + moaspssAuthTrustProfileTest = authblock.getTestTrustProfileID(); + + final List<String> list = authblock.getVerifyTransformsInfoProfileID(); + if (list.size() == 1) { + moaspssAuthTransformations += list.get(0); + } else { + for (final String el : list) { + moaspssAuthTransformations += el + LINE_DELIMITER + "\n"; + } + } + } + + final VerifyIdentityLink idl = moaspss.getVerifyIdentityLink(); + if (idl != null) { + moaspssIdlTrustProfile = idl.getTrustProfileID(); + moaspssIdlTrustProfileTest = idl.getTestTrustProfileID(); + } + } + + final OnlineMandates mandates = auth.getOnlineMandates(); + if (mandates != null) { + final ConnectionParameterClientAuthType con = mandates.getConnectionParameter(); + if (con != null) { + if (MiscUtil.isNotEmpty(con.getURL())) { + if (KeyValueUtils.isCSVValueString(con.getURL())) { + mandateURL = KeyValueUtils.normalizeCSVValueString(con.getURL()); + } else { + if (con.getURL().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + mandateURL = con.getURL().substring(0, + con.getURL().indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + mandateURL = con.getURL(); + } + + } + + } + + } + } + } + + final Protocols protocols = auth.getProtocols(); + if (protocols != null) { + final LegacyAllowed legacy = protocols.getLegacyAllowed(); + + if (legacy != null) { + final List<String> list = legacy.getProtocolName(); + if (list.contains(Constants.MOA_CONFIG_PROTOCOL_SAML1)) { + legacy_saml1 = true; + } + + if (list.contains(Constants.MOA_CONFIG_PROTOCOL_PVP2)) { + legacy_pvp2 = true; + } + } + + final SAML1 saml1 = protocols.getSAML1(); + if (saml1 != null) { + protocolActiveSAML1 = saml1.isIsActive(); + saml1SourceID = saml1.getSourceID(); + + // TODO: could removed in a later version + if (MiscUtil.isEmpty(saml1SourceID) && MiscUtil.isNotEmpty(alternativeSourceID)) { + saml1SourceID = alternativeSourceID; + } + + } + + if (isMoaidMode()) { + final OAuth oauth = protocols.getOAuth(); + if (oauth != null) { + protocolActiveOAuth = oauth.isIsActive(); + + } + + } + + final PVP2 pvp2 = protocols.getPVP2(); + if (pvp2 != null) { + + protocolActivePVP21 = pvp2.isIsActive(); + + // INFO: only for backup + if (MiscUtil.isEmpty(publicURLPrefix)) { + publicURLPrefix = pvp2.getPublicURLPrefix(); + } + + pvp2IssuerName = pvp2.getIssuerName(); + + final List<Contact> con = pvp2.getContact(); + + // TODO: change to support more contacts + if (con != null && con.size() > 0) { + pvp2Contact = new ContactForm(con.get(0)); + + } + + final Organization org = pvp2.getOrganization(); + if (org != null) { + pvp2OrgDisplayName = org.getDisplayName(); + pvp2OrgName = org.getName(); + pvp2OrgURL = org.getURL(); + } + } + + } + + if (isMoaidMode()) { + final SecurityLayer seclayer = auth.getSecurityLayer(); + if (seclayer != null) { + final List<TransformsInfoType> list = seclayer.getTransformsInfo(); + + for (final TransformsInfoType el : list) { + fileUploadFileName.add(el.getFilename()); + } + } + + final SSO sso = auth.getSSO(); + if (sso != null) { + ssoFriendlyName = sso.getFriendlyName(); + + // IdentificationNumber idl = sso.getIdentificationNumber(); + // if (idl != null) + // ssoIdentificationNumber = idl.getValue(); + + // INFO: only for backup + if (MiscUtil.isEmpty(publicURLPrefix)) { + publicURLPrefix = sso.getPublicURL(); + } + + ssoSpecialText = sso.getSpecialText(); + + if (MiscUtil.isNotEmpty(sso.getTarget()) && + sso.getTarget().startsWith(Constants.PREFIX_WPBK)) { + ssoTarget = sso.getTarget().substring(Constants.PREFIX_WPBK.length()).replace("+", ""); + + } else { + ssoTarget = sso.getTarget(); + } + + } + } + + final ChainingModes modes = config.getChainingModes(); + if (modes != null) { + final ChainingModeType defaultmode = modes.getSystemDefaultMode(); + if (defaultmode != null) { + + defaultchainigmode = defaultmode.value(); + + } + + final List<TrustAnchor> trustanchor = modes.getTrustAnchor(); + if (trustanchor != null) { + // TODO: set addional trust anchors!!!! + } + } + + final DefaultBKUs defaultbkus = config.getDefaultBKUs(); + if (defaultbkus != null) { + defaultBKUHandy = defaultbkus.getHandyBKU(); + defaultBKULocal = defaultbkus.getLocalBKU(); + defaultBKUOnline = defaultbkus.getOnlineBKU(); + } + + final SLRequestTemplates slreq = config.getSLRequestTemplates(); + if (slreq != null) { + SLRequestTemplateHandy = slreq.getHandyBKU(); + SLRequestTemplateLocal = slreq.getLocalBKU(); + SLRequestTemplateOnline = slreq.getOnlineBKU(); + } + + } + + trustedCACerts = config.getTrustedCACertificates(); + + } + } + + /** + * @return the szrgwURL + */ + public String getSzrgwURL() { + return szrgwURL; + } + + /** + * @param szrgwURL the szrgwURL to set + */ + public void setSzrgwURL(String szrgwURL) { + if (MiscUtil.isNotEmpty(szrgwURL)) { + this.szrgwURL = KeyValueUtils.removeAllNewlineFromString(szrgwURL); + } else { + this.szrgwURL = szrgwURL; + } + } // /** // * @return the certStoreDirectory @@ -506,662 +516,665 @@ public class GeneralMOAIDConfig { // this.certStoreDirectory = certStoreDirectory; // } - /** - * @return the timeoutAssertion - */ - public String getTimeoutAssertion() { - return timeoutAssertion; - } - - /** - * @param timeoutAssertion the timeoutAssertion to set - */ - public void setTimeoutAssertion(String timeoutAssertion) { - this.timeoutAssertion = timeoutAssertion; - } - - /** - * @return the timeoutMOASessionCreated - */ - public String getTimeoutMOASessionCreated() { - return timeoutMOASessionCreated; - } - - /** - * @param timeoutMOASessionCreated the timeoutMOASessionCreated to set - */ - public void setTimeoutMOASessionCreated(String timeoutMOASessionCreated) { - this.timeoutMOASessionCreated = timeoutMOASessionCreated; - } - - /** - * @return the timeoutMOASessionUpdated - */ - public String getTimeoutMOASessionUpdated() { - return timeoutMOASessionUpdated; - } - - /** - * @param timeoutMOASessionUpdated the timeoutMOASessionUpdated to set - */ - public void setTimeoutMOASessionUpdated(String timeoutMOASessionUpdated) { - this.timeoutMOASessionUpdated = timeoutMOASessionUpdated; - } - - /** - * @return the moaspssURL - */ - public String getMoaspssURL() { - return moaspssURL; - } - - /** - * @param moaspssURL the moaspssURL to set - */ - public void setMoaspssURL(String moaspssURL) { - this.moaspssURL = moaspssURL; - } - - /** - * @return the moaspssAuthTrustProfile - */ - public String getMoaspssAuthTrustProfile() { - return moaspssAuthTrustProfile; - } - - /** - * @param moaspssAuthTrustProfile the moaspssAuthTrustProfile to set - */ - public void setMoaspssAuthTrustProfile(String moaspssAuthTrustProfile) { - this.moaspssAuthTrustProfile = moaspssAuthTrustProfile; - } - - /** - * @return the moaspssAuthTransformations - */ - public String getMoaspssAuthTransformations() { - return moaspssAuthTransformations; - } - - /** - * @param moaspssAuthTransformations the moaspssAuthTransformations to set - */ - public void setMoaspssAuthTransformations(String moaspssAuthTransformations) { - this.moaspssAuthTransformations = moaspssAuthTransformations; - } - - /** - * @return the moaspssIdlTrustProfile - */ - public String getMoaspssIdlTrustProfile() { - return moaspssIdlTrustProfile; - } - - /** - * @param moaspssIdlTrustProfile the moaspssIdlTrustProfile to set - */ - public void setMoaspssIdlTrustProfile(String moaspssIdlTrustProfile) { - this.moaspssIdlTrustProfile = moaspssIdlTrustProfile; - } - - /** - * @return the mandateURL - */ - public String getMandateURL() { - return mandateURL; - } - - /** - * @param mandateURL the mandateURL to set - */ - public void setMandateURL(String mandateURL) { - if (MiscUtil.isNotEmpty(mandateURL)) - this.mandateURL = KeyValueUtils.removeAllNewlineFromString(mandateURL); - else - this.mandateURL = mandateURL; - } - - /** - * @return the legacy_saml1 - */ - public boolean isLegacy_saml1() { - return legacy_saml1; - } - - /** - * @param legacy_saml1 the legacy_saml1 to set - */ - public void setLegacy_saml1(boolean legacy_saml1) { - this.legacy_saml1 = legacy_saml1; - } - - /** - * @return the legacy_pvp2 - */ - public boolean isLegacy_pvp2() { - return legacy_pvp2; - } - - /** - * @param legacy_pvp2 the legacy_pvp2 to set - */ - public void setLegacy_pvp2(boolean legacy_pvp2) { - this.legacy_pvp2 = legacy_pvp2; - } - - /** - * @return the pvp2IssuerName - */ - public String getPvp2IssuerName() { - return pvp2IssuerName; - } - - /** - * @param pvp2IssuerName the pvp2IssuerName to set - */ - public void setPvp2IssuerName(String pvp2IssuerName) { - this.pvp2IssuerName = pvp2IssuerName; - } - - /** - * @return the pvp2OrgName - */ - public String getPvp2OrgName() { - return pvp2OrgName; - } - - /** - * @param pvp2OrgName the pvp2OrgName to set - */ - public void setPvp2OrgName(String pvp2OrgName) { - this.pvp2OrgName = pvp2OrgName; - } - - /** - * @return the pvp2OrgDisplayName - */ - public String getPvp2OrgDisplayName() { - return pvp2OrgDisplayName; - } - - /** - * @param pvp2OrgDisplayName the pvp2OrgDisplayName to set - */ - public void setPvp2OrgDisplayName(String pvp2OrgDisplayName) { - this.pvp2OrgDisplayName = pvp2OrgDisplayName; - } - - /** - * @return the pvp2OrgURL - */ - public String getPvp2OrgURL() { - return pvp2OrgURL; - } - - /** - * @param pvp2OrgURL the pvp2OrgURL to set - */ - public void setPvp2OrgURL(String pvp2OrgURL) { - this.pvp2OrgURL = pvp2OrgURL; - } - - /** - * @return the pvp2Contact - */ - public ContactForm getPvp2Contact() { - return pvp2Contact; - } - - /** - * @param pvp2Contact the pvp2Contact to set - */ - public void setPvp2Contact(ContactForm pvp2Contact) { - this.pvp2Contact = pvp2Contact; - } - - /** - * @return the fileUpload - */ - public List<File> getFileUpload() { - return fileUpload; - } - - /** - * @param fileUpload the fileUpload to set - */ - public void setFileUpload(List<File> fileUpload) { - this.fileUpload = fileUpload; - } - - /** - * @return the fileUploadContentType - */ - public List<String> getFileUploadContentType() { - return fileUploadContentType; - } - - /** - * @param fileUploadContentType the fileUploadContentType to set - */ - public void setFileUploadContentType(List<String> fileUploadContentType) { - this.fileUploadContentType = fileUploadContentType; - } - - /** - * @return the fileUploadFileName - */ - public List<String> getFileUploadFileName() { - return fileUploadFileName; - } - - /** - * @param fileUploadFileName the fileUploadFileName to set - */ - public void setFileUploadFileName(List<String> fileUploadFileName) { - this.fileUploadFileName = fileUploadFileName; - } - - /** - * @return the ssoTarget - */ - public String getSsoTarget() { - return ssoTarget; - } - - /** - * @param ssoTarget the ssoTarget to set - */ - public void setSsoTarget(String ssoTarget) { - this.ssoTarget = ssoTarget; - } - - /** - * @return the ssoFriendlyName - */ - public String getSsoFriendlyName() { - return ssoFriendlyName; - } - - /** - * @param ssoFriendlyName the ssoFriendlyName to set - */ - public void setSsoFriendlyName(String ssoFriendlyName) { - this.ssoFriendlyName = ssoFriendlyName; - } - - /** - * @return the ssoSpecialText - */ - public String getSsoSpecialText() { - return ssoSpecialText; - } - - /** - * @param ssoSpecialText the ssoSpecialText to set - */ - public void setSsoSpecialText(String ssoSpecialText) { - this.ssoSpecialText = ssoSpecialText; - } - - /** - * @return the ssoIdentificationNumber - */ - public String getSsoIdentificationNumber() { - return ssoIdentificationNumber; - } - - /** - * @param ssoIdentificationNumber the ssoIdentificationNumber to set - */ - public void setSsoIdentificationNumber(String ssoIdentificationNumber) { - this.ssoIdentificationNumber = ssoIdentificationNumber; - } - - /** - * @return the defaultchainigmode - */ - public String getDefaultchainigmode() { - return defaultchainigmode; - } - - /** - * @param defaultchainigmode the defaultchainigmode to set - */ - public void setDefaultchainigmode(String defaultchainigmode) { - this.defaultchainigmode = defaultchainigmode; - } - - /** - * @return the defaultBKUOnline - */ - public String getDefaultBKUOnline() { - return defaultBKUOnline; - } - - /** - * @param defaultBKUOnline the defaultBKUOnline to set - */ - public void setDefaultBKUOnline(String defaultBKUOnline) { - this.defaultBKUOnline = defaultBKUOnline; - } - - /** - * @return the defaultBKULocal - */ - public String getDefaultBKULocal() { - return defaultBKULocal; - } - - /** - * @param defaultBKULocal the defaultBKULocal to set - */ - public void setDefaultBKULocal(String defaultBKULocal) { - this.defaultBKULocal = defaultBKULocal; - } - - /** - * @return the defaultBKUHandy - */ - public String getDefaultBKUHandy() { - return defaultBKUHandy; - } - - /** - * @param defaultBKUHandy the defaultBKUHandy to set - */ - public void setDefaultBKUHandy(String defaultBKUHandy) { - this.defaultBKUHandy = defaultBKUHandy; - } - - /** - * @return the sLRequestTemplateOnline - */ - public String getSLRequestTemplateOnline() { - return SLRequestTemplateOnline; - } - - /** - * @param sLRequestTemplateOnline the sLRequestTemplateOnline to set - */ - public void setSLRequestTemplateOnline(String sLRequestTemplateOnline) { - SLRequestTemplateOnline = sLRequestTemplateOnline; - } - - /** - * @return the sLRequestTemplateLocal - */ - public String getSLRequestTemplateLocal() { - return SLRequestTemplateLocal; - } - - /** - * @param sLRequestTemplateLocal the sLRequestTemplateLocal to set - */ - public void setSLRequestTemplateLocal(String sLRequestTemplateLocal) { - SLRequestTemplateLocal = sLRequestTemplateLocal; - } - - /** - * @return the sLRequestTemplateHandy - */ - public String getSLRequestTemplateHandy() { - return SLRequestTemplateHandy; - } - - /** - * @param sLRequestTemplateHandy the sLRequestTemplateHandy to set - */ - public void setSLRequestTemplateHandy(String sLRequestTemplateHandy) { - SLRequestTemplateHandy = sLRequestTemplateHandy; - } - - /** - * @return the trustmanagerrevocationcheck - */ - public boolean isTrustmanagerrevocationcheck() { - return trustmanagerrevocationcheck; - } - - /** - * @param trustmanagerrevocationcheck the trustmanagerrevocationcheck to set - */ - public void setTrustmanagerrevocationcheck(boolean trustmanagerrevocationcheck) { - this.trustmanagerrevocationcheck = trustmanagerrevocationcheck; - } - - /** - * @return the trustedCACerts - */ - public String getTrustedCACerts() { - return trustedCACerts; - } - - /** - * @param trustedCACerts the trustedCACerts to set - */ - public void setTrustedCACerts(String trustedCACerts) { - this.trustedCACerts = trustedCACerts; - } - - /** - * @return the chainigmodelist - */ - public Map<String, String> getChainigmodelist() { - return chainigmodelist; - } - - /** - * @param chainigmodelist the chainigmodelist to set - */ - public void setChainigmodelist(Map<String, String> chainigmodelist) { - GeneralMOAIDConfig.chainigmodelist = chainigmodelist; - } - - /** - * @return the secLayerTransformation - */ - public Map<String, byte[]> getSecLayerTransformation() { - - return secLayerTransformation; - } - - /** - * @param secLayerTransformation the secLayerTransformation to set - */ - public void setSecLayerTransformation(Map<String, byte[]> secLayerTransformation) { - this.secLayerTransformation = secLayerTransformation; - } - - /** - * @return the authTransformList - */ - public List<String> getAuthTransformList() { - return authTransformList; - } - - /** - * @param authTransformList the authTransformList to set - */ - public void setAuthTransformList(List<String> authTransformList) { - this.authTransformList = authTransformList; - } - - - - - public void setFileUpload(File fileUpload) { - if (this.fileUpload == null) - this.fileUpload = new ArrayList<File>(); - this.fileUpload.add(fileUpload); - } - - public void setFileUploadContentType(String fileUploadContentType) { - if (this.fileUploadContentType == null) - this.fileUploadContentType = new ArrayList<String>(); - this.fileUploadContentType.add(fileUploadContentType); - } - - public void setFileUploadFileName(String fileUploadFileName) { - if (this.fileUploadFileName == null) - this.fileUploadFileName = new ArrayList<String>(); - this.fileUploadFileName.add(fileUploadFileName); - } - - /** - * @return the protocolActiveSAML1 - */ - public boolean isProtocolActiveSAML1() { - return protocolActiveSAML1; - } - - /** - * @param protocolActiveSAML1 the protocolActiveSAML1 to set - */ - public void setProtocolActiveSAML1(boolean protocolActiveSAML1) { - this.protocolActiveSAML1 = protocolActiveSAML1; - } - - /** - * @return the protocolActivePVP21 - */ - public boolean isProtocolActivePVP21() { - return protocolActivePVP21; - } - - /** - * @param protocolActivePVP21 the protocolActivePVP21 to set - */ - public void setProtocolActivePVP21(boolean protocolActivePVP21) { - this.protocolActivePVP21 = protocolActivePVP21; - } - - /** - * @return the protocolActiveOAuth - */ - public boolean isProtocolActiveOAuth() { - return protocolActiveOAuth; - } - - /** - * @param protocolActiveOAuth the protocolActiveOAuth to set - */ - public void setProtocolActiveOAuth(boolean protocolActiveOAuth) { - this.protocolActiveOAuth = protocolActiveOAuth; - } - - /** - * @return the saml1SourceID - */ - public String getSaml1SourceID() { - return saml1SourceID; - } - - /** - * @param saml1SourceID the saml1SourceID to set - */ - public void setSaml1SourceID(String saml1SourceID) { - this.saml1SourceID = saml1SourceID; - } - - /** - * @return the publicURLPrefix - */ - public String getPublicURLPrefix() { - return publicURLPrefix; - } - - /** - * @param publicURLPrefix the publicURLPrefix to set - */ - public void setPublicURLPrefix(String publicURLPrefix) { - if (MiscUtil.isNotEmpty(publicURLPrefix)) - this.publicURLPrefix = - KeyValueUtils.removeAllNewlineFromString(publicURLPrefix); - else - this.publicURLPrefix = publicURLPrefix; - - } - - /** - * @return the moaspssIdlTrustProfileTest - */ - public String getMoaspssIdlTrustProfileTest() { - return moaspssIdlTrustProfileTest; - } - - /** - * @param moaspssIdlTrustProfileTest the moaspssIdlTrustProfileTest to set - */ - public void setMoaspssIdlTrustProfileTest(String moaspssIdlTrustProfileTest) { - this.moaspssIdlTrustProfileTest = moaspssIdlTrustProfileTest; - } - - /** - * @return the moaspssAuthTrustProfileTest - */ - public String getMoaspssAuthTrustProfileTest() { - return moaspssAuthTrustProfileTest; - } - - /** - * @param moaspssAuthTrustProfileTest the moaspssAuthTrustProfileTest to set - */ - public void setMoaspssAuthTrustProfileTest(String moaspssAuthTrustProfileTest) { - this.moaspssAuthTrustProfileTest = moaspssAuthTrustProfileTest; - } - - /** - * @return the virtualPublicURLPrefixEnabled - */ - public boolean isVirtualPublicURLPrefixEnabled() { - return virtualPublicURLPrefixEnabled; - } - - /** - * @param virtualPublicURLPrefixEnabled the virtualPublicURLPrefixEnabled to set - */ - public void setVirtualPublicURLPrefixEnabled( - boolean virtualPublicURLPrefixEnabled) { - this.virtualPublicURLPrefixEnabled = virtualPublicURLPrefixEnabled; - } - - /** - * @return the elgaMandateServiceURL - */ - public String getElgaMandateServiceURL() { - return elgaMandateServiceURL; - } - - /** - * @param elgaMandateServiceURL the elgaMandateServiceURL to set - */ - public void setElgaMandateServiceURL(String elgaMandateServiceURL) { - if (MiscUtil.isNotEmpty(elgaMandateServiceURL)) - this.elgaMandateServiceURL = KeyValueUtils.removeAllNewlineFromString(elgaMandateServiceURL); - else - this.elgaMandateServiceURL = elgaMandateServiceURL; - } - - /** - * @return the eidSystemServiceURL - */ - public String getEidSystemServiceURL() { - return eidSystemServiceURL; - } - - public boolean isMoaidMode() { - return moaidMode; - } - - /** - * @param eidSystemServiceURL the E-ID Service URL to set - */ - public void setEidSystemServiceURL(String eidSystemServiceURL) { - if (MiscUtil.isNotEmpty(eidSystemServiceURL)) - this.eidSystemServiceURL = KeyValueUtils.removeAllNewlineFromString(eidSystemServiceURL); - else - this.eidSystemServiceURL = eidSystemServiceURL; - } - - + /** + * @return the timeoutAssertion + */ + public String getTimeoutAssertion() { + return timeoutAssertion; + } + + /** + * @param timeoutAssertion the timeoutAssertion to set + */ + public void setTimeoutAssertion(String timeoutAssertion) { + this.timeoutAssertion = timeoutAssertion; + } + + /** + * @return the timeoutMOASessionCreated + */ + public String getTimeoutMOASessionCreated() { + return timeoutMOASessionCreated; + } + + /** + * @param timeoutMOASessionCreated the timeoutMOASessionCreated to set + */ + public void setTimeoutMOASessionCreated(String timeoutMOASessionCreated) { + this.timeoutMOASessionCreated = timeoutMOASessionCreated; + } + + /** + * @return the timeoutMOASessionUpdated + */ + public String getTimeoutMOASessionUpdated() { + return timeoutMOASessionUpdated; + } + + /** + * @param timeoutMOASessionUpdated the timeoutMOASessionUpdated to set + */ + public void setTimeoutMOASessionUpdated(String timeoutMOASessionUpdated) { + this.timeoutMOASessionUpdated = timeoutMOASessionUpdated; + } + + /** + * @return the moaspssURL + */ + public String getMoaspssURL() { + return moaspssURL; + } + + /** + * @param moaspssURL the moaspssURL to set + */ + public void setMoaspssURL(String moaspssURL) { + this.moaspssURL = moaspssURL; + } + + /** + * @return the moaspssAuthTrustProfile + */ + public String getMoaspssAuthTrustProfile() { + return moaspssAuthTrustProfile; + } + + /** + * @param moaspssAuthTrustProfile the moaspssAuthTrustProfile to set + */ + public void setMoaspssAuthTrustProfile(String moaspssAuthTrustProfile) { + this.moaspssAuthTrustProfile = moaspssAuthTrustProfile; + } + + /** + * @return the moaspssAuthTransformations + */ + public String getMoaspssAuthTransformations() { + return moaspssAuthTransformations; + } + + /** + * @param moaspssAuthTransformations the moaspssAuthTransformations to set + */ + public void setMoaspssAuthTransformations(String moaspssAuthTransformations) { + this.moaspssAuthTransformations = moaspssAuthTransformations; + } + + /** + * @return the moaspssIdlTrustProfile + */ + public String getMoaspssIdlTrustProfile() { + return moaspssIdlTrustProfile; + } + + /** + * @param moaspssIdlTrustProfile the moaspssIdlTrustProfile to set + */ + public void setMoaspssIdlTrustProfile(String moaspssIdlTrustProfile) { + this.moaspssIdlTrustProfile = moaspssIdlTrustProfile; + } + + /** + * @return the mandateURL + */ + public String getMandateURL() { + return mandateURL; + } + + /** + * @param mandateURL the mandateURL to set + */ + public void setMandateURL(String mandateURL) { + if (MiscUtil.isNotEmpty(mandateURL)) { + this.mandateURL = KeyValueUtils.removeAllNewlineFromString(mandateURL); + } else { + this.mandateURL = mandateURL; + } + } + + /** + * @return the legacy_saml1 + */ + public boolean isLegacy_saml1() { + return legacy_saml1; + } + + /** + * @param legacy_saml1 the legacy_saml1 to set + */ + public void setLegacy_saml1(boolean legacy_saml1) { + this.legacy_saml1 = legacy_saml1; + } + + /** + * @return the legacy_pvp2 + */ + public boolean isLegacy_pvp2() { + return legacy_pvp2; + } + + /** + * @param legacy_pvp2 the legacy_pvp2 to set + */ + public void setLegacy_pvp2(boolean legacy_pvp2) { + this.legacy_pvp2 = legacy_pvp2; + } + + /** + * @return the pvp2IssuerName + */ + public String getPvp2IssuerName() { + return pvp2IssuerName; + } + + /** + * @param pvp2IssuerName the pvp2IssuerName to set + */ + public void setPvp2IssuerName(String pvp2IssuerName) { + this.pvp2IssuerName = pvp2IssuerName; + } + + /** + * @return the pvp2OrgName + */ + public String getPvp2OrgName() { + return pvp2OrgName; + } + + /** + * @param pvp2OrgName the pvp2OrgName to set + */ + public void setPvp2OrgName(String pvp2OrgName) { + this.pvp2OrgName = pvp2OrgName; + } + + /** + * @return the pvp2OrgDisplayName + */ + public String getPvp2OrgDisplayName() { + return pvp2OrgDisplayName; + } + + /** + * @param pvp2OrgDisplayName the pvp2OrgDisplayName to set + */ + public void setPvp2OrgDisplayName(String pvp2OrgDisplayName) { + this.pvp2OrgDisplayName = pvp2OrgDisplayName; + } + + /** + * @return the pvp2OrgURL + */ + public String getPvp2OrgURL() { + return pvp2OrgURL; + } + + /** + * @param pvp2OrgURL the pvp2OrgURL to set + */ + public void setPvp2OrgURL(String pvp2OrgURL) { + this.pvp2OrgURL = pvp2OrgURL; + } + + /** + * @return the pvp2Contact + */ + public ContactForm getPvp2Contact() { + return pvp2Contact; + } + + /** + * @param pvp2Contact the pvp2Contact to set + */ + public void setPvp2Contact(ContactForm pvp2Contact) { + this.pvp2Contact = pvp2Contact; + } + + /** + * @return the fileUpload + */ + public List<File> getFileUpload() { + return fileUpload; + } + + /** + * @param fileUpload the fileUpload to set + */ + public void setFileUpload(List<File> fileUpload) { + this.fileUpload = fileUpload; + } + + /** + * @return the fileUploadContentType + */ + public List<String> getFileUploadContentType() { + return fileUploadContentType; + } + + /** + * @param fileUploadContentType the fileUploadContentType to set + */ + public void setFileUploadContentType(List<String> fileUploadContentType) { + this.fileUploadContentType = fileUploadContentType; + } + + /** + * @return the fileUploadFileName + */ + public List<String> getFileUploadFileName() { + return fileUploadFileName; + } + + /** + * @param fileUploadFileName the fileUploadFileName to set + */ + public void setFileUploadFileName(List<String> fileUploadFileName) { + this.fileUploadFileName = fileUploadFileName; + } + + /** + * @return the ssoTarget + */ + public String getSsoTarget() { + return ssoTarget; + } + + /** + * @param ssoTarget the ssoTarget to set + */ + public void setSsoTarget(String ssoTarget) { + this.ssoTarget = ssoTarget; + } + + /** + * @return the ssoFriendlyName + */ + public String getSsoFriendlyName() { + return ssoFriendlyName; + } + + /** + * @param ssoFriendlyName the ssoFriendlyName to set + */ + public void setSsoFriendlyName(String ssoFriendlyName) { + this.ssoFriendlyName = ssoFriendlyName; + } + + /** + * @return the ssoSpecialText + */ + public String getSsoSpecialText() { + return ssoSpecialText; + } + + /** + * @param ssoSpecialText the ssoSpecialText to set + */ + public void setSsoSpecialText(String ssoSpecialText) { + this.ssoSpecialText = ssoSpecialText; + } + + /** + * @return the ssoIdentificationNumber + */ + public String getSsoIdentificationNumber() { + return ssoIdentificationNumber; + } + + /** + * @param ssoIdentificationNumber the ssoIdentificationNumber to set + */ + public void setSsoIdentificationNumber(String ssoIdentificationNumber) { + this.ssoIdentificationNumber = ssoIdentificationNumber; + } + + /** + * @return the defaultchainigmode + */ + public String getDefaultchainigmode() { + return defaultchainigmode; + } + + /** + * @param defaultchainigmode the defaultchainigmode to set + */ + public void setDefaultchainigmode(String defaultchainigmode) { + this.defaultchainigmode = defaultchainigmode; + } + + /** + * @return the defaultBKUOnline + */ + public String getDefaultBKUOnline() { + return defaultBKUOnline; + } + + /** + * @param defaultBKUOnline the defaultBKUOnline to set + */ + public void setDefaultBKUOnline(String defaultBKUOnline) { + this.defaultBKUOnline = defaultBKUOnline; + } + + /** + * @return the defaultBKULocal + */ + public String getDefaultBKULocal() { + return defaultBKULocal; + } + + /** + * @param defaultBKULocal the defaultBKULocal to set + */ + public void setDefaultBKULocal(String defaultBKULocal) { + this.defaultBKULocal = defaultBKULocal; + } + + /** + * @return the defaultBKUHandy + */ + public String getDefaultBKUHandy() { + return defaultBKUHandy; + } + + /** + * @param defaultBKUHandy the defaultBKUHandy to set + */ + public void setDefaultBKUHandy(String defaultBKUHandy) { + this.defaultBKUHandy = defaultBKUHandy; + } + + /** + * @return the sLRequestTemplateOnline + */ + public String getSLRequestTemplateOnline() { + return SLRequestTemplateOnline; + } + + /** + * @param sLRequestTemplateOnline the sLRequestTemplateOnline to set + */ + public void setSLRequestTemplateOnline(String sLRequestTemplateOnline) { + SLRequestTemplateOnline = sLRequestTemplateOnline; + } + + /** + * @return the sLRequestTemplateLocal + */ + public String getSLRequestTemplateLocal() { + return SLRequestTemplateLocal; + } + + /** + * @param sLRequestTemplateLocal the sLRequestTemplateLocal to set + */ + public void setSLRequestTemplateLocal(String sLRequestTemplateLocal) { + SLRequestTemplateLocal = sLRequestTemplateLocal; + } + + /** + * @return the sLRequestTemplateHandy + */ + public String getSLRequestTemplateHandy() { + return SLRequestTemplateHandy; + } + + /** + * @param sLRequestTemplateHandy the sLRequestTemplateHandy to set + */ + public void setSLRequestTemplateHandy(String sLRequestTemplateHandy) { + SLRequestTemplateHandy = sLRequestTemplateHandy; + } + + /** + * @return the trustmanagerrevocationcheck + */ + public boolean isTrustmanagerrevocationcheck() { + return trustmanagerrevocationcheck; + } + + /** + * @param trustmanagerrevocationcheck the trustmanagerrevocationcheck to set + */ + public void setTrustmanagerrevocationcheck(boolean trustmanagerrevocationcheck) { + this.trustmanagerrevocationcheck = trustmanagerrevocationcheck; + } + + /** + * @return the trustedCACerts + */ + public String getTrustedCACerts() { + return trustedCACerts; + } + + /** + * @param trustedCACerts the trustedCACerts to set + */ + public void setTrustedCACerts(String trustedCACerts) { + this.trustedCACerts = trustedCACerts; + } + + /** + * @return the chainigmodelist + */ + public Map<String, String> getChainigmodelist() { + return chainigmodelist; + } + + /** + * @param chainigmodelist the chainigmodelist to set + */ + public void setChainigmodelist(Map<String, String> chainigmodelist) { + GeneralMOAIDConfig.chainigmodelist = chainigmodelist; + } + + /** + * @return the secLayerTransformation + */ + public Map<String, byte[]> getSecLayerTransformation() { + + return secLayerTransformation; + } + + /** + * @param secLayerTransformation the secLayerTransformation to set + */ + public void setSecLayerTransformation(Map<String, byte[]> secLayerTransformation) { + this.secLayerTransformation = secLayerTransformation; + } + + /** + * @return the authTransformList + */ + public List<String> getAuthTransformList() { + return authTransformList; + } + + /** + * @param authTransformList the authTransformList to set + */ + public void setAuthTransformList(List<String> authTransformList) { + this.authTransformList = authTransformList; + } + + public void setFileUpload(File fileUpload) { + if (this.fileUpload == null) { + this.fileUpload = new ArrayList<>(); + } + this.fileUpload.add(fileUpload); + } + + public void setFileUploadContentType(String fileUploadContentType) { + if (this.fileUploadContentType == null) { + this.fileUploadContentType = new ArrayList<>(); + } + this.fileUploadContentType.add(fileUploadContentType); + } + + public void setFileUploadFileName(String fileUploadFileName) { + if (this.fileUploadFileName == null) { + this.fileUploadFileName = new ArrayList<>(); + } + this.fileUploadFileName.add(fileUploadFileName); + } + + /** + * @return the protocolActiveSAML1 + */ + public boolean isProtocolActiveSAML1() { + return protocolActiveSAML1; + } + + /** + * @param protocolActiveSAML1 the protocolActiveSAML1 to set + */ + public void setProtocolActiveSAML1(boolean protocolActiveSAML1) { + this.protocolActiveSAML1 = protocolActiveSAML1; + } + + /** + * @return the protocolActivePVP21 + */ + public boolean isProtocolActivePVP21() { + return protocolActivePVP21; + } + + /** + * @param protocolActivePVP21 the protocolActivePVP21 to set + */ + public void setProtocolActivePVP21(boolean protocolActivePVP21) { + this.protocolActivePVP21 = protocolActivePVP21; + } + + /** + * @return the protocolActiveOAuth + */ + public boolean isProtocolActiveOAuth() { + return protocolActiveOAuth; + } + + /** + * @param protocolActiveOAuth the protocolActiveOAuth to set + */ + public void setProtocolActiveOAuth(boolean protocolActiveOAuth) { + this.protocolActiveOAuth = protocolActiveOAuth; + } + + /** + * @return the saml1SourceID + */ + public String getSaml1SourceID() { + return saml1SourceID; + } + + /** + * @param saml1SourceID the saml1SourceID to set + */ + public void setSaml1SourceID(String saml1SourceID) { + this.saml1SourceID = saml1SourceID; + } + + /** + * @return the publicURLPrefix + */ + public String getPublicURLPrefix() { + return publicURLPrefix; + } + + /** + * @param publicURLPrefix the publicURLPrefix to set + */ + public void setPublicURLPrefix(String publicURLPrefix) { + if (MiscUtil.isNotEmpty(publicURLPrefix)) { + this.publicURLPrefix = + KeyValueUtils.removeAllNewlineFromString(publicURLPrefix); + } else { + this.publicURLPrefix = publicURLPrefix; + } + + } + + /** + * @return the moaspssIdlTrustProfileTest + */ + public String getMoaspssIdlTrustProfileTest() { + return moaspssIdlTrustProfileTest; + } + + /** + * @param moaspssIdlTrustProfileTest the moaspssIdlTrustProfileTest to set + */ + public void setMoaspssIdlTrustProfileTest(String moaspssIdlTrustProfileTest) { + this.moaspssIdlTrustProfileTest = moaspssIdlTrustProfileTest; + } + + /** + * @return the moaspssAuthTrustProfileTest + */ + public String getMoaspssAuthTrustProfileTest() { + return moaspssAuthTrustProfileTest; + } + + /** + * @param moaspssAuthTrustProfileTest the moaspssAuthTrustProfileTest to set + */ + public void setMoaspssAuthTrustProfileTest(String moaspssAuthTrustProfileTest) { + this.moaspssAuthTrustProfileTest = moaspssAuthTrustProfileTest; + } + + /** + * @return the virtualPublicURLPrefixEnabled + */ + public boolean isVirtualPublicURLPrefixEnabled() { + return virtualPublicURLPrefixEnabled; + } + + /** + * @param virtualPublicURLPrefixEnabled the virtualPublicURLPrefixEnabled to set + */ + public void setVirtualPublicURLPrefixEnabled( + boolean virtualPublicURLPrefixEnabled) { + this.virtualPublicURLPrefixEnabled = virtualPublicURLPrefixEnabled; + } + + /** + * @return the elgaMandateServiceURL + */ + public String getElgaMandateServiceURL() { + return elgaMandateServiceURL; + } + + /** + * @param elgaMandateServiceURL the elgaMandateServiceURL to set + */ + public void setElgaMandateServiceURL(String elgaMandateServiceURL) { + if (MiscUtil.isNotEmpty(elgaMandateServiceURL)) { + this.elgaMandateServiceURL = KeyValueUtils.removeAllNewlineFromString(elgaMandateServiceURL); + } else { + this.elgaMandateServiceURL = elgaMandateServiceURL; + } + } + + /** + * @return the eidSystemServiceURL + */ + public String getEidSystemServiceURL() { + return eidSystemServiceURL; + } + + public boolean isMoaidMode() { + return moaidMode; + } + + /** + * @param eidSystemServiceURL the E-ID Service URL to set + */ + public void setEidSystemServiceURL(String eidSystemServiceURL) { + if (MiscUtil.isNotEmpty(eidSystemServiceURL)) { + this.eidSystemServiceURL = KeyValueUtils.removeAllNewlineFromString(eidSystemServiceURL); + } else { + this.eidSystemServiceURL = eidSystemServiceURL; + } + } + } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java index b5c996c72..c833372c9 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java @@ -25,8 +25,6 @@ package at.gv.egovernment.moa.id.configuration.data; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.commons.MOAIDConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; @@ -36,141 +34,147 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class GeneralStorkConfig { - private List<CPEPS> cpepslist; - private List<StorkAttribute> attributes; - private String qaa; - private static final Logger log = Logger.getLogger(GeneralStorkConfig.class); - - private MOAIDConfiguration dbconfig = null; - - /** - * - */ - public GeneralStorkConfig() { - try { - dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); - - } catch (ConfigurationException e) { - log.error("MOA-ID-Configuration initialization FAILED.", e); - - } - - } - - public void parse(MOAIDConfiguration config) { - log.info("Initializing general Stork config"); - - cpepslist = new ArrayList<CPEPS>(); - attributes = new ArrayList<StorkAttribute>(); - - if (config != null) { - AuthComponentGeneral auth = config.getAuthComponentGeneral(); - - if (auth != null) { - ForeignIdentities foreign = auth.getForeignIdentities(); - - if (foreign != null) { - STORK stork = foreign.getSTORK(); - - if (stork != null) { - // deep clone all the things - // to foreclose lazyloading session timeouts - if (stork.getCPEPS() != null) { - for(CPEPS current : stork.getCPEPS()) { - cpepslist.add(current); - } - } - - List<StorkAttribute> tmp = stork.getAttributes(); - if(null != tmp) { - - for(StorkAttribute current : tmp) - attributes.add(current); - } - - try { - qaa = stork.getGeneral_eIDAS_LOA(); - - } catch(NullPointerException e) { - qaa = MOAIDConstants.eIDAS_LOA_HIGH; - } - } - - } - } - } - - if (cpepslist.isEmpty()) { - CPEPS defaultCPEPS = new CPEPS(); - defaultCPEPS.setCountryCode("CC"); - defaultCPEPS.setURL("http://"); - defaultCPEPS.setSupportsXMLSignature(true); - cpepslist.add(defaultCPEPS ); - - } - if(attributes.isEmpty()) - attributes.add(new StorkAttribute()); - } - - public List<String> getAllowedLoALevels() { - return MOAIDConstants.ALLOWED_eIDAS_LOA; - } - - public List<CPEPS> getRawCPEPSList() { - return cpepslist; + private List<CPEPS> cpepslist; + private List<StorkAttribute> attributes; + private String qaa; + + private MOAIDConfiguration dbconfig = null; + + /** + * + */ + public GeneralStorkConfig() { + try { + dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); + + } catch (final ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + + } + + } + + public void parse(MOAIDConfiguration config) { + log.info("Initializing general Stork config"); + + cpepslist = new ArrayList<>(); + attributes = new ArrayList<>(); + + if (config != null) { + final AuthComponentGeneral auth = config.getAuthComponentGeneral(); + + if (auth != null) { + final ForeignIdentities foreign = auth.getForeignIdentities(); + + if (foreign != null) { + final STORK stork = foreign.getSTORK(); + + if (stork != null) { + // deep clone all the things + // to foreclose lazyloading session timeouts + if (stork.getCPEPS() != null) { + for (final CPEPS current : stork.getCPEPS()) { + cpepslist.add(current); + } + } + + final List<StorkAttribute> tmp = stork.getAttributes(); + if (null != tmp) { + + for (final StorkAttribute current : tmp) { + attributes.add(current); + } + } + + try { + qaa = stork.getGeneral_eIDAS_LOA(); + + } catch (final NullPointerException e) { + qaa = MOAIDConstants.eIDAS_LOA_HIGH; + } + } + + } + } } - - public List<CPEPS> getCpepslist() { - if (null == cpepslist) - return null; - - //MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); - - try { - List<CPEPS> cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS(); - - if (cpepss != null) { - // make CountryCode "readonly" - for (CPEPS newone : cpepslist) { - for (CPEPS current : cpepss) { - if (null != newone) - if (current.getHjid().equals(newone.getHjid())) { - newone.setCountryCode(current.getCountryCode()); - break; - } - } - } - } - - return cpepslist; - - } catch (NullPointerException e) { - return null; - - } - - } - - public void setCpepslist(List<CPEPS> list) { - cpepslist = list; - } - - public List<StorkAttribute> getAttributes() { - return attributes; - } - - public void setAttributes(List<StorkAttribute> attributes) { - this.attributes = attributes; - } - - public String getDefaultQaa() { - return qaa; - } - - public void setDefaultQaa(String qaa) { - this.qaa = qaa; - } + + if (cpepslist.isEmpty()) { + final CPEPS defaultCPEPS = new CPEPS(); + defaultCPEPS.setCountryCode("CC"); + defaultCPEPS.setURL("http://"); + defaultCPEPS.setSupportsXMLSignature(true); + cpepslist.add(defaultCPEPS); + + } + if (attributes.isEmpty()) { + attributes.add(new StorkAttribute()); + } + } + + public List<String> getAllowedLoALevels() { + return MOAIDConstants.ALLOWED_eIDAS_LOA; + } + + public List<CPEPS> getRawCPEPSList() { + return cpepslist; + } + + public List<CPEPS> getCpepslist() { + if (null == cpepslist) { + return null; + } + + // MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); + + try { + final List<CPEPS> cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() + .getCPEPS(); + + if (cpepss != null) { + // make CountryCode "readonly" + for (final CPEPS newone : cpepslist) { + for (final CPEPS current : cpepss) { + if (null != newone) { + if (current.getHjid().equals(newone.getHjid())) { + newone.setCountryCode(current.getCountryCode()); + break; + } + } + } + } + } + + return cpepslist; + + } catch (final NullPointerException e) { + return null; + + } + + } + + public void setCpepslist(List<CPEPS> list) { + cpepslist = list; + } + + public List<StorkAttribute> getAttributes() { + return attributes; + } + + public void setAttributes(List<StorkAttribute> attributes) { + this.attributes = attributes; + } + + public String getDefaultQaa() { + return qaa; + } + + public void setDefaultQaa(String qaa) { + this.qaa = qaa; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java index 28eba9f34..c7de7e369 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/OAListElement.java @@ -23,92 +23,103 @@ package at.gv.egovernment.moa.id.configuration.data; public class OAListElement { - - public enum ServiceType {OA, VIDP, IDP, GWAY} - - private long dataBaseID; - private String oaIdentifier; - private String oaFriendlyName; - private String oaType; - private boolean isActive; - private ServiceType serviceType; - - /** - * - */ - public OAListElement(ServiceType type) { - this.serviceType = type; - } - - - /** - * @return the dataBaseID - */ - public long getDataBaseID() { - return dataBaseID; - } - /** - * @param dataBaseID the dataBaseID to set - */ - public void setDataBaseID(long dataBaseID) { - this.dataBaseID = dataBaseID; - } - /** - * @return the oaIdentifier - */ - public String getOaIdentifier() { - return oaIdentifier; - } - /** - * @param oaIdentifier the oaIdentifier to set - */ - public void setOaIdentifier(String oaIdentifier) { - this.oaIdentifier = oaIdentifier; - } - /** - * @return the oaFriendlyName - */ - public String getOaFriendlyName() { - return oaFriendlyName; - } - /** - * @param oaFriendlyName the oaFriendlyName to set - */ - public void setOaFriendlyName(String oaFriendlyName) { - this.oaFriendlyName = oaFriendlyName; - } - /** - * @return the oaType - */ - public String getOaType() { - return oaType; - } - /** - * @param oaType the oaType to set - */ - public void setOaType(String oaType) { - this.oaType = oaType; - } - /** - * @return the isActive - */ - public boolean isActive() { - return isActive; - } - /** - * @param isActive the isActive to set - */ - public void setActive(boolean isActive) { - this.isActive = isActive; - } - - public String getIsActive(){ - return String.valueOf(isActive); - } - /** - * @return the serviceType - */ - public String getServiceType() { - return serviceType.name(); - } + + public enum ServiceType { + OA, VIDP, IDP, GWAY + } + + private long dataBaseID; + private String oaIdentifier; + private String oaFriendlyName; + private String oaType; + private boolean isActive; + private final ServiceType serviceType; + + /** + * + */ + public OAListElement(ServiceType type) { + this.serviceType = type; + } + + /** + * @return the dataBaseID + */ + public long getDataBaseID() { + return dataBaseID; + } + + /** + * @param dataBaseID the dataBaseID to set + */ + public void setDataBaseID(long dataBaseID) { + this.dataBaseID = dataBaseID; + } + + /** + * @return the oaIdentifier + */ + public String getOaIdentifier() { + return oaIdentifier; + } + + /** + * @param oaIdentifier the oaIdentifier to set + */ + public void setOaIdentifier(String oaIdentifier) { + this.oaIdentifier = oaIdentifier; + } + + /** + * @return the oaFriendlyName + */ + public String getOaFriendlyName() { + return oaFriendlyName; + } + + /** + * @param oaFriendlyName the oaFriendlyName to set + */ + public void setOaFriendlyName(String oaFriendlyName) { + this.oaFriendlyName = oaFriendlyName; + } + + /** + * @return the oaType + */ + public String getOaType() { + return oaType; + } + + /** + * @param oaType the oaType to set + */ + public void setOaType(String oaType) { + this.oaType = oaType; + } + + /** + * @return the isActive + */ + public boolean isActive() { + return isActive; + } + + /** + * @param isActive the isActive to set + */ + public void setActive(boolean isActive) { + this.isActive = isActive; + } + + public String getIsActive() { + return String.valueOf(isActive); + } + + /** + * @return the serviceType + */ + public String getServiceType() { + return serviceType.name(); + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/StorkAttributes.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/StorkAttributes.java index a1bcf4aa4..af4548779 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/StorkAttributes.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/StorkAttributes.java @@ -24,27 +24,25 @@ package at.gv.egovernment.moa.id.configuration.data; public class StorkAttributes { + public AttributValues eIdentifier; - public AttributValues eIdentifier; - - - public void parse() { - eIdentifier = AttributValues.MANDATORY; - } - - - public enum AttributValues { - MANDATORY, OPTIONAL, NOT; - - public String getValue() { - if (this == MANDATORY) - return MANDATORY.name(); - if (this == OPTIONAL) - return OPTIONAL.name(); - else - return NOT.name(); - } - } - -} + public void parse() { + eIdentifier = AttributValues.MANDATORY; + } + + public enum AttributValues { + MANDATORY, OPTIONAL, NOT; + public String getValue() { + if (this == MANDATORY) { + return MANDATORY.name(); + } + if (this == OPTIONAL) { + return OPTIONAL.name(); + } else { + return NOT.name(); + } + } + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/UserDatabaseFrom.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/UserDatabaseFrom.java index 8f4746d69..8f94fa642 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/UserDatabaseFrom.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/UserDatabaseFrom.java @@ -26,328 +26,310 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.UserDatabase; import at.gv.egovernment.moa.util.MiscUtil; public class UserDatabaseFrom { - - private String bpk; - private String familyName; - private String givenName; - private String institut; - private String mail; - private String phone; - private String username; - private String password; - private String password_second; - private boolean active = false; - private boolean admin = false; - private boolean passwordActive; - private boolean isusernamepasswordallowed = false; - private boolean isadminrequest = true; - private boolean ismandateuser = false; - private boolean isPVPGenerated; - private String userID = null; - - public UserDatabaseFrom() { - - } - - public UserDatabaseFrom(UserDatabase db) { - bpk = db.getBpk(); - familyName = db.getFamilyname(); - givenName = db.getGivenname(); - institut = db.getInstitut(); - mail = db.getMail(); - phone = db.getPhone(); - username = db.getUsername(); - - if (MiscUtil.isNotEmpty(db.getPassword())) - passwordActive = true; - else - passwordActive = false; - - active = db.isIsActive(); - admin = db.isIsAdmin(); - - if (db.isIsUsernamePasswordAllowed() != null) - isusernamepasswordallowed = db.isIsUsernamePasswordAllowed(); - else - isusernamepasswordallowed = true; - - if (db.isIsAdminRequest() != null) - isadminrequest = db.isIsAdminRequest(); - else - isadminrequest = false; - - if (db.isIsMandateUser() != null) - ismandateuser = db.isIsMandateUser(); - else - ismandateuser = false; - - if (db.isIsPVP2Generated() != null) - isPVPGenerated = db.isIsPVP2Generated(); - else - isPVPGenerated = false; - - userID = String.valueOf(db.getHjid()); - } - - - /** - * @return the bpk - */ - public String getBpk() { - return bpk; - } - - - /** - * @param bpk the bpk to set - */ - public void setBpk(String bpk) { - this.bpk = bpk; - } - - - /** - * @return the familyName - */ - public String getFamilyName() { - return familyName; - } - - - /** - * @param familyName the familyName to set - */ - public void setFamilyName(String familyName) { - this.familyName = familyName; - } - - - /** - * @return the givenName - */ - public String getGivenName() { - return givenName; - } - - - /** - * @param givenName the givenName to set - */ - public void setGivenName(String givenName) { - this.givenName = givenName; - } - - - /** - * @return the institut - */ - public String getInstitut() { - return institut; - } - - - /** - * @param institut the institut to set - */ - public void setInstitut(String institut) { - this.institut = institut; - } - - - /** - * @return the mail - */ - public String getMail() { - return mail; - } - - - /** - * @param mail the mail to set - */ - public void setMail(String mail) { - this.mail = mail; - } - - - /** - * @return the phone - */ - public String getPhone() { - return phone; - } - - - /** - * @param phone the phone to set - */ - public void setPhone(String phone) { - this.phone = phone; - } - - - /** - * @return the username - */ - public String getUsername() { - return username; - } - - - /** - * @param username the username to set - */ - public void setUsername(String username) { - this.username = username; - } - - - /** - * @return the password - */ - public String getPassword() { - return password; - } - - - /** - * @param password the password to set - */ - public void setPassword(String password) { - this.password = password; - } - - - /** - * @return the active - */ - public boolean isActive() { - return active; - } - - - /** - * @param active the active to set - */ - public void setActive(boolean active) { - this.active = active; - } - - - /** - * @return the admin - */ - public boolean isAdmin() { - return admin; - } - - - /** - * @param admin the admin to set - */ - public void setAdmin(boolean admin) { - this.admin = admin; - } - - - /** - * @return the passwordActive - */ - public boolean isPasswordActive() { - return passwordActive; - } - - - /** - * @param passwordActive the passwordActive to set - */ - public void setPasswordActive(boolean passwordActive) { - this.passwordActive = passwordActive; - } - - /** - * @return the userID - */ - public String getUserID() { - return userID; - } - - /** - * @param userID the userID to set - */ - public void setUserID(String userID) { - this.userID = userID; - } - - /** - * @return the password_second - */ - public String getPassword_second() { - return password_second; - } - - /** - * @param password_second the password_second to set - */ - public void setPassword_second(String password_second) { - this.password_second = password_second; - } - - /** - * @return the isusernamepasswordallowed - */ - public boolean isIsusernamepasswordallowed() { - return isusernamepasswordallowed; - } - - /** - * @param isusernamepasswordallowed the isusernamepasswordallowed to set - */ - public void setIsusernamepasswordallowed(boolean isusernamepasswordallowed) { - this.isusernamepasswordallowed = isusernamepasswordallowed; - } - - /** - * @return the ismandateuser - */ - public boolean isIsmandateuser() { - return ismandateuser; - } - - - /** - * @param ismandateuser the ismandateuser to set - */ - public void setIsmandateuser(boolean ismandateuser) { - this.ismandateuser = ismandateuser; - } - - /** - * @return the isadminrequest - */ - public boolean isIsadminrequest() { - return isadminrequest; - } - - /** - * @param isadminrequest the isadminrequest to set - */ - public void setIsadminrequest(boolean isadminrequest) { - this.isadminrequest = isadminrequest; - } - - /** - * @return the isPVPGenerated - */ - public boolean isPVPGenerated() { - return isPVPGenerated; - } - - /** - * @param isPVPGenerated the isPVPGenerated to set - */ - public void setPVPGenerated(boolean isPVPGenerated) { - this.isPVPGenerated = isPVPGenerated; - } - + + private String bpk; + private String familyName; + private String givenName; + private String institut; + private String mail; + private String phone; + private String username; + private String password; + private String password_second; + private boolean active = false; + private boolean admin = false; + private boolean passwordActive; + private boolean isusernamepasswordallowed = false; + private boolean isadminrequest = true; + private boolean ismandateuser = false; + private boolean isPVPGenerated; + private String userID = null; + + public UserDatabaseFrom() { + + } + + public UserDatabaseFrom(UserDatabase db) { + bpk = db.getBpk(); + familyName = db.getFamilyname(); + givenName = db.getGivenname(); + institut = db.getInstitut(); + mail = db.getMail(); + phone = db.getPhone(); + username = db.getUsername(); + + if (MiscUtil.isNotEmpty(db.getPassword())) { + passwordActive = true; + } else { + passwordActive = false; + } + + active = db.isIsActive(); + admin = db.isIsAdmin(); + + if (db.isIsUsernamePasswordAllowed() != null) { + isusernamepasswordallowed = db.isIsUsernamePasswordAllowed(); + } else { + isusernamepasswordallowed = true; + } + + if (db.isIsAdminRequest() != null) { + isadminrequest = db.isIsAdminRequest(); + } else { + isadminrequest = false; + } + + if (db.isIsMandateUser() != null) { + ismandateuser = db.isIsMandateUser(); + } else { + ismandateuser = false; + } + + if (db.isIsPVP2Generated() != null) { + isPVPGenerated = db.isIsPVP2Generated(); + } else { + isPVPGenerated = false; + } + + userID = String.valueOf(db.getHjid()); + } + + /** + * @return the bpk + */ + public String getBpk() { + return bpk; + } + + /** + * @param bpk the bpk to set + */ + public void setBpk(String bpk) { + this.bpk = bpk; + } + + /** + * @return the familyName + */ + public String getFamilyName() { + return familyName; + } + + /** + * @param familyName the familyName to set + */ + public void setFamilyName(String familyName) { + this.familyName = familyName; + } + + /** + * @return the givenName + */ + public String getGivenName() { + return givenName; + } + + /** + * @param givenName the givenName to set + */ + public void setGivenName(String givenName) { + this.givenName = givenName; + } + + /** + * @return the institut + */ + public String getInstitut() { + return institut; + } + + /** + * @param institut the institut to set + */ + public void setInstitut(String institut) { + this.institut = institut; + } + + /** + * @return the mail + */ + public String getMail() { + return mail; + } + + /** + * @param mail the mail to set + */ + public void setMail(String mail) { + this.mail = mail; + } + + /** + * @return the phone + */ + public String getPhone() { + return phone; + } + + /** + * @param phone the phone to set + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @param username the username to set + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * @param password the password to set + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * @return the active + */ + public boolean isActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(boolean active) { + this.active = active; + } + + /** + * @return the admin + */ + public boolean isAdmin() { + return admin; + } + + /** + * @param admin the admin to set + */ + public void setAdmin(boolean admin) { + this.admin = admin; + } + + /** + * @return the passwordActive + */ + public boolean isPasswordActive() { + return passwordActive; + } + + /** + * @param passwordActive the passwordActive to set + */ + public void setPasswordActive(boolean passwordActive) { + this.passwordActive = passwordActive; + } + + /** + * @return the userID + */ + public String getUserID() { + return userID; + } + + /** + * @param userID the userID to set + */ + public void setUserID(String userID) { + this.userID = userID; + } + + /** + * @return the password_second + */ + public String getPassword_second() { + return password_second; + } + + /** + * @param password_second the password_second to set + */ + public void setPassword_second(String password_second) { + this.password_second = password_second; + } + + /** + * @return the isusernamepasswordallowed + */ + public boolean isIsusernamepasswordallowed() { + return isusernamepasswordallowed; + } + + /** + * @param isusernamepasswordallowed the isusernamepasswordallowed to set + */ + public void setIsusernamepasswordallowed(boolean isusernamepasswordallowed) { + this.isusernamepasswordallowed = isusernamepasswordallowed; + } + + /** + * @return the ismandateuser + */ + public boolean isIsmandateuser() { + return ismandateuser; + } + + /** + * @param ismandateuser the ismandateuser to set + */ + public void setIsmandateuser(boolean ismandateuser) { + this.ismandateuser = ismandateuser; + } + + /** + * @return the isadminrequest + */ + public boolean isIsadminrequest() { + return isadminrequest; + } + + /** + * @param isadminrequest the isadminrequest to set + */ + public void setIsadminrequest(boolean isadminrequest) { + this.isadminrequest = isadminrequest; + } + + /** + * @return the isPVPGenerated + */ + public boolean isPVPGenerated() { + return isPVPGenerated; + } + + /** + * @param isPVPGenerated the isPVPGenerated to set + */ + public void setPVPGenerated(boolean isPVPGenerated) { + this.isPVPGenerated = isPVPGenerated; + } + } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java index 63c82037f..c2344e059 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/AttributeHelper.java @@ -4,61 +4,61 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAStorkAttribut import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; public class AttributeHelper { - private boolean isUsed = false; - private String name; - private boolean mandatory; - private boolean readonly; + private boolean isUsed = false; + private String name; + private boolean mandatory; + private boolean readonly; - public AttributeHelper() { - // TODO Auto-generated constructor stub - } + public AttributeHelper() { + // TODO Auto-generated constructor stub + } - public AttributeHelper(OAStorkAttribute attribute) { - isUsed = true; - name = attribute.getName(); - mandatory = attribute.isMandatory(); - } + public AttributeHelper(OAStorkAttribute attribute) { + isUsed = true; + name = attribute.getName(); + mandatory = attribute.isMandatory(); + } - public AttributeHelper(StorkAttribute attribute) { - name = attribute.getName(); - mandatory = false; - if (attribute.isMandatory()==null) { // TODO check details - attribute.setMandatory(false); - } else { - readonly = attribute.isMandatory(); - } - isUsed = readonly; - } + public AttributeHelper(StorkAttribute attribute) { + name = attribute.getName(); + mandatory = false; + if (attribute.isMandatory() == null) { // TODO check details + attribute.setMandatory(false); + } else { + readonly = attribute.isMandatory(); + } + isUsed = readonly; + } - public boolean isUsed() { - return isUsed; - } + public boolean isUsed() { + return isUsed; + } - public void setUsed(boolean used) { - isUsed = used; - } + public void setUsed(boolean used) { + isUsed = used; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String newname) { - name = newname; - } + public void setName(String newname) { + name = newname; + } - public boolean isMandatory() { - return mandatory; - } + public boolean isMandatory() { + return mandatory; + } - public void setMandatory(boolean value) { - mandatory = value; - } + public void setMandatory(boolean value) { + mandatory = value; + } - public boolean isReadOnly() { - return readonly; - } + public boolean isReadOnly() { + return readonly; + } - public void setReadOnly(boolean value) { - // we do not allow setting the readonly field - } + public void setReadOnly(boolean value) { + // we do not allow setting the readonly field + } }
\ No newline at end of file diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java index 8195c993d..0ba3ed36c 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/IOnlineApplicationData.java @@ -34,31 +34,34 @@ import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; * */ public interface IOnlineApplicationData { - - public String getName(); - - /** - * Parse OnlineApplication database object to formData - * @param dbOAConfig - * @return List of Errors - */ - public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request); - - /** - * Store formData to OnlineApplication database object - * @param dboa: Database data object - * @param authUser - * @param request: - * @return Error description - */ - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request); - - /** - * Validate formData - * @param general - * @param request - * @return - */ - public List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, HttpServletRequest request); + + String getName(); + + /** + * Parse OnlineApplication database object to formData + * + * @param dbOAConfig + * @return List of Errors + */ + List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request); + + /** + * Store formData to OnlineApplication database object + * + * @param dboa: Database data object + * @param authUser + * @param request: + * @return Error description + */ + String store(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request); + + /** + * Validate formData + * + * @param general + * @param request + * @return + */ + List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, HttpServletRequest request); } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java index b3db074a2..b3f0620f0 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAAuthenticationData.java @@ -29,8 +29,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.BKUURLS; @@ -47,105 +45,105 @@ import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import at.gv.egovernment.moa.id.configuration.validation.oa.OAAuthenticationDataValidation; import at.gv.egovernment.moa.util.MiscUtil; +import lombok.extern.slf4j.Slf4j; /** * @author tlenz * */ +@Slf4j public class OAAuthenticationData implements IOnlineApplicationData { - private static final Logger log = Logger.getLogger(OAAuthenticationData.class); - - private String bkuOnlineURL = null; - private String bkuHandyURL = null; - private String bkuLocalURL = null; - - private String mandateProfiles = null; - private boolean useMandates = false; - - private List<String> misServicesList = new ArrayList<String>(); - private List<String> elgaServicesList = new ArrayList<String>(); - private List<String> szrgwServicesList = new ArrayList<String>(); - private List<String> eidServicesList = new ArrayList<String>(); - private String misServiceSelected = null; - private String elgaServiceSelected = null; - private String szrgwServiceSelected = null; - private String eidServiceSelected = null; - - private boolean calculateHPI = false; - - private String keyBoxIdentifier = null; - private static Map<String, String> keyBoxIdentifierList; - - private boolean legacy = false; - List<String> SLTemplates = null; - - private Map<String, byte[]> transformations; - - private boolean enableTestCredentials = false; - private List<String> testCredentialOIDs = null; - private boolean useTestIDLValidationTrustStore = false; - private boolean useTestAuthblockValidationTrustStore = false; - - - //SL2.0 - private boolean sl20Active = false; - private String sl20EndPoints = null; - - private boolean isMoaidMode = false; - - /** - * @param isMoaidMode - * - */ - public OAAuthenticationData() { - try { - this.isMoaidMode = ConfigurationProvider.getInstance().isMOAIDMode(); - } catch (ConfigurationException e) { - e.printStackTrace(); - - } - - keyBoxIdentifierList = new HashMap<String, String>(); - MOAKeyBoxSelector[] values = MOAKeyBoxSelector.values(); - for (int i=0; i<values.length; i++) { - keyBoxIdentifierList.put(values[i].value(), values[i].value()); - } - - keyBoxIdentifier = MOAKeyBoxSelector.SECURE_SIGNATURE_KEYPAIR.value(); - - - try { - MOAIDConfiguration dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); - - if (this.isMoaidMode) { - try { - elgaServicesList = KeyValueUtils.getListOfCSVValues(dbconfig.getElgaMandateServiceURLs()); - misServicesList = KeyValueUtils.getListOfCSVValues( - dbconfig.getAuthComponentGeneral().getOnlineMandates().getConnectionParameter().getURL()); - } catch (NullPointerException e) {} - - try { - szrgwServicesList = KeyValueUtils.getListOfCSVValues( - dbconfig.getAuthComponentGeneral().getForeignIdentities().getConnectionParameter().getURL()); - } catch (NullPointerException e) {} - - } - - - try { - eidServicesList = KeyValueUtils.getListOfCSVValues(dbconfig.getEidSystemServiceURLs()); - } catch (NullPointerException e) {} - - - } catch (ConfigurationException e) { - log.error("MOA-ID-Configuration initialization FAILED.", e); - - } - + private String bkuOnlineURL = null; + private String bkuHandyURL = null; + private String bkuLocalURL = null; + + private String mandateProfiles = null; + private boolean useMandates = false; + + private List<String> misServicesList = new ArrayList<>(); + private List<String> elgaServicesList = new ArrayList<>(); + private List<String> szrgwServicesList = new ArrayList<>(); + private List<String> eidServicesList = new ArrayList<>(); + private String misServiceSelected = null; + private String elgaServiceSelected = null; + private String szrgwServiceSelected = null; + private String eidServiceSelected = null; + + private boolean calculateHPI = false; + + private String keyBoxIdentifier = null; + private static Map<String, String> keyBoxIdentifierList; + + private boolean legacy = false; + List<String> SLTemplates = null; + + private Map<String, byte[]> transformations; + + private boolean enableTestCredentials = false; + private List<String> testCredentialOIDs = null; + private boolean useTestIDLValidationTrustStore = false; + private boolean useTestAuthblockValidationTrustStore = false; + + // SL2.0 + private boolean sl20Active = false; + private String sl20EndPoints = null; + + private boolean isMoaidMode = false; + + /** + * @param isMoaidMode + * + */ + public OAAuthenticationData() { + try { + this.isMoaidMode = ConfigurationProvider.getInstance().isMOAIDMode(); + } catch (final ConfigurationException e) { + e.printStackTrace(); + + } + + keyBoxIdentifierList = new HashMap<>(); + final MOAKeyBoxSelector[] values = MOAKeyBoxSelector.values(); + for (final MOAKeyBoxSelector value : values) { + keyBoxIdentifierList.put(value.value(), value.value()); + } + + keyBoxIdentifier = MOAKeyBoxSelector.SECURE_SIGNATURE_KEYPAIR.value(); + + try { + final MOAIDConfiguration dbconfig = ConfigurationProvider.getInstance().getDbRead() + .getMOAIDConfiguration(); + + if (this.isMoaidMode) { + try { + elgaServicesList = KeyValueUtils.getListOfCSVValues(dbconfig.getElgaMandateServiceURLs()); + misServicesList = KeyValueUtils.getListOfCSVValues( + dbconfig.getAuthComponentGeneral().getOnlineMandates().getConnectionParameter().getURL()); + } catch (final NullPointerException e) { + } + + try { + szrgwServicesList = KeyValueUtils.getListOfCSVValues( + dbconfig.getAuthComponentGeneral().getForeignIdentities().getConnectionParameter().getURL()); + } catch (final NullPointerException e) { + } + + } + + try { + eidServicesList = KeyValueUtils.getListOfCSVValues(dbconfig.getEidSystemServiceURLs()); + } catch (final NullPointerException e) { + } + + } catch (final ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + + } + // bkuLocalURL = Constants.DEFAULT_LOCALBKU_URL; // bkuHandyURL = Constants.DEFAULT_HANDYBKU_URL; -// +// // MOAIDConfiguration moaidconfig = ConfigurationDBRead.getMOAIDConfiguration(); // if (moaidconfig != null) { // DefaultBKUs defaultbkus = moaidconfig.getDefaultBKUs(); @@ -155,34 +153,43 @@ public class OAAuthenticationData implements IOnlineApplicationData { // setBkuOnlineURL(defaultbkus.getOnlineBKU()); // } // } - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OAAuthenticationData"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { - keyBoxIdentifier = dbOA.getKeyBoxIdentifier().value(); - - szrgwServiceSelected = dbOA.getSelectedSZRGWServiceURL(); - eidServiceSelected = dbOA.getSelectedEIDServiceURL(); - - AuthComponentOA oaauth = dbOA.getAuthComponentOA(); - if (oaauth != null) { - BKUURLS bkuurls = oaauth.getBKUURLS(); - - String defaulthandy = ""; - String defaultlocal = ""; - String defaultonline = ""; - + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OAAuthenticationData"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { + keyBoxIdentifier = dbOA.getKeyBoxIdentifier().value(); + + szrgwServiceSelected = dbOA.getSelectedSZRGWServiceURL(); + eidServiceSelected = dbOA.getSelectedEIDServiceURL(); + + final AuthComponentOA oaauth = dbOA.getAuthComponentOA(); + if (oaauth != null) { + final BKUURLS bkuurls = oaauth.getBKUURLS(); + + final String defaulthandy = ""; + final String defaultlocal = ""; + final String defaultonline = ""; + // MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); // if (dbconfig != null) { // DefaultBKUs defaultbkus = dbconfig.getDefaultBKUs(); @@ -192,674 +199,685 @@ public class OAAuthenticationData implements IOnlineApplicationData { // defaultonline = defaultbkus.getOnlineBKU(); // } // } - - if (bkuurls != null) { - - if (MiscUtil.isEmpty(bkuurls.getHandyBKU())) - bkuHandyURL = defaulthandy; - else - bkuHandyURL = bkuurls.getHandyBKU(); - - if (MiscUtil.isEmpty(bkuurls.getLocalBKU())) - bkuLocalURL = defaultlocal; - else - bkuLocalURL = bkuurls.getLocalBKU(); - - if (MiscUtil.isEmpty(bkuurls.getOnlineBKU())) - bkuOnlineURL = defaultonline; - else - bkuOnlineURL = bkuurls.getOnlineBKU(); - } - - Mandates mandates = oaauth.getMandates(); - if (mandates != null) { - - mandateProfiles = null; - - List<String> profileList = mandates.getProfileName(); - for (String el : profileList) { - if (mandateProfiles == null) - mandateProfiles = el; - - else - mandateProfiles += "," + el; - } - - //TODO: only for RC1 - if (MiscUtil.isNotEmpty(mandates.getProfiles())) { - if (mandateProfiles == null) - mandateProfiles = mandates.getProfiles(); - - else - mandateProfiles += "," + mandates.getProfiles(); - - } - - if (mandateProfiles != null) - useMandates = true; - - else - useMandates = false; - - misServiceSelected = mandates.getSelectedMISServiceURL(); - elgaServiceSelected = mandates.getSelecteELGAServiceURL(); - - } - - TemplatesType templates = oaauth.getTemplates(); - if (templates != null) { - List<TemplateType> templatetype = templates.getTemplate(); - - if (templatetype != null) { - if (SLTemplates == null) { - SLTemplates = new ArrayList<String>(); - } - - for (TemplateType el : templatetype) { - SLTemplates.add(el.getURL()); - } - } - } - - if (SLTemplates != null && SLTemplates.size() > 0) - legacy = true; - - List<TransformsInfoType> transforminfos = oaauth.getTransformsInfo(); - transformations = new HashMap<String, byte[]>(); - for (TransformsInfoType el : transforminfos) { - transformations.put(el.getFilename(), el.getTransformation()); - } - } - - if (oaauth.getTestCredentials() != null) { - enableTestCredentials = oaauth.getTestCredentials().isEnableTestCredentials(); - testCredentialOIDs = new ArrayList<String>(); - testCredentialOIDs.addAll(oaauth.getTestCredentials().getCredentialOID()); - - useTestAuthblockValidationTrustStore = oaauth.getTestCredentials().isUseTestAuthBlockTrustStore(); - useTestIDLValidationTrustStore = oaauth.getTestCredentials().isUseTestIDLTrustStore(); - } - - //parse SL2.0 information - if (oaauth.isSl20Active()) { - //parse SL2.0 endpoint information - if (oaauth.getSl20EndPoints() != null) { - if (KeyValueUtils.isCSVValueString(oaauth.getSl20EndPoints())) - sl20EndPoints = KeyValueUtils.normalizeCSVValueString(oaauth.getSl20EndPoints()); - - else { - if (oaauth.getSl20EndPoints().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - sl20EndPoints = oaauth.getSl20EndPoints().substring(0, - oaauth.getSl20EndPoints().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - sl20EndPoints = oaauth.getSl20EndPoints(); - - } - } - sl20Active = oaauth.isSl20Active(); - - } - - - return null; - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); + + if (bkuurls != null) { + + if (MiscUtil.isEmpty(bkuurls.getHandyBKU())) { + bkuHandyURL = defaulthandy; + } else { + bkuHandyURL = bkuurls.getHandyBKU(); + } + + if (MiscUtil.isEmpty(bkuurls.getLocalBKU())) { + bkuLocalURL = defaultlocal; + } else { + bkuLocalURL = bkuurls.getLocalBKU(); + } + + if (MiscUtil.isEmpty(bkuurls.getOnlineBKU())) { + bkuOnlineURL = defaultonline; + } else { + bkuOnlineURL = bkuurls.getOnlineBKU(); + } + } + + final Mandates mandates = oaauth.getMandates(); + if (mandates != null) { + + mandateProfiles = null; + + final List<String> profileList = mandates.getProfileName(); + for (final String el : profileList) { + if (mandateProfiles == null) { + mandateProfiles = el; + } else { + mandateProfiles += "," + el; + } + } + + // TODO: only for RC1 + if (MiscUtil.isNotEmpty(mandates.getProfiles())) { + if (mandateProfiles == null) { + mandateProfiles = mandates.getProfiles(); + } else { + mandateProfiles += "," + mandates.getProfiles(); + } + + } + + if (mandateProfiles != null) { + useMandates = true; + } else { + useMandates = false; + } + + misServiceSelected = mandates.getSelectedMISServiceURL(); + elgaServiceSelected = mandates.getSelecteELGAServiceURL(); + + } + + final TemplatesType templates = oaauth.getTemplates(); + if (templates != null) { + final List<TemplateType> templatetype = templates.getTemplate(); + + if (templatetype != null) { + if (SLTemplates == null) { + SLTemplates = new ArrayList<>(); + } + + for (final TemplateType el : templatetype) { + SLTemplates.add(el.getURL()); + } } - - dbOA.setCalculateHPI(isCalculateHPI()); - - if (MiscUtil.isNotEmpty(getSzrgwServiceSelected())) - dbOA.setSelectedSZRGWServiceURL(getSzrgwServiceSelected()); - - - if (MiscUtil.isNotEmpty(getEidServiceSelected())) - dbOA.setSelectedEIDServiceURL(getEidServiceSelected()); - - if (authUser.isAdmin()) { - - //store BKU-URLs - BKUURLS bkuruls = new BKUURLS(); - authoa.setBKUURLS(bkuruls); - bkuruls.setHandyBKU(getBkuHandyURL()); - bkuruls.setLocalBKU(getBkuLocalURL()); - bkuruls.setOnlineBKU(getBkuOnlineURL()); - - //store SecurtiyLayerTemplates - TemplatesType templates = authoa.getTemplates(); - if (templates == null) { - templates = new TemplatesType(); - authoa.setTemplates(templates); - } - List<TemplateType> template = templates.getTemplate(); - if (isLegacy()) { - - if (template == null) - template = new ArrayList<TemplateType>(); - else - template.clear(); - - if (MiscUtil.isNotEmpty(getSLTemplateURL1())) { - TemplateType el = new TemplateType(); - el.setURL(getSLTemplateURL1()); - template.add(el); - } else - template.add(new TemplateType()); - if (MiscUtil.isNotEmpty(getSLTemplateURL2())) { - TemplateType el = new TemplateType(); - el.setURL(getSLTemplateURL2()); - template.add(el); - } else - template.add(new TemplateType()); - if (MiscUtil.isNotEmpty(getSLTemplateURL3())) { - TemplateType el = new TemplateType(); - el.setURL(getSLTemplateURL3()); - template.add(el); - } else - template.add(new TemplateType()); - - } else { - if (template != null && template.size() > 0) template.clear(); - } - - - //store keyBox Identifier - dbOA.setKeyBoxIdentifier(MOAKeyBoxSelector.fromValue(getKeyBoxIdentifier())); + } + + if (SLTemplates != null && SLTemplates.size() > 0) { + legacy = true; + } + + final List<TransformsInfoType> transforminfos = oaauth.getTransformsInfo(); + transformations = new HashMap<>(); + for (final TransformsInfoType el : transforminfos) { + transformations.put(el.getFilename(), el.getTransformation()); + } + } + + if (oaauth.getTestCredentials() != null) { + enableTestCredentials = oaauth.getTestCredentials().isEnableTestCredentials(); + testCredentialOIDs = new ArrayList<>(); + testCredentialOIDs.addAll(oaauth.getTestCredentials().getCredentialOID()); + + useTestAuthblockValidationTrustStore = oaauth.getTestCredentials().isUseTestAuthBlockTrustStore(); + useTestIDLValidationTrustStore = oaauth.getTestCredentials().isUseTestIDLTrustStore(); + } + + // parse SL2.0 information + if (oaauth.isSl20Active()) { + // parse SL2.0 endpoint information + if (oaauth.getSl20EndPoints() != null) { + if (KeyValueUtils.isCSVValueString(oaauth.getSl20EndPoints())) { + sl20EndPoints = KeyValueUtils.normalizeCSVValueString(oaauth.getSl20EndPoints()); } else { - if (dbOA.isIsNew()) dbOA.setKeyBoxIdentifier(MOAKeyBoxSelector.SECURE_SIGNATURE_KEYPAIR); + if (oaauth.getSl20EndPoints().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + sl20EndPoints = oaauth.getSl20EndPoints().substring(0, + oaauth.getSl20EndPoints().indexOf(KeyValueUtils.CSV_DELIMITER)); + + } else { + sl20EndPoints = oaauth.getSl20EndPoints(); + } + } - - Mandates mandates = new Mandates(); - if (isUseMandates()) { - - String[] profileList = getMandateProfiles().split(","); - - List<String> dbProfiles = mandates.getProfileName(); - if (dbProfiles == null) { - dbProfiles = new ArrayList<String>(); - mandates.setProfileName(dbProfiles); - - } - - for (String el: profileList) - dbProfiles.add(el.trim()); - - mandates.setProfiles(null); - - if (MiscUtil.isNotEmpty(getMisServiceSelected())) - mandates.setSelectedMISServiceURL(getMisServiceSelected()); - - if (MiscUtil.isNotEmpty(getElgaServiceSelected())) - mandates.setSelecteELGAServiceURL(getElgaServiceSelected()); - + } + sl20Active = oaauth.isSl20Active(); + + } + + return null; + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } + + dbOA.setCalculateHPI(isCalculateHPI()); + + if (MiscUtil.isNotEmpty(getSzrgwServiceSelected())) { + dbOA.setSelectedSZRGWServiceURL(getSzrgwServiceSelected()); + } + + if (MiscUtil.isNotEmpty(getEidServiceSelected())) { + dbOA.setSelectedEIDServiceURL(getEidServiceSelected()); + } + + if (authUser.isAdmin()) { + + // store BKU-URLs + final BKUURLS bkuruls = new BKUURLS(); + authoa.setBKUURLS(bkuruls); + bkuruls.setHandyBKU(getBkuHandyURL()); + bkuruls.setLocalBKU(getBkuLocalURL()); + bkuruls.setOnlineBKU(getBkuOnlineURL()); + + // store SecurtiyLayerTemplates + TemplatesType templates = authoa.getTemplates(); + if (templates == null) { + templates = new TemplatesType(); + authoa.setTemplates(templates); + } + List<TemplateType> template = templates.getTemplate(); + if (isLegacy()) { + + if (template == null) { + template = new ArrayList<>(); } else { - mandates.setProfiles(null); - mandates.getProfileName().clear(); - + template.clear(); } - authoa.setMandates(mandates); - // set default transformation if it is empty - List<TransformsInfoType> transformsInfo = authoa.getTransformsInfo(); - if (transformsInfo == null) { - // TODO: set OA specific transformation if it is required + if (MiscUtil.isNotEmpty(getSLTemplateURL1())) { + final TemplateType el = new TemplateType(); + el.setURL(getSLTemplateURL1()); + template.add(el); + } else { + template.add(new TemplateType()); + } + if (MiscUtil.isNotEmpty(getSLTemplateURL2())) { + final TemplateType el = new TemplateType(); + el.setURL(getSLTemplateURL2()); + template.add(el); + } else { + template.add(new TemplateType()); + } + if (MiscUtil.isNotEmpty(getSLTemplateURL3())) { + final TemplateType el = new TemplateType(); + el.setURL(getSLTemplateURL3()); + template.add(el); + } else { + template.add(new TemplateType()); + } + } else { + if (template != null && template.size() > 0) { + template.clear(); } - - if (enableTestCredentials) { - TestCredentials testing = authoa.getTestCredentials(); + } + + // store keyBox Identifier + dbOA.setKeyBoxIdentifier(MOAKeyBoxSelector.fromValue(getKeyBoxIdentifier())); + } else { + if (dbOA.isIsNew()) { + dbOA.setKeyBoxIdentifier(MOAKeyBoxSelector.SECURE_SIGNATURE_KEYPAIR); + } + } + + final Mandates mandates = new Mandates(); + if (isUseMandates()) { + + final String[] profileList = getMandateProfiles().split(","); + + List<String> dbProfiles = mandates.getProfileName(); + if (dbProfiles == null) { + dbProfiles = new ArrayList<>(); + mandates.setProfileName(dbProfiles); + + } + + for (final String el : profileList) { + dbProfiles.add(el.trim()); + } + + mandates.setProfiles(null); + + if (MiscUtil.isNotEmpty(getMisServiceSelected())) { + mandates.setSelectedMISServiceURL(getMisServiceSelected()); + } + + if (MiscUtil.isNotEmpty(getElgaServiceSelected())) { + mandates.setSelecteELGAServiceURL(getElgaServiceSelected()); + } + + } else { + mandates.setProfiles(null); + mandates.getProfileName().clear(); + + } + authoa.setMandates(mandates); + + // set default transformation if it is empty + final List<TransformsInfoType> transformsInfo = authoa.getTransformsInfo(); + if (transformsInfo == null) { + // TODO: set OA specific transformation if it is required + + } + + if (enableTestCredentials) { + TestCredentials testing = authoa.getTestCredentials(); // if (testing != null) // ConfigurationDBUtils.delete(testing); - testing = new TestCredentials(); - authoa.setTestCredentials(testing); - testing.setEnableTestCredentials(enableTestCredentials); - testing.setCredentialOID(testCredentialOIDs); - + testing = new TestCredentials(); + authoa.setTestCredentials(testing); + testing.setEnableTestCredentials(enableTestCredentials); + testing.setCredentialOID(testCredentialOIDs); + + } else { + final TestCredentials testing = authoa.getTestCredentials(); + if (testing != null) { + testing.setEnableTestCredentials(false); + } + + } + + TestCredentials testing = authoa.getTestCredentials(); + if (testing == null) { + testing = new TestCredentials(); + authoa.setTestCredentials(testing); + + } + testing.setUseTestAuthBlockTrustStore(useTestAuthblockValidationTrustStore); + testing.setUseTestIDLTrustStore(useTestIDLValidationTrustStore); + + // store SL2.0 information + authoa.setSl20Active(isSl20Active()); + authoa.setSl20EndPoints(getSl20EndPoints()); + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + return new OAAuthenticationDataValidation().validate(this, authUser.isAdmin(), request); + } + + /** + * @return the bkuOnlineURL + */ + public String getBkuOnlineURL() { + return bkuOnlineURL; + } + + /** + * @param bkuOnlineURL the bkuOnlineURL to set + */ + public void setBkuOnlineURL(String bkuOnlineURL) { + this.bkuOnlineURL = bkuOnlineURL; + } + + /** + * @return the bkuHandyURL + */ + public String getBkuHandyURL() { + return bkuHandyURL; + } + + /** + * @param bkuHandyURL the bkuHandyURL to set + */ + public void setBkuHandyURL(String bkuHandyURL) { + this.bkuHandyURL = bkuHandyURL; + } + + /** + * @return the bkuLocalURL + */ + public String getBkuLocalURL() { + return bkuLocalURL; + } + + /** + * @param bkuLocalURL the bkuLocalURL to set + */ + public void setBkuLocalURL(String bkuLocalURL) { + this.bkuLocalURL = bkuLocalURL; + } + + /** + * @return the mandateProfiles + */ + public String getMandateProfiles() { + return mandateProfiles; + } + + /** + * @param mandateProfiles the mandateProfiles to set + */ + public void setMandateProfiles(String mandateProfiles) { + this.mandateProfiles = mandateProfiles; + } + + /** + * @return the useMandates + */ + public boolean isUseMandates() { + return useMandates; + } + + /** + * @param useMandates the useMandates to set + */ + public void setUseMandates(boolean useMandates) { + this.useMandates = useMandates; + } + + /** + * @return the calculateHPI + */ + public boolean isCalculateHPI() { + return calculateHPI; + } + + /** + * @param calculateHPI the calculateHPI to set + */ + public void setCalculateHPI(boolean calculateHPI) { + this.calculateHPI = calculateHPI; + } + + /** + * @return the keyBoxIdentifier + */ + public String getKeyBoxIdentifier() { + return keyBoxIdentifier; + } + + /** + * @param keyBoxIdentifier the keyBoxIdentifier to set + */ + public void setKeyBoxIdentifier(String keyBoxIdentifier) { + this.keyBoxIdentifier = keyBoxIdentifier; + } + + /** + * @return the keyBoxIdentifierList + */ + public Map<String, String> getKeyBoxIdentifierList() { + return keyBoxIdentifierList; + } + + /** + * @return the legacy + */ + public boolean isLegacy() { + return legacy; + } + + /** + * @param legacy the legacy to set + */ + public void setLegacy(boolean legacy) { + this.legacy = legacy; + } + + /** + * @return the transformations + */ + public Map<String, byte[]> getTransformations() { + return transformations; + } + + /** + * @param transformations the transformations to set + */ + public void setTransformations(Map<String, byte[]> transformations) { + this.transformations = transformations; + } + + /** + * @return the sLTemplates + */ + public List<String> getSLTemplates() { + return SLTemplates; + } + + /** + * @return the sLTemplateURL1 + */ + public String getSLTemplateURL1() { + if (SLTemplates != null && SLTemplates.size() > 0) { + return SLTemplates.get(0); + } else { + return null; + } + } + + /** + * @param sLTemplateURL1 the sLTemplateURL1 to set + */ + public void setSLTemplateURL1(String sLTemplateURL1) { + if (SLTemplates == null) { + SLTemplates = new ArrayList<>(); + } + SLTemplates.add(sLTemplateURL1); + } + + /** + * @return the sLTemplateURL2 + */ + public String getSLTemplateURL2() { + if (SLTemplates != null && SLTemplates.size() > 1) { + return SLTemplates.get(1); + } else { + return null; + } + } + + /** + * @param sLTemplateURL2 the sLTemplateURL2 to set + */ + public void setSLTemplateURL2(String sLTemplateURL2) { + if (SLTemplates == null) { + SLTemplates = new ArrayList<>(); + } + SLTemplates.add(sLTemplateURL2); + } + + /** + * @return the sLTemplateURL3 + */ + public String getSLTemplateURL3() { + if (SLTemplates != null && SLTemplates.size() > 2) { + return SLTemplates.get(2); + } else { + return null; + } + } + + /** + * @param sLTemplateURL3 the sLTemplateURL3 to set + */ + public void setSLTemplateURL3(String sLTemplateURL3) { + if (SLTemplates == null) { + SLTemplates = new ArrayList<>(); + } + SLTemplates.add(sLTemplateURL3); + } + + /** + * @return the enableTestCredentials + */ + public boolean isEnableTestCredentials() { + return enableTestCredentials; + } + + /** + * @param enableTestCredentials the enableTestCredentials to set + */ + public void setEnableTestCredentials(boolean enableTestCredentials) { + this.enableTestCredentials = enableTestCredentials; + } + + /** + * @return the testCredentialOIDs + */ + public String getTestCredentialOIDs() { + String value = null; + if (testCredentialOIDs != null) { + for (final String el : testCredentialOIDs) { + if (value == null) { + value = el; } else { - TestCredentials testing = authoa.getTestCredentials(); - if (testing != null) { - testing.setEnableTestCredentials(false); - } - + value += "," + el; } - - TestCredentials testing = authoa.getTestCredentials(); - if (testing == null) { - testing = new TestCredentials(); - authoa.setTestCredentials(testing); - - } - testing.setUseTestAuthBlockTrustStore(useTestAuthblockValidationTrustStore); - testing.setUseTestIDLTrustStore(useTestIDLValidationTrustStore); - - - //store SL2.0 information - authoa.setSl20Active(isSl20Active()); - authoa.setSl20EndPoints(getSl20EndPoints()); - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - return new OAAuthenticationDataValidation().validate(this, authUser.isAdmin(), request); - } - - - /** - * @return the bkuOnlineURL - */ - public String getBkuOnlineURL() { - return bkuOnlineURL; - } - - - /** - * @param bkuOnlineURL the bkuOnlineURL to set - */ - public void setBkuOnlineURL(String bkuOnlineURL) { - this.bkuOnlineURL = bkuOnlineURL; - } - - - /** - * @return the bkuHandyURL - */ - public String getBkuHandyURL() { - return bkuHandyURL; - } - - - /** - * @param bkuHandyURL the bkuHandyURL to set - */ - public void setBkuHandyURL(String bkuHandyURL) { - this.bkuHandyURL = bkuHandyURL; - } - - - /** - * @return the bkuLocalURL - */ - public String getBkuLocalURL() { - return bkuLocalURL; - } - - - /** - * @param bkuLocalURL the bkuLocalURL to set - */ - public void setBkuLocalURL(String bkuLocalURL) { - this.bkuLocalURL = bkuLocalURL; - } - - - /** - * @return the mandateProfiles - */ - public String getMandateProfiles() { - return mandateProfiles; - } - - - /** - * @param mandateProfiles the mandateProfiles to set - */ - public void setMandateProfiles(String mandateProfiles) { - this.mandateProfiles = mandateProfiles; - } - - - /** - * @return the useMandates - */ - public boolean isUseMandates() { - return useMandates; - } - - - /** - * @param useMandates the useMandates to set - */ - public void setUseMandates(boolean useMandates) { - this.useMandates = useMandates; - } - - - /** - * @return the calculateHPI - */ - public boolean isCalculateHPI() { - return calculateHPI; - } - - - /** - * @param calculateHPI the calculateHPI to set - */ - public void setCalculateHPI(boolean calculateHPI) { - this.calculateHPI = calculateHPI; - } - - - /** - * @return the keyBoxIdentifier - */ - public String getKeyBoxIdentifier() { - return keyBoxIdentifier; - } - - - /** - * @param keyBoxIdentifier the keyBoxIdentifier to set - */ - public void setKeyBoxIdentifier(String keyBoxIdentifier) { - this.keyBoxIdentifier = keyBoxIdentifier; - } - - - /** - * @return the keyBoxIdentifierList - */ - public Map<String, String> getKeyBoxIdentifierList() { - return keyBoxIdentifierList; - } - - - /** - * @return the legacy - */ - public boolean isLegacy() { - return legacy; - } - - - /** - * @param legacy the legacy to set - */ - public void setLegacy(boolean legacy) { - this.legacy = legacy; - } - - - /** - * @return the transformations - */ - public Map<String, byte[]> getTransformations() { - return transformations; - } - - - /** - * @param transformations the transformations to set - */ - public void setTransformations(Map<String, byte[]> transformations) { - this.transformations = transformations; - } - - - /** - * @return the sLTemplates - */ - public List<String> getSLTemplates() { - return SLTemplates; - } - - /** - * @return the sLTemplateURL1 - */ - public String getSLTemplateURL1() { - if (SLTemplates != null && SLTemplates.size() > 0) - return SLTemplates.get(0); - else - return null; - } - - - /** - * @param sLTemplateURL1 the sLTemplateURL1 to set - */ - public void setSLTemplateURL1(String sLTemplateURL1) { - if (SLTemplates == null) - SLTemplates = new ArrayList<String>(); - SLTemplates.add(sLTemplateURL1); - } - - - /** - * @return the sLTemplateURL2 - */ - public String getSLTemplateURL2() { - if (SLTemplates != null && SLTemplates.size() > 1) - return SLTemplates.get(1); - else - return null; - } - - - /** - * @param sLTemplateURL2 the sLTemplateURL2 to set - */ - public void setSLTemplateURL2(String sLTemplateURL2) { - if (SLTemplates == null) - SLTemplates = new ArrayList<String>(); - SLTemplates.add(sLTemplateURL2); - } - - - /** - * @return the sLTemplateURL3 - */ - public String getSLTemplateURL3() { - if (SLTemplates != null && SLTemplates.size() > 2) - return SLTemplates.get(2); - else - return null; - } - - - /** - * @param sLTemplateURL3 the sLTemplateURL3 to set - */ - public void setSLTemplateURL3(String sLTemplateURL3) { - if (SLTemplates == null) - SLTemplates = new ArrayList<String>(); - SLTemplates.add(sLTemplateURL3); - } - - /** - * @return the enableTestCredentials - */ - public boolean isEnableTestCredentials() { - return enableTestCredentials; - } - - /** - * @param enableTestCredentials the enableTestCredentials to set - */ - public void setEnableTestCredentials(boolean enableTestCredentials) { - this.enableTestCredentials = enableTestCredentials; - } - - /** - * @return the testCredentialOIDs - */ - public String getTestCredentialOIDs() { - String value = null; - if (testCredentialOIDs != null) { - for (String el : testCredentialOIDs) { - if (value == null) - value = el; - else - value += "," + el; - - } - } - - return value; - } - - public List<String> getTestCredialOIDList() { - return this.testCredentialOIDs; - } - - /** - * @param testCredentialOIDs the testCredentialOIDs to set - */ - public void setTestCredentialOIDs(String testCredentialOIDs) { - if (MiscUtil.isNotEmpty(testCredentialOIDs)) { - String[] oidList = testCredentialOIDs.split(","); - - this.testCredentialOIDs = new ArrayList<String>(); - for (int i=0; i<oidList.length; i++) - this.testCredentialOIDs.add(oidList[i].trim()); - } - } - - /** - * @return the useTestIDLValidationTrustStore - */ - public boolean isUseTestIDLValidationTrustStore() { - return useTestIDLValidationTrustStore; - } - - /** - * @param useTestIDLValidationTrustStore the useTestIDLValidationTrustStore to set - */ - public void setUseTestIDLValidationTrustStore( - boolean useTestIDLValidationTrustStore) { - this.useTestIDLValidationTrustStore = useTestIDLValidationTrustStore; - } - - /** - * @return the useTestAuthblockValidationTrustStore - */ - public boolean isUseTestAuthblockValidationTrustStore() { - return useTestAuthblockValidationTrustStore; - } - - /** - * @param useTestAuthblockValidationTrustStore the useTestAuthblockValidationTrustStore to set - */ - public void setUseTestAuthblockValidationTrustStore( - boolean useTestAuthblockValidationTrustStore) { - this.useTestAuthblockValidationTrustStore = useTestAuthblockValidationTrustStore; - } - - /** - * @return the misServiceSelected - */ - public String getMisServiceSelected() { - return misServiceSelected; - } - - /** - * @param misServiceSelected the misServiceSelected to set - */ - public void setMisServiceSelected(String misServiceSelected) { - this.misServiceSelected = misServiceSelected; - } - - /** - * @return the elgaServiceSelected - */ - public String getElgaServiceSelected() { - return elgaServiceSelected; - } - - /** - * @param elgaServiceSelected the elgaServiceSelected to set - */ - public void setElgaServiceSelected(String elgaServiceSelected) { - this.elgaServiceSelected = elgaServiceSelected; - } - - /** - * @return the szrgwServiceSelected - */ - public String getSzrgwServiceSelected() { - return szrgwServiceSelected; - } - - /** - * @param szrgwServiceSelected the szrgwServiceSelected to set - */ - public void setSzrgwServiceSelected(String szrgwServiceSelected) { - this.szrgwServiceSelected = szrgwServiceSelected; - } - - /** - * @return the misServicesList - */ - public List<String> getMisServicesList() { - return misServicesList; - } - - /** - * @return the elgaServicesList - */ - public List<String> getElgaServicesList() { - return elgaServicesList; - } - - /** - * @return the szrgwServicesList - */ - public List<String> getSzrgwServicesList() { - return szrgwServicesList; - } - - public List<String> getEidServicesList() { - return eidServicesList; - } - - public String getEidServiceSelected() { - return eidServiceSelected; - } - - public void setEidServiceSelected(String eidServiceSelected) { - this.eidServiceSelected = eidServiceSelected; - } - - public boolean isSl20Active() { - return sl20Active; - } - - public void setSl20Active(boolean sl20Active) { - this.sl20Active = sl20Active; - } - - public String getSl20EndPoints() { - return sl20EndPoints; - } - - public void setSl20EndPoints(String sl20EndPoints) { - if (MiscUtil.isNotEmpty(sl20EndPoints)) - this.sl20EndPoints = - KeyValueUtils.removeAllNewlineFromString(sl20EndPoints); - else - this.sl20EndPoints = sl20EndPoints; - } - - public boolean isMoaidMode() { - return isMoaidMode; - } - + + } + } + + return value; + } + + public List<String> getTestCredialOIDList() { + return this.testCredentialOIDs; + } + + /** + * @param testCredentialOIDs the testCredentialOIDs to set + */ + public void setTestCredentialOIDs(String testCredentialOIDs) { + if (MiscUtil.isNotEmpty(testCredentialOIDs)) { + final String[] oidList = testCredentialOIDs.split(","); + + this.testCredentialOIDs = new ArrayList<>(); + for (final String element : oidList) { + this.testCredentialOIDs.add(element.trim()); + } + } + } + + /** + * @return the useTestIDLValidationTrustStore + */ + public boolean isUseTestIDLValidationTrustStore() { + return useTestIDLValidationTrustStore; + } + + /** + * @param useTestIDLValidationTrustStore the useTestIDLValidationTrustStore to + * set + */ + public void setUseTestIDLValidationTrustStore( + boolean useTestIDLValidationTrustStore) { + this.useTestIDLValidationTrustStore = useTestIDLValidationTrustStore; + } + + /** + * @return the useTestAuthblockValidationTrustStore + */ + public boolean isUseTestAuthblockValidationTrustStore() { + return useTestAuthblockValidationTrustStore; + } + + /** + * @param useTestAuthblockValidationTrustStore the + * useTestAuthblockValidationTrustStore + * to set + */ + public void setUseTestAuthblockValidationTrustStore( + boolean useTestAuthblockValidationTrustStore) { + this.useTestAuthblockValidationTrustStore = useTestAuthblockValidationTrustStore; + } + + /** + * @return the misServiceSelected + */ + public String getMisServiceSelected() { + return misServiceSelected; + } + + /** + * @param misServiceSelected the misServiceSelected to set + */ + public void setMisServiceSelected(String misServiceSelected) { + this.misServiceSelected = misServiceSelected; + } + + /** + * @return the elgaServiceSelected + */ + public String getElgaServiceSelected() { + return elgaServiceSelected; + } + + /** + * @param elgaServiceSelected the elgaServiceSelected to set + */ + public void setElgaServiceSelected(String elgaServiceSelected) { + this.elgaServiceSelected = elgaServiceSelected; + } + + /** + * @return the szrgwServiceSelected + */ + public String getSzrgwServiceSelected() { + return szrgwServiceSelected; + } + + /** + * @param szrgwServiceSelected the szrgwServiceSelected to set + */ + public void setSzrgwServiceSelected(String szrgwServiceSelected) { + this.szrgwServiceSelected = szrgwServiceSelected; + } + + /** + * @return the misServicesList + */ + public List<String> getMisServicesList() { + return misServicesList; + } + + /** + * @return the elgaServicesList + */ + public List<String> getElgaServicesList() { + return elgaServicesList; + } + + /** + * @return the szrgwServicesList + */ + public List<String> getSzrgwServicesList() { + return szrgwServicesList; + } + + public List<String> getEidServicesList() { + return eidServicesList; + } + + public String getEidServiceSelected() { + return eidServiceSelected; + } + + public void setEidServiceSelected(String eidServiceSelected) { + this.eidServiceSelected = eidServiceSelected; + } + + public boolean isSl20Active() { + return sl20Active; + } + + public void setSl20Active(boolean sl20Active) { + this.sl20Active = sl20Active; + } + + public String getSl20EndPoints() { + return sl20EndPoints; + } + + public void setSl20EndPoints(String sl20EndPoints) { + if (MiscUtil.isNotEmpty(sl20EndPoints)) { + this.sl20EndPoints = + KeyValueUtils.removeAllNewlineFromString(sl20EndPoints); + } else { + this.sl20EndPoints = sl20EndPoints; + } + } + + public boolean isMoaidMode() { + return isMoaidMode; + } + } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java index bac69cf34..1f4d842ca 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OABPKEncryption.java @@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.lang.SerializationUtils; -import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.auth.exception.BuildException; import at.gv.egovernment.moa.id.commons.api.data.BPKDecryptionParameters; @@ -49,322 +48,342 @@ import at.gv.egovernment.moa.id.configuration.utils.ConfigurationEncryptionUtils import at.gv.egovernment.moa.id.configuration.validation.oa.OAFileUploadValidation; import at.gv.egovernment.moa.id.data.EncryptedData; import at.gv.egovernment.moa.util.MiscUtil; +import lombok.extern.slf4j.Slf4j; /** * @author tlenz * */ +@Slf4j public class OABPKEncryption implements IOnlineApplicationData { - private static final Logger log = Logger.getLogger(OABPKEncryption.class); - - private static final String MODULENAME = "bPKEncryptionDecryption"; - - private String keyStorePassword = null; - private String keyAlias = null; - private String keyPassword = null; - - private Map<String, byte[]> keyStoreForm = new HashMap<String, byte[]>(); - - private List<File> keyStoreFileUpload = null; - private List<String> keyStoreFileUploadContentType = null; - private List<String> keyStoreFileUploadFileName = new ArrayList<String>();; - private boolean deletekeyStore = false; - private boolean validationError = false; - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - // TODO Auto-generated method stub - return MODULENAME; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, - AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA oaAuth = dbOA.getAuthComponentOA(); - if (oaAuth != null) { - EncBPKInformation bPKEncDec = oaAuth.getEncBPKInformation(); - if (bPKEncDec != null) { - BPKDecryption bPKDec = bPKEncDec.getBPKDecryption(); - if (bPKDec != null) { - keyAlias = bPKDec.getKeyAlias(); - if (bPKDec.getKeyStoreFileName() != null) - keyStoreFileUploadFileName.add(bPKDec.getKeyStoreFileName()); - - } - } - } - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - AuthComponentOA oaAuth = dbOA.getAuthComponentOA(); - if (oaAuth == null) { - oaAuth = new AuthComponentOA(); - dbOA.setAuthComponentOA(oaAuth); - - } - EncBPKInformation bPKEncDec = oaAuth.getEncBPKInformation(); - if (bPKEncDec == null) { - bPKEncDec = new EncBPKInformation(); - oaAuth.setEncBPKInformation(bPKEncDec); - - } - - BPKDecryption bPKDec = bPKEncDec.getBPKDecryption(); - if (bPKDec == null) { - bPKDec = new BPKDecryption(); - bPKEncDec.setBPKDecryption(bPKDec); - } - - if (isDeletekeyStore()) { - bPKDec.setIv(null); - bPKDec.setKeyAlias(null); - bPKDec.setKeyInformation(null); - bPKDec.setKeyStoreFileName(null); - - } - - BPKDecryptionParameters keyInfo = new BPKDecryptionParameters(); - if (keyStoreForm != null && keyStoreForm.size() > 0) { - keyInfo.setKeyAlias(keyAlias); - keyInfo.setKeyPassword(keyPassword); - keyInfo.setKeyStorePassword(keyStorePassword); - - Iterator<String> interator = keyStoreForm.keySet().iterator(); - bPKDec.setKeyStoreFileName(interator.next()); - bPKDec.setKeyAlias(keyAlias); - keyInfo.setKeyStore(keyStoreForm.get( - bPKDec.getKeyStoreFileName())); - - //encrypt key information - byte[] serKeyInfo = SerializationUtils.serialize(keyInfo); - try { - EncryptedData encryptkeyInfo = ConfigurationEncryptionUtils.getInstance().encrypt(serKeyInfo); - bPKDec.setIv(encryptkeyInfo.getIv()); - bPKDec.setKeyInformation(encryptkeyInfo.getEncData()); - - } catch (BuildException e) { - log.error("Configuration encryption FAILED.", e); - return LanguageHelper.getErrorString("error.general.text", request); - - } - } - - request.getSession().setAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION, null); - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - HttpSession session = request.getSession(); - List<String> errors = new ArrayList<String>(); - - String check = null; - - OAFileUploadValidation valiator_fileUpload = new OAFileUploadValidation(); - //validate BKU-selection template - List<String> templateError = valiator_fileUpload.validate(getKeyStoreFileUploadFileName() - , getKeyStoreFileUpload(), "validation.bPKDec.keyStore", keyStoreForm, request); - if (templateError != null && templateError.size() == 0) { - if (keyStoreForm != null && keyStoreForm.size() > 0) { - session.setAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION, keyStoreForm); - - } else - keyStoreForm = (Map<String, byte[]>) session.getAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION); - - } else { - errors.addAll(templateError); + private static final String MODULENAME = "bPKEncryptionDecryption"; + + private String keyStorePassword = null; + private String keyAlias = null; + private String keyPassword = null; + + private Map<String, byte[]> keyStoreForm = new HashMap<>(); + + private List<File> keyStoreFileUpload = null; + private List<String> keyStoreFileUploadContentType = null; + private List<String> keyStoreFileUploadFileName = new ArrayList<>(); + private boolean deletekeyStore = false; + private boolean validationError = false; + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + // TODO Auto-generated method stub + return MODULENAME; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + final AuthComponentOA oaAuth = dbOA.getAuthComponentOA(); + if (oaAuth != null) { + final EncBPKInformation bPKEncDec = oaAuth.getEncBPKInformation(); + if (bPKEncDec != null) { + final BPKDecryption bPKDec = bPKEncDec.getBPKDecryption(); + if (bPKDec != null) { + keyAlias = bPKDec.getKeyAlias(); + if (bPKDec.getKeyStoreFileName() != null) { + keyStoreFileUploadFileName.add(bPKDec.getKeyStoreFileName()); + } } - - if (keyStoreForm != null && keyStoreForm.size() > 0) { - check = getKeyStorePassword(); - if (MiscUtil.isEmpty(check)) { - log.info("bPK decryption keystore password is empty"); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStorePassword.empty", request)); - - } else { - if (ValidationHelper.containsNotValidCharacter(check, false)) { - log.warn("bPK decryption keystore password contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStorePassword.valid", - new Object[] {ValidationHelper.getNotValidCharacter(false)}, request )); - - } - } - - check = getKeyAlias(); - if (MiscUtil.isEmpty(check)) { - log.info("bPK decryption key alias is empty"); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyAlias.empty", request)); - - } else { - if (ValidationHelper.containsNotValidCharacter(check, false)) { - log.warn("bPK decryption key alias contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyAlias.valid", - new Object[] {ValidationHelper.getNotValidCharacter(false)}, request )); - - } - } - - check = getKeyPassword(); - if (MiscUtil.isNotEmpty(check)) { - if (ValidationHelper.containsNotValidCharacter(check, false)) { - log.warn("bPK decryption key password contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyPassword.valid", - new Object[] {ValidationHelper.getNotValidCharacter(false)}, request )); - - } - } - - BPKDecryptionParameters keyInfo = new BPKDecryptionParameters(); - keyInfo.setKeyAlias(keyAlias); - keyInfo.setKeyPassword(keyPassword); - keyInfo.setKeyStorePassword(keyStorePassword); - Iterator<String> interator = keyStoreForm.keySet().iterator(); - String fileName = interator.next(); - keyInfo.setKeyStore(keyStoreForm.get(fileName)); - if (keyInfo.getPrivateKey() == null) { - log.info("Open keyStore FAILED."); - errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStore.file.valid", request)); - - } + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + AuthComponentOA oaAuth = dbOA.getAuthComponentOA(); + if (oaAuth == null) { + oaAuth = new AuthComponentOA(); + dbOA.setAuthComponentOA(oaAuth); + + } + EncBPKInformation bPKEncDec = oaAuth.getEncBPKInformation(); + if (bPKEncDec == null) { + bPKEncDec = new EncBPKInformation(); + oaAuth.setEncBPKInformation(bPKEncDec); + + } + + BPKDecryption bPKDec = bPKEncDec.getBPKDecryption(); + if (bPKDec == null) { + bPKDec = new BPKDecryption(); + bPKEncDec.setBPKDecryption(bPKDec); + } + + if (isDeletekeyStore()) { + bPKDec.setIv(null); + bPKDec.setKeyAlias(null); + bPKDec.setKeyInformation(null); + bPKDec.setKeyStoreFileName(null); + + } + + final BPKDecryptionParameters keyInfo = new BPKDecryptionParameters(); + if (keyStoreForm != null && keyStoreForm.size() > 0) { + keyInfo.setKeyAlias(keyAlias); + keyInfo.setKeyPassword(keyPassword); + keyInfo.setKeyStorePassword(keyStorePassword); + + final Iterator<String> interator = keyStoreForm.keySet().iterator(); + bPKDec.setKeyStoreFileName(interator.next()); + bPKDec.setKeyAlias(keyAlias); + keyInfo.setKeyStore(keyStoreForm.get( + bPKDec.getKeyStoreFileName())); + + // encrypt key information + final byte[] serKeyInfo = SerializationUtils.serialize(keyInfo); + try { + final EncryptedData encryptkeyInfo = ConfigurationEncryptionUtils.getInstance().encrypt(serKeyInfo); + bPKDec.setIv(encryptkeyInfo.getIv()); + bPKDec.setKeyInformation(encryptkeyInfo.getEncData()); + + } catch (final BuildException e) { + log.error("Configuration encryption FAILED.", e); + return LanguageHelper.getErrorString("error.general.text", request); + + } + } + + request.getSession().setAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION, null); + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + final HttpSession session = request.getSession(); + final List<String> errors = new ArrayList<>(); + + String check = null; + + final OAFileUploadValidation valiator_fileUpload = new OAFileUploadValidation(); + // validate BKU-selection template + final List<String> templateError = valiator_fileUpload.validate(getKeyStoreFileUploadFileName(), + getKeyStoreFileUpload(), "validation.bPKDec.keyStore", keyStoreForm, request); + if (templateError != null && templateError.size() == 0) { + if (keyStoreForm != null && keyStoreForm.size() > 0) { + session.setAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION, keyStoreForm); + + } else { + keyStoreForm = (Map<String, byte[]>) session.getAttribute(Constants.SESSION_BPKENCRYPTIONDECRYPTION); + } + + } else { + errors.addAll(templateError); + + } + + if (keyStoreForm != null && keyStoreForm.size() > 0) { + check = getKeyStorePassword(); + if (MiscUtil.isEmpty(check)) { + log.info("bPK decryption keystore password is empty"); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStorePassword.empty", request)); + + } else { + if (ValidationHelper.containsNotValidCharacter(check, false)) { + log.warn("bPK decryption keystore password contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStorePassword.valid", + new Object[] { ValidationHelper.getNotValidCharacter(false) }, request)); + } - - if (errors.size() > 0) { - validationError = true; - + } + + check = getKeyAlias(); + if (MiscUtil.isEmpty(check)) { + log.info("bPK decryption key alias is empty"); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyAlias.empty", request)); + + } else { + if (ValidationHelper.containsNotValidCharacter(check, false)) { + log.warn("bPK decryption key alias contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyAlias.valid", + new Object[] { ValidationHelper.getNotValidCharacter(false) }, request)); + } - - return errors; - - } - - /** - * @return the keyStorePassword - */ - public String getKeyStorePassword() { - return keyStorePassword; - } - - /** - * @param keyStorePassword the keyStorePassword to set - */ - public void setKeyStorePassword(String keyStorePassword) { - this.keyStorePassword = keyStorePassword; - } - - /** - * @return the keyAlias - */ - public String getKeyAlias() { - return keyAlias; - } - - /** - * @param keyAlias the keyAlias to set - */ - public void setKeyAlias(String keyAlias) { - this.keyAlias = keyAlias; - } - - /** - * @return the keyPassword - */ - public String getKeyPassword() { - return keyPassword; - } - - /** - * @param keyPassword the keyPassword to set - */ - public void setKeyPassword(String keyPassword) { - this.keyPassword = keyPassword; - } - - /** - * @return the keyStoreFileUpload - */ - public List<File> getKeyStoreFileUpload() { - return keyStoreFileUpload; - } - - /** - * @param keyStoreFileUpload the keyStoreFileUpload to set - */ - public void setKeyStoreFileUpload(List<File> keyStoreFileUpload) { - this.keyStoreFileUpload = keyStoreFileUpload; - } - - /** - * @return the keyStoreFileUploadContentType - */ - public List<String> getKeyStoreFileUploadContentType() { - return keyStoreFileUploadContentType; - } - - /** - * @param keyStoreFileUploadContentType the keyStoreFileUploadContentType to set - */ - public void setKeyStoreFileUploadContentType( - List<String> keyStoreFileUploadContentType) { - this.keyStoreFileUploadContentType = keyStoreFileUploadContentType; - } - - /** - * @return the keyStoreFileUploadFileName - */ - public List<String> getKeyStoreFileUploadFileName() { - return keyStoreFileUploadFileName; - } - - /** - * @param keyStoreFileUploadFileName the keyStoreFileUploadFileName to set - */ - public void setKeyStoreFileUploadFileName( - List<String> keyStoreFileUploadFileName) { - this.keyStoreFileUploadFileName = keyStoreFileUploadFileName; - } - - /** - * @return the deletekeyStore - */ - public boolean isDeletekeyStore() { - return deletekeyStore; - } - - /** - * @param deletekeyStore the deletekeyStore to set - */ - public void setDeletekeyStore(boolean deletekeyStore) { - this.deletekeyStore = deletekeyStore; - } - - /** - * @return the validationError - */ - public boolean isValidationError() { - return validationError; - } - - + } + + check = getKeyPassword(); + if (MiscUtil.isNotEmpty(check)) { + if (ValidationHelper.containsNotValidCharacter(check, false)) { + log.warn("bPK decryption key password contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyPassword.valid", + new Object[] { ValidationHelper.getNotValidCharacter(false) }, request)); + + } + } + + final BPKDecryptionParameters keyInfo = new BPKDecryptionParameters(); + keyInfo.setKeyAlias(keyAlias); + keyInfo.setKeyPassword(keyPassword); + keyInfo.setKeyStorePassword(keyStorePassword); + final Iterator<String> interator = keyStoreForm.keySet().iterator(); + final String fileName = interator.next(); + keyInfo.setKeyStore(keyStoreForm.get(fileName)); + if (keyInfo.getPrivateKey() == null) { + log.info("Open keyStore FAILED."); + errors.add(LanguageHelper.getErrorString("validation.bPKDec.keyStore.file.valid", request)); + + } + } + + if (errors.size() > 0) { + validationError = true; + + } + + return errors; + + } + + /** + * @return the keyStorePassword + */ + public String getKeyStorePassword() { + return keyStorePassword; + } + + /** + * @param keyStorePassword the keyStorePassword to set + */ + public void setKeyStorePassword(String keyStorePassword) { + this.keyStorePassword = keyStorePassword; + } + + /** + * @return the keyAlias + */ + public String getKeyAlias() { + return keyAlias; + } + + /** + * @param keyAlias the keyAlias to set + */ + public void setKeyAlias(String keyAlias) { + this.keyAlias = keyAlias; + } + + /** + * @return the keyPassword + */ + public String getKeyPassword() { + return keyPassword; + } + + /** + * @param keyPassword the keyPassword to set + */ + public void setKeyPassword(String keyPassword) { + this.keyPassword = keyPassword; + } + + /** + * @return the keyStoreFileUpload + */ + public List<File> getKeyStoreFileUpload() { + return keyStoreFileUpload; + } + + /** + * @param keyStoreFileUpload the keyStoreFileUpload to set + */ + public void setKeyStoreFileUpload(List<File> keyStoreFileUpload) { + this.keyStoreFileUpload = keyStoreFileUpload; + } + + /** + * @return the keyStoreFileUploadContentType + */ + public List<String> getKeyStoreFileUploadContentType() { + return keyStoreFileUploadContentType; + } + + /** + * @param keyStoreFileUploadContentType the keyStoreFileUploadContentType to set + */ + public void setKeyStoreFileUploadContentType( + List<String> keyStoreFileUploadContentType) { + this.keyStoreFileUploadContentType = keyStoreFileUploadContentType; + } + + /** + * @return the keyStoreFileUploadFileName + */ + public List<String> getKeyStoreFileUploadFileName() { + return keyStoreFileUploadFileName; + } + + /** + * @param keyStoreFileUploadFileName the keyStoreFileUploadFileName to set + */ + public void setKeyStoreFileUploadFileName( + List<String> keyStoreFileUploadFileName) { + this.keyStoreFileUploadFileName = keyStoreFileUploadFileName; + } + + /** + * @return the deletekeyStore + */ + public boolean isDeletekeyStore() { + return deletekeyStore; + } + + /** + * @param deletekeyStore the deletekeyStore to set + */ + public void setDeletekeyStore(boolean deletekeyStore) { + this.deletekeyStore = deletekeyStore; + } + + /** + * @return the validationError + */ + public boolean isValidationError() { + return validationError; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java index c51513193..45a3dba1b 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAGeneralConfig.java @@ -27,8 +27,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; @@ -36,130 +34,151 @@ import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.util.MiscUtil; - - -public class OAGeneralConfig implements IOnlineApplicationData{ - private static final Logger log = Logger.getLogger(OAGeneralConfig.class); - - private boolean isActive = false; - - private String identifier = null; - private String friendlyName = null; - private boolean businessService = false; - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OAGeneralInformation"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, HttpServletRequest request) { - isActive = dbOAConfig.isIsActive(); - - friendlyName = dbOAConfig.getFriendlyName(); - identifier = dbOAConfig.getPublicURLPrefix(); - - if (dbOAConfig.getType().equals(Constants.MOA_CONFIG_BUSINESSSERVICE)) - businessService = true; - else - businessService = false; - - return null; - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); - } - - if (authUser.isAdmin()) dbOA.setIsActive(isActive()); - - dbOA.setPublicURLPrefix(getIdentifier()); - dbOA.setFriendlyName(getFriendlyName()); - - if (isBusinessService() || authUser.isOnlyBusinessService()) { - dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); - - } else { - dbOA.setType(null); - } - - return null; - - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - - List<String> errors = new ArrayList<String>(); - String check; - - //check OA FriendlyName - check = getFriendlyName(); - if (MiscUtil.isNotEmpty(check)) { - if (ValidationHelper.containsNotValidCharacter(check, false)) { - log.warn("OAFriendlyName contains potentail XSS characters: " + check); - errors.add(LanguageHelper.getErrorString("validation.general.oafriendlyname.valid", - new Object[] {ValidationHelper.getNotValidCharacter(false)}, request )); - } - } else { - log.info("OA friendlyName is empty"); - errors.add(LanguageHelper.getErrorString("validation.general.oafriendlyname.empty", request)); - } - - return errors; - - } - - public boolean isBusinessService() { - return businessService; - } - - public void setBusinessService(boolean businessService) { - this.businessService = businessService; - } - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getFriendlyName() { - return friendlyName; - } - - public void setFriendlyName(String friendlyName) { - this.friendlyName = friendlyName; - } - - public boolean isActive() { - return isActive; - } - - public void setActive(boolean isActive) { - this.isActive = isActive; - } +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class OAGeneralConfig implements IOnlineApplicationData { + + private boolean isActive = false; + + private String identifier = null; + private String friendlyName = null; + private boolean businessService = false; + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OAGeneralInformation"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, + HttpServletRequest request) { + isActive = dbOAConfig.isIsActive(); + + friendlyName = dbOAConfig.getFriendlyName(); + identifier = dbOAConfig.getPublicURLPrefix(); + + if (dbOAConfig.getType().equals(Constants.MOA_CONFIG_BUSINESSSERVICE)) { + businessService = true; + } else { + businessService = false; + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } + + if (authUser.isAdmin()) { + dbOA.setIsActive(isActive()); + } + + dbOA.setPublicURLPrefix(getIdentifier()); + dbOA.setFriendlyName(getFriendlyName()); + + if (isBusinessService() || authUser.isOnlyBusinessService()) { + dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); + + } else { + dbOA.setType(null); + } + + return null; + + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + + final List<String> errors = new ArrayList<>(); + String check; + + // check OA FriendlyName + check = getFriendlyName(); + if (MiscUtil.isNotEmpty(check)) { + if (ValidationHelper.containsNotValidCharacter(check, false)) { + log.warn("OAFriendlyName contains potentail XSS characters: " + check); + errors.add(LanguageHelper.getErrorString("validation.general.oafriendlyname.valid", + new Object[] { ValidationHelper.getNotValidCharacter(false) }, request)); + } + } else { + log.info("OA friendlyName is empty"); + errors.add(LanguageHelper.getErrorString("validation.general.oafriendlyname.empty", request)); + } + + return errors; + + } + + public boolean isBusinessService() { + return businessService; + } + + public void setBusinessService(boolean businessService) { + this.businessService = businessService; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getFriendlyName() { + return friendlyName; + } + + public void setFriendlyName(String friendlyName) { + this.friendlyName = friendlyName; + } + + public boolean isActive() { + return isActive; + } + + public void setActive(boolean isActive) { + this.isActive = isActive; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java index a4d71f0ed..ef5658ca4 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAMOAIDPInterfederationConfig.java @@ -27,194 +27,212 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.util.MiscUtil; +import lombok.extern.slf4j.Slf4j; /** * @author tlenz * */ +@Slf4j public class OAMOAIDPInterfederationConfig implements IOnlineApplicationData { - private static final Logger log = Logger.getLogger(OAMOAIDPInterfederationConfig.class); - - private String queryURL; - private Boolean inboundSSO = true; - private Boolean outboundSSO = true; - private Boolean storeSSOSession = true; - private Boolean passiveRequest = true; - private Boolean localAuthOnError = true; - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "MOAIDPInterfederation"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, - AuthenticatedUser authUser, HttpServletRequest request) { - - InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); - if (moaIDP != null) { - this.queryURL = moaIDP.getAttributeQueryURL(); - this.inboundSSO = moaIDP.isInboundSSO(); - this.outboundSSO = moaIDP.isOutboundSSO(); - this.storeSSOSession = moaIDP.isStoreSSOSession(); - this.localAuthOnError = moaIDP.isPerformLocalAuthenticationOnError(); - this.passiveRequest = moaIDP.isPerformPassivRequest(); - } - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - - if (authUser.isAdmin()) { - dbOA.setIsInterfederationIDP(true); - - InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); - if (moaIDP == null) { - moaIDP = new InterfederationIDPType(); - dbOA.setInterfederationIDP(moaIDP); - } - - moaIDP.setAttributeQueryURL(queryURL); - moaIDP.setInboundSSO(inboundSSO); - moaIDP.setOutboundSSO(outboundSSO); - moaIDP.setStoreSSOSession(storeSSOSession); - moaIDP.setPerformLocalAuthenticationOnError(localAuthOnError); - moaIDP.setPerformPassivRequest(passiveRequest); - - } - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - - List<String> errors = new ArrayList<String>(); - - if (MiscUtil.isNotEmpty(queryURL)) { - if (!ValidationHelper.validateURL(queryURL)) { - log.info("AttributeQuery URL is not valid"); - errors.add(LanguageHelper.getErrorString("validation.interfederation.moaidp.queryurl.valid", request)); - - } - } - + private String queryURL; + private Boolean inboundSSO = true; + private Boolean outboundSSO = true; + private Boolean storeSSOSession = true; + private Boolean passiveRequest = true; + private Boolean localAuthOnError = true; + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "MOAIDPInterfederation"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + + final InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); + if (moaIDP != null) { + this.queryURL = moaIDP.getAttributeQueryURL(); + this.inboundSSO = moaIDP.isInboundSSO(); + this.outboundSSO = moaIDP.isOutboundSSO(); + this.storeSSOSession = moaIDP.isStoreSSOSession(); + this.localAuthOnError = moaIDP.isPerformLocalAuthenticationOnError(); + this.passiveRequest = moaIDP.isPerformPassivRequest(); + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + if (authUser.isAdmin()) { + dbOA.setIsInterfederationIDP(true); + + InterfederationIDPType moaIDP = dbOA.getInterfederationIDP(); + if (moaIDP == null) { + moaIDP = new InterfederationIDPType(); + dbOA.setInterfederationIDP(moaIDP); + } + + moaIDP.setAttributeQueryURL(queryURL); + moaIDP.setInboundSSO(inboundSSO); + moaIDP.setOutboundSSO(outboundSSO); + moaIDP.setStoreSSOSession(storeSSOSession); + moaIDP.setPerformLocalAuthenticationOnError(localAuthOnError); + moaIDP.setPerformPassivRequest(passiveRequest); + + } + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + + final List<String> errors = new ArrayList<>(); + + if (MiscUtil.isNotEmpty(queryURL)) { + if (!ValidationHelper.validateURL(queryURL)) { + log.info("AttributeQuery URL is not valid"); + errors.add(LanguageHelper.getErrorString("validation.interfederation.moaidp.queryurl.valid", + request)); + + } + } + // if (inboundSSO && MiscUtil.isEmpty(queryURL)) { // log.info("Inbound Single Sign-On requires AttributQueryURL configuration."); // errors.add(LanguageHelper.getErrorString("validation.interfederation.moaidp.queryurl.empty", request)); // } - - return errors; - } - - /** - * @return the queryURL - */ - public String getQueryURL() { - return queryURL; - } - - /** - * @param queryURL the queryURL to set - */ - public void setQueryURL(String queryURL) { - this.queryURL = queryURL; - } - - /** - * @return the inboundSSO - */ - public boolean isInboundSSO() { - return inboundSSO.booleanValue(); - } - - /** - * @param inboundSSO the inboundSSO to set - */ - public void setInboundSSO(boolean inboundSSO) { - this.inboundSSO = inboundSSO; - } - - /** - * @return the outboundSSO - */ - public boolean isOutboundSSO() { - return outboundSSO.booleanValue(); - } - - /** - * @param outboundSSO the outboundSSO to set - */ - public void setOutboundSSO(boolean outboundSSO) { - this.outboundSSO = outboundSSO; - } - - /** - * @return the storeSSOSession - */ - public boolean isStoreSSOSession() { - return storeSSOSession.booleanValue(); - } - - /** - * @param storeSSOSession the storeSSOSession to set - */ - public void setStoreSSOSession(boolean storeSSOSession) { - this.storeSSOSession = storeSSOSession; - } - - /** - * @return the passiveRequest - */ - public boolean isPassiveRequest() { - return passiveRequest.booleanValue(); - } - - /** - * @param passiveRequest the passiveRequest to set - */ - public void setPassiveRequest(boolean passiveRequest) { - this.passiveRequest = passiveRequest; - } - - /** - * @return the localAuthOnError - */ - public boolean isLocalAuthOnError() { - return localAuthOnError.booleanValue(); - } - - /** - * @param localAuthOnError the localAuthOnError to set - */ - public void setLocalAuthOnError(boolean localAuthOnError) { - this.localAuthOnError = localAuthOnError; - } - - + + return errors; + } + + /** + * @return the queryURL + */ + public String getQueryURL() { + return queryURL; + } + + /** + * @param queryURL the queryURL to set + */ + public void setQueryURL(String queryURL) { + this.queryURL = queryURL; + } + + /** + * @return the inboundSSO + */ + public boolean isInboundSSO() { + return inboundSSO.booleanValue(); + } + + /** + * @param inboundSSO the inboundSSO to set + */ + public void setInboundSSO(boolean inboundSSO) { + this.inboundSSO = inboundSSO; + } + + /** + * @return the outboundSSO + */ + public boolean isOutboundSSO() { + return outboundSSO.booleanValue(); + } + + /** + * @param outboundSSO the outboundSSO to set + */ + public void setOutboundSSO(boolean outboundSSO) { + this.outboundSSO = outboundSSO; + } + + /** + * @return the storeSSOSession + */ + public boolean isStoreSSOSession() { + return storeSSOSession.booleanValue(); + } + + /** + * @param storeSSOSession the storeSSOSession to set + */ + public void setStoreSSOSession(boolean storeSSOSession) { + this.storeSSOSession = storeSSOSession; + } + + /** + * @return the passiveRequest + */ + public boolean isPassiveRequest() { + return passiveRequest.booleanValue(); + } + + /** + * @param passiveRequest the passiveRequest to set + */ + public void setPassiveRequest(boolean passiveRequest) { + this.passiveRequest = passiveRequest; + } + + /** + * @return the localAuthOnError + */ + public boolean isLocalAuthOnError() { + return localAuthOnError.booleanValue(); + } + + /** + * @param localAuthOnError the localAuthOnError to set + */ + public void setLocalAuthOnError(boolean localAuthOnError) { + this.localAuthOnError = localAuthOnError; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java index ce50c847a..bae37b531 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAOAuth20Config.java @@ -30,7 +30,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAOAUTH20; @@ -40,132 +39,150 @@ import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.validation.oa.OAOAUTH20ConfigValidation; import at.gv.egovernment.moa.id.protocols.oauth20.OAuth20Util; +import lombok.extern.slf4j.Slf4j; -public class OAOAuth20Config implements IOnlineApplicationData{ - - private final Logger log = Logger.getLogger(OAOAuth20Config.class); - - private String clientId = null; - private String clientSecret = null; - private String redirectUri = null; - - public OAOAuth20Config() { - this.generateClientSecret(); - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OAOpenIDConnect"; - } - - public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, HttpServletRequest request) { - List<String> errors = new ArrayList<String>(); - - HttpSession session = request.getSession(); - - AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); - if (authdata != null) { - // set client id to public url prefix - this.clientId = dbOAConfig.getPublicURLPrefix(); - - OAOAUTH20 config = authdata.getOAOAUTH20(); - - if (config != null) { - // validate secret - if (StringUtils.isNotEmpty(config.getOAuthClientSecret())) { - this.clientSecret = config.getOAuthClientSecret(); - } else { - this.generateClientSecret(); - } - - // validate redirectUri - if (StringUtils.isNotEmpty(config.getOAuthRedirectUri()) && OAuth20Util.isUrl(config.getOAuthRedirectUri())) { - this.redirectUri = config.getOAuthRedirectUri(); - } else { - errors.add(LanguageHelper.getErrorString("error.oa.oauth.redirecturi", request)); - } - } else { - this.generateClientSecret(); - } - } - - session.setAttribute(Constants.SESSION_OAUTH20SECRET, this.getClientSecret()); - - return null; - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - return new OAOAUTH20ConfigValidation().validate(this, request); - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); +@Slf4j +public class OAOAuth20Config implements IOnlineApplicationData { + + private String clientId = null; + private String clientSecret = null; + private String redirectUri = null; + + public OAOAuth20Config() { + this.generateClientSecret(); + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OAOpenIDConnect"; + } + + @Override + public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, + HttpServletRequest request) { + final List<String> errors = new ArrayList<>(); + + final HttpSession session = request.getSession(); + + final AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); + if (authdata != null) { + // set client id to public url prefix + this.clientId = dbOAConfig.getPublicURLPrefix(); + + final OAOAUTH20 config = authdata.getOAOAUTH20(); + + if (config != null) { + // validate secret + if (StringUtils.isNotEmpty(config.getOAuthClientSecret())) { + this.clientSecret = config.getOAuthClientSecret(); + } else { + this.generateClientSecret(); } - - log.debug("Saving OAuth 2.0 configuration:"); - OAOAUTH20 oaOAuth20 = authoa.getOAOAUTH20(); - if (oaOAuth20 == null) { - oaOAuth20 = new OAOAUTH20(); - authoa.setOAOAUTH20(oaOAuth20); + + // validate redirectUri + if (StringUtils.isNotEmpty(config.getOAuthRedirectUri()) && OAuth20Util.isUrl(config + .getOAuthRedirectUri())) { + this.redirectUri = config.getOAuthRedirectUri(); + } else { + errors.add(LanguageHelper.getErrorString("error.oa.oauth.redirecturi", request)); } + } else { + this.generateClientSecret(); + } + } + + session.setAttribute(Constants.SESSION_OAUTH20SECRET, this.getClientSecret()); + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + return new OAOAUTH20ConfigValidation().validate(this, request); + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } + + log.debug("Saving OAuth 2.0 configuration:"); + OAOAUTH20 oaOAuth20 = authoa.getOAOAUTH20(); + if (oaOAuth20 == null) { + oaOAuth20 = new OAOAUTH20(); + authoa.setOAOAUTH20(oaOAuth20); + } + + oaOAuth20.setOAuthClientId(dbOA.getPublicURLPrefix()); + // oaOAuth20.setOAuthClientSecret(oauth20OA.getClientSecret()); + oaOAuth20.setOAuthRedirectUri(getRedirectUri()); + log.debug("client id: " + getClientId()); + log.debug("client secret: " + getClientSecret()); + log.debug("redirect uri:" + getRedirectUri()); + + oaOAuth20.setOAuthClientSecret((String) request.getSession().getAttribute( + Constants.SESSION_OAUTH20SECRET)); + request.getSession().setAttribute(Constants.SESSION_OAUTH20SECRET, null); + + return null; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientSecret() { + return clientSecret; + } + + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } - oaOAuth20.setOAuthClientId(dbOA.getPublicURLPrefix()); - // oaOAuth20.setOAuthClientSecret(oauth20OA.getClientSecret()); - oaOAuth20.setOAuthRedirectUri(getRedirectUri()); - log.debug("client id: " + getClientId()); - log.debug("client secret: " + getClientSecret()); - log.debug("redirect uri:" + getRedirectUri()); - - oaOAuth20.setOAuthClientSecret((String) request.getSession().getAttribute(Constants.SESSION_OAUTH20SECRET)); - request.getSession().setAttribute(Constants.SESSION_OAUTH20SECRET, null); - - return null; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientSecret() { - return clientSecret; - } - - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - public String getRedirectUri() { - return redirectUri; - } - - public void setRedirectUri(String redirectUri) { - this.redirectUri = redirectUri; - } - - public void generateClientSecret() { - this.clientSecret = UUID.randomUUID().toString(); - } + public void generateClientSecret() { + this.clientSecret = UUID.randomUUID().toString(); + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java index 4be1a81de..008617e76 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OAPVP2Config.java @@ -32,228 +32,247 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - -import iaik.x509.X509Certificate; import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAPVP2; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; -import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.validation.oa.OAPVP2ConfigValidation; import at.gv.egovernment.moa.util.Base64Utils; import at.gv.egovernment.moa.util.MiscUtil; +import iaik.x509.X509Certificate; +import lombok.extern.slf4j.Slf4j; -public class OAPVP2Config implements IOnlineApplicationData{ - - private final Logger log = Logger.getLogger(OAPVP2Config.class); - - private boolean reLoad = false; - - private String metaDataURL = null; - private String certificateDN = null; - - private File fileUpload = null; - private String fileUploadContentType; - private String fileUploadFileName; - - private byte[] storedCert = null; - - public OAPVP2Config() { - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OAPVP2"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser) - */ - @Override - public String store(OnlineApplication dboa, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA authoa = dboa.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dboa.setAuthComponentOA(authoa); - } - OAPVP2 pvp2 = authoa.getOAPVP2(); - if (pvp2 == null) { - pvp2 = new OAPVP2(); - authoa.setOAPVP2(pvp2); - } +@Slf4j +public class OAPVP2Config implements IOnlineApplicationData { + + private boolean reLoad = false; + + private String metaDataURL = null; + private String certificateDN = null; + + private File fileUpload = null; + private String fileUploadContentType; + private String fileUploadFileName; + + private byte[] storedCert = null; + + public OAPVP2Config() { + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OAPVP2"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser) + */ + @Override + public String store(OnlineApplication dboa, AuthenticatedUser authUser, HttpServletRequest request) { + AuthComponentOA authoa = dboa.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dboa.setAuthComponentOA(authoa); + } + OAPVP2 pvp2 = authoa.getOAPVP2(); + if (pvp2 == null) { + pvp2 = new OAPVP2(); + authoa.setOAPVP2(pvp2); + } + + try { + + if (getFileUpload() != null) { + pvp2.setCertificate(getCertificate()); + setReLoad(true); + + } else if (storedCert != null) { + pvp2.setCertificate(storedCert); + } + + } catch (final CertificateException e) { + log.info("Uploaded Certificate can not be found", e); + return LanguageHelper.getErrorString("validation.pvp2.certificate.notfound", request); + } catch (final IOException e) { + log.info("Uploaded Certificate can not be parsed", e); + return LanguageHelper.getErrorString("validation.pvp2.certificate.format", request); + } + + if (getMetaDataURL() != null && + !getMetaDataURL().equals(pvp2.getMetadataURL())) { + setReLoad(true); + } + pvp2.setMetadataURL(getMetaDataURL()); + + if (isReLoad()) { + pvp2.setUpdateRequiredItem(new Date()); + } + + return null; + + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + return new OAPVP2ConfigValidation().validate(this, general.getIdentifier(), request); + } - try { - - if (getFileUpload() != null) { - pvp2.setCertificate(getCertificate()); - setReLoad(true); - - } else if (storedCert != null) - pvp2.setCertificate(storedCert); - - } catch (CertificateException e) { - log.info("Uploaded Certificate can not be found", e); - return LanguageHelper.getErrorString("validation.pvp2.certificate.notfound", request); - } catch (IOException e) { - log.info("Uploaded Certificate can not be parsed", e); - return LanguageHelper.getErrorString("validation.pvp2.certificate.format", request); + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication) + */ + @Override + public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, + HttpServletRequest request) { + final List<String> errors = new ArrayList<>(); + + final AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); + if (authdata != null) { + final OAPVP2 pvp2 = authdata.getOAPVP2(); + if (pvp2 != null) { + metaDataURL = pvp2.getMetadataURL(); + + if (pvp2.getCertificate() != null && + !new String(pvp2.getCertificate()).equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT)) { + try { + // byte[] cert = pvp2.getCertificate(); + final byte[] cert = Base64Utils.decode(new String(pvp2.getCertificate()), false); + if (MiscUtil.isNotEmpty(cert)) { + final X509Certificate x509 = new X509Certificate(cert); + certificateDN = x509.getSubjectDN().getName(); + } + } catch (final CertificateException e) { + try { + final byte[] cert = pvp2.getCertificate(); + if (MiscUtil.isNotEmpty(cert)) { + final X509Certificate x509 = new X509Certificate(cert); + certificateDN = x509.getSubjectDN().getName(); + } + + } catch (final CertificateException e1) { + log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig + .getPublicURLPrefix(), e1); + errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); + + } + + } catch (final IOException e) { + log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig + .getPublicURLPrefix()); + errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); + } } + } + } + return errors; + } - if (getMetaDataURL() != null && - !getMetaDataURL().equals(pvp2.getMetadataURL())) - setReLoad(true); - pvp2.setMetadataURL(getMetaDataURL()); - - if (isReLoad()) - pvp2.setUpdateRequiredItem(new Date()); - - return null; - - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - return new OAPVP2ConfigValidation().validate(this, general.getIdentifier(), request); - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication) - */ - @Override - public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, HttpServletRequest request) { - List<String> errors = new ArrayList<String>(); - - AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); - if (authdata != null) { - OAPVP2 pvp2 = authdata.getOAPVP2(); - if (pvp2 != null) { - metaDataURL = pvp2.getMetadataURL(); - - if (pvp2.getCertificate() != null && - !(new String(pvp2.getCertificate())).equals(MOAIDConfigurationConstants.WEBGUI_EMPTY_ELEMENT)) { - try { - //byte[] cert = pvp2.getCertificate(); - byte[] cert = Base64Utils.decode(new String(pvp2.getCertificate()), false); - if (MiscUtil.isNotEmpty(cert)) { - X509Certificate x509 = new X509Certificate(cert); - certificateDN = x509.getSubjectDN().getName(); - } - } catch (CertificateException e) { - try { - byte[] cert = pvp2.getCertificate(); - if (MiscUtil.isNotEmpty(cert)) { - X509Certificate x509 = new X509Certificate(cert); - certificateDN = x509.getSubjectDN().getName(); - } - - } catch (CertificateException e1) { - log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig.getPublicURLPrefix(), e1); - errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); - - } - - } catch (IOException e) { - log.warn("PVP2 certificate can not be loaded from Online-Applikation with ID " + dbOAConfig.getPublicURLPrefix()); - errors.add(LanguageHelper.getErrorString("error.oa.pvp2.certificate", request)); - } - } - } - } - return errors; - } - - public byte[] getCertificate() throws CertificateException, IOException { - - FileInputStream filestream = new FileInputStream(fileUpload); - X509Certificate x509 = new X509Certificate(filestream); - return x509.getEncoded(); - } - - public void setStoredCert(byte[] storedCert) { - this.storedCert = storedCert; - } - - public String getMetaDataURL() { - return metaDataURL; - } - public void setMetaDataURL(String metaDataURL) { - this.metaDataURL = metaDataURL; - } - - /** - * @return the certificateDN - */ - public String getCertificateDN() { - return certificateDN; - } - - /** - * @return the fileUpLoad - */ - public File getFileUpload() { - return fileUpload; - } - - /** - * @param fileUpLoad the fileUpLoad to set - */ - public void setFileUpload(File fileUpload) { - this.fileUpload = fileUpload; - } - - /** - * @return the fileUploadContentType - */ - public String getFileUploadContentType() { - return fileUploadContentType; - } - - /** - * @param fileUploadContentType the fileUploadContentType to set - */ - public void setFileUploadContentType(String fileUploadContentType) { - this.fileUploadContentType = fileUploadContentType; - } - - /** - * @return the fileUploadFileName - */ - public String getFileUploadFileName() { - return fileUploadFileName; - } - - /** - * @param fileUploadFileName the fileUploadFileName to set - */ - public void setFileUploadFileName(String fileUploadFileName) { - this.fileUploadFileName = fileUploadFileName; - } - - /** - * @return the reLoad - */ - public boolean isReLoad() { - return reLoad; - } - - /** - * @param reLoad the reLoad to set - */ - public void setReLoad(boolean reLoad) { - this.reLoad = reLoad; - } - -} + public byte[] getCertificate() throws CertificateException, IOException { + + final FileInputStream filestream = new FileInputStream(fileUpload); + final X509Certificate x509 = new X509Certificate(filestream); + return x509.getEncoded(); + } + + public void setStoredCert(byte[] storedCert) { + this.storedCert = storedCert; + } + + public String getMetaDataURL() { + return metaDataURL; + } + + public void setMetaDataURL(String metaDataURL) { + this.metaDataURL = metaDataURL; + } + /** + * @return the certificateDN + */ + public String getCertificateDN() { + return certificateDN; + } + /** + * @return the fileUpLoad + */ + public File getFileUpload() { + return fileUpload; + } + + /** + * @param fileUpLoad the fileUpLoad to set + */ + public void setFileUpload(File fileUpload) { + this.fileUpload = fileUpload; + } + + /** + * @return the fileUploadContentType + */ + public String getFileUploadContentType() { + return fileUploadContentType; + } + + /** + * @param fileUploadContentType the fileUploadContentType to set + */ + public void setFileUploadContentType(String fileUploadContentType) { + this.fileUploadContentType = fileUploadContentType; + } + + /** + * @return the fileUploadFileName + */ + public String getFileUploadFileName() { + return fileUploadFileName; + } + + /** + * @param fileUploadFileName the fileUploadFileName to set + */ + public void setFileUploadFileName(String fileUploadFileName) { + this.fileUploadFileName = fileUploadFileName; + } + + /** + * @return the reLoad + */ + public boolean isReLoad() { + return reLoad; + } + + /** + * @param reLoad the reLoad to set + */ + public void setReLoad(boolean reLoad) { + this.reLoad = reLoad; + } + +} diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java index 18bebf9d8..76fd31ccd 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OARevisionsLogData.java @@ -39,113 +39,134 @@ import at.gv.egovernment.moa.util.MiscUtil; */ public class OARevisionsLogData implements IOnlineApplicationData { - private boolean active = false; - private String eventCodes = null; - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OARevisionsLogging"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, - AuthenticatedUser authUser, HttpServletRequest request) { - - if (dbOA.getIsRevisionsLogActive() != null) - active = dbOA.getIsRevisionsLogActive(); - - if (MiscUtil.isNotEmpty(dbOA.getEventCodes())) - eventCodes = dbOA.getEventCodes(); - - return null; - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - - dbOA.setIsRevisionsLogActive(active); - - if (MiscUtil.isNotEmpty(eventCodes)) { - dbOA.setEventCodes(KeyValueUtils.normalizeCSVValueString(eventCodes)); - - } - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - List<String> errors = new ArrayList<String>(); - - if (active && MiscUtil.isEmpty(eventCodes)) { - errors.add(LanguageHelper.getErrorString( - "error.oa.reversion.log.enabled")); - - } - - if (MiscUtil.isNotEmpty(eventCodes)) { - String[] codes = eventCodes.split(","); - for (String el: codes) { - try { - Integer.parseInt(el.trim()); - - } catch (NumberFormatException e) { - errors.add(LanguageHelper.getErrorString( - "error.oa.reversion.log.eventcodes")); - break; - - } - - } - - } - - return errors; - } - - /** - * @return the active - */ - public boolean isActive() { - return active; - } - - /** - * @param active the active to set - */ - public void setActive(boolean active) { - this.active = active; - } - - /** - * @return the eventCodes - */ - public String getEventCodes() { - return eventCodes; - } - - /** - * @param eventCodes the eventCodes to set - */ - public void setEventCodes(String eventCodes) { - this.eventCodes = eventCodes; - } - - + private boolean active = false; + private String eventCodes = null; + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OARevisionsLogging"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + + if (dbOA.getIsRevisionsLogActive() != null) { + active = dbOA.getIsRevisionsLogActive(); + } + + if (MiscUtil.isNotEmpty(dbOA.getEventCodes())) { + eventCodes = dbOA.getEventCodes(); + } + + return null; + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + dbOA.setIsRevisionsLogActive(active); + + if (MiscUtil.isNotEmpty(eventCodes)) { + dbOA.setEventCodes(KeyValueUtils.normalizeCSVValueString(eventCodes)); + + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + final List<String> errors = new ArrayList<>(); + + if (active && MiscUtil.isEmpty(eventCodes)) { + errors.add(LanguageHelper.getErrorString( + "error.oa.reversion.log.enabled")); + + } + + if (MiscUtil.isNotEmpty(eventCodes)) { + final String[] codes = eventCodes.split(","); + for (final String el : codes) { + try { + Integer.parseInt(el.trim()); + + } catch (final NumberFormatException e) { + errors.add(LanguageHelper.getErrorString( + "error.oa.reversion.log.eventcodes")); + break; + + } + + } + + } + + return errors; + } + + /** + * @return the active + */ + public boolean isActive() { + return active; + } + + /** + * @param active the active to set + */ + public void setActive(boolean active) { + this.active = active; + } + + /** + * @return the eventCodes + */ + public String getEventCodes() { + return eventCodes; + } + + /** + * @param eventCodes the eventCodes to set + */ + public void setEventCodes(String eventCodes) { + this.eventCodes = eventCodes; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java index 2922231b3..f1ee853ae 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASAML1Config.java @@ -33,178 +33,213 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplicati import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OASAML1ConfigValidation; -public class OASAML1Config implements IOnlineApplicationData{ - - private Boolean isActive = false; - private Boolean provideStammZahl = false; - private Boolean provideAuthBlock = false; - private Boolean provideIdentityLink = false; - private Boolean provideCertificate = false; - private Boolean provideFullMandateData = false; - private Boolean useCondition = false; - private Boolean provideAllErrors = true; - private int conditionLength = -1; - - - public OASAML1Config() { - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OASAML1"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA authdata = dbOA.getAuthComponentOA(); - if (authdata != null) { - OASAML1 saml1 = authdata.getOASAML1(); - if (saml1 != null) { - provideAuthBlock = saml1.isProvideAUTHBlock(); - provideCertificate = saml1.isProvideCertificate(); - provideFullMandateData = saml1.isProvideFullMandatorData(); - provideIdentityLink = saml1.isProvideIdentityLink(); - provideStammZahl = saml1.isProvideStammzahl(); - - if (saml1.isProvideAllErrors() != null) - provideAllErrors = saml1.isProvideAllErrors(); - - if (saml1.isUseCondition() != null) - useCondition = saml1.isUseCondition(); - - if (saml1.getConditionLength() != null) - conditionLength = saml1.getConditionLength().intValue(); - - if (saml1.isIsActive() != null) - isActive = saml1.isIsActive(); - } - } - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - return new OASAML1ConfigValidation().validate(this, general, request); - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); - } - - OASAML1 saml1 = authoa.getOASAML1(); - if (saml1 == null) { - saml1 = new OASAML1(); - authoa.setOASAML1(saml1); - saml1.setIsActive(false); - } - - if (authUser.isAdmin()) { - saml1.setIsActive(isActive()); - } - - if (saml1.isIsActive() != null && saml1.isIsActive()) { - saml1.setProvideAUTHBlock(isProvideAuthBlock()); - saml1.setProvideCertificate(isProvideCertificate()); - saml1.setProvideFullMandatorData(isProvideFullMandateData()); - saml1.setProvideIdentityLink(isProvideIdentityLink()); - saml1.setProvideStammzahl(isProvideStammZahl()); - saml1.setUseCondition(isUseCondition()); - saml1.setProvideAllErrors(provideAllErrors); - saml1.setConditionLength(BigInteger.valueOf(getConditionLength())); - // TODO: set sourceID - // saml1.setSourceID(""); - } - - return null; - } - - public boolean isProvideStammZahl() { - return provideStammZahl; - } - public void setProvideStammZahl(boolean provideStammZahl) { - this.provideStammZahl = provideStammZahl; - } - public boolean isProvideAuthBlock() { - return provideAuthBlock; - } - public void setProvideAuthBlock(boolean provideAuthBlock) { - this.provideAuthBlock = provideAuthBlock; - } - public boolean isProvideIdentityLink() { - return provideIdentityLink; - } - public void setProvideIdentityLink(boolean provideIdentityLink) { - this.provideIdentityLink = provideIdentityLink; - } - public boolean isProvideCertificate() { - return provideCertificate; - } - public void setProvideCertificate(boolean provideCertificate) { - this.provideCertificate = provideCertificate; - } - public boolean isProvideFullMandateData() { - return provideFullMandateData; - } - public void setProvideFullMandateData(boolean provideFullMandateData) { - this.provideFullMandateData = provideFullMandateData; - } - public boolean isUseCondition() { - return useCondition; - } - public void setUseCondition(boolean useCondition) { - this.useCondition = useCondition; - } - public int getConditionLength() { - return conditionLength; - } - public void setConditionLength(int conditionLength) { - this.conditionLength = conditionLength; - } - - /** - * @return the isActive - */ - public boolean isActive() { - return isActive; - } - - /** - * @param isActive the isActive to set - */ - public void setActive(boolean isActive) { - this.isActive = isActive; - } - - /** - * @return the provideAllErrors - */ - public Boolean getProvideAllErrors() { - return provideAllErrors; - } - - /** - * @param provideAllErrors the provideAllErrors to set - */ - public void setProvideAllErrors(Boolean provideAllErrors) { - this.provideAllErrors = provideAllErrors; - } - - +public class OASAML1Config implements IOnlineApplicationData { + + private Boolean isActive = false; + private Boolean provideStammZahl = false; + private Boolean provideAuthBlock = false; + private Boolean provideIdentityLink = false; + private Boolean provideCertificate = false; + private Boolean provideFullMandateData = false; + private Boolean useCondition = false; + private Boolean provideAllErrors = true; + private int conditionLength = -1; + + public OASAML1Config() { + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OASAML1"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { + final AuthComponentOA authdata = dbOA.getAuthComponentOA(); + if (authdata != null) { + final OASAML1 saml1 = authdata.getOASAML1(); + if (saml1 != null) { + provideAuthBlock = saml1.isProvideAUTHBlock(); + provideCertificate = saml1.isProvideCertificate(); + provideFullMandateData = saml1.isProvideFullMandatorData(); + provideIdentityLink = saml1.isProvideIdentityLink(); + provideStammZahl = saml1.isProvideStammzahl(); + + if (saml1.isProvideAllErrors() != null) { + provideAllErrors = saml1.isProvideAllErrors(); + } + + if (saml1.isUseCondition() != null) { + useCondition = saml1.isUseCondition(); + } + + if (saml1.getConditionLength() != null) { + conditionLength = saml1.getConditionLength().intValue(); + } + + if (saml1.isIsActive() != null) { + isActive = saml1.isIsActive(); + } + } + } + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + return new OASAML1ConfigValidation().validate(this, general, request); + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, HttpServletRequest request) { + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } + + OASAML1 saml1 = authoa.getOASAML1(); + if (saml1 == null) { + saml1 = new OASAML1(); + authoa.setOASAML1(saml1); + saml1.setIsActive(false); + } + + if (authUser.isAdmin()) { + saml1.setIsActive(isActive()); + } + + if (saml1.isIsActive() != null && saml1.isIsActive()) { + saml1.setProvideAUTHBlock(isProvideAuthBlock()); + saml1.setProvideCertificate(isProvideCertificate()); + saml1.setProvideFullMandatorData(isProvideFullMandateData()); + saml1.setProvideIdentityLink(isProvideIdentityLink()); + saml1.setProvideStammzahl(isProvideStammZahl()); + saml1.setUseCondition(isUseCondition()); + saml1.setProvideAllErrors(provideAllErrors); + saml1.setConditionLength(BigInteger.valueOf(getConditionLength())); + // TODO: set sourceID + // saml1.setSourceID(""); + } + + return null; + } + + public boolean isProvideStammZahl() { + return provideStammZahl; + } + + public void setProvideStammZahl(boolean provideStammZahl) { + this.provideStammZahl = provideStammZahl; + } + + public boolean isProvideAuthBlock() { + return provideAuthBlock; + } + + public void setProvideAuthBlock(boolean provideAuthBlock) { + this.provideAuthBlock = provideAuthBlock; + } + + public boolean isProvideIdentityLink() { + return provideIdentityLink; + } + + public void setProvideIdentityLink(boolean provideIdentityLink) { + this.provideIdentityLink = provideIdentityLink; + } + + public boolean isProvideCertificate() { + return provideCertificate; + } + + public void setProvideCertificate(boolean provideCertificate) { + this.provideCertificate = provideCertificate; + } + + public boolean isProvideFullMandateData() { + return provideFullMandateData; + } + + public void setProvideFullMandateData(boolean provideFullMandateData) { + this.provideFullMandateData = provideFullMandateData; + } + + public boolean isUseCondition() { + return useCondition; + } + + public void setUseCondition(boolean useCondition) { + this.useCondition = useCondition; + } + + public int getConditionLength() { + return conditionLength; + } + + public void setConditionLength(int conditionLength) { + this.conditionLength = conditionLength; + } + + /** + * @return the isActive + */ + public boolean isActive() { + return isActive; + } + + /** + * @param isActive the isActive to set + */ + public void setActive(boolean isActive) { + this.isActive = isActive; + } + + /** + * @return the provideAllErrors + */ + public Boolean getProvideAllErrors() { + return provideAllErrors; + } + + /** + * @param provideAllErrors the provideAllErrors to set + */ + public void setProvideAllErrors(Boolean provideAllErrors) { + this.provideAllErrors = provideAllErrors; + } + } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java index 1baefe4b8..ed0f1c278 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASSOConfig.java @@ -32,88 +32,104 @@ import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplicati import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.validation.oa.OASSOConfigValidation; -public class OASSOConfig implements IOnlineApplicationData{ - - private boolean useSSO = false; - private boolean showAuthDataFrame = true; - private String singleLogOutURL = null; - - public OASSOConfig() { - - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OASingleSignOn"; - } - - public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); - if (authdata != null) { - OASSO ssoconfig = authdata.getOASSO(); - if(ssoconfig != null) { - useSSO = ssoconfig.isUseSSO(); - showAuthDataFrame = ssoconfig.isAuthDataFrame(); - singleLogOutURL = ssoconfig.getSingleLogOutURL(); - } - } - - return null; - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, - HttpServletRequest request) { - return new OASSOConfigValidation().validate(this, authUser.isAdmin(), request); - } - - public String store(OnlineApplication dboa, AuthenticatedUser authUser, HttpServletRequest request) { - - AuthComponentOA authoa = dboa.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dboa.setAuthComponentOA(authoa); - } - - OASSO sso = authoa.getOASSO(); - if (sso == null) { - sso = new OASSO(); - authoa.setOASSO(sso); - sso.setAuthDataFrame(true); - } - sso.setUseSSO(this.useSSO); - - if (authUser.isAdmin()) - sso.setAuthDataFrame(this.showAuthDataFrame); - - sso.setSingleLogOutURL(this.singleLogOutURL); - - return null; - } - - public boolean isUseSSO() { - return useSSO; - } - public void setUseSSO(boolean useSSO) { - this.useSSO = useSSO; - } - public boolean isShowAuthDataFrame() { - return showAuthDataFrame; - } - public void setShowAuthDataFrame(boolean showAuthDataFrame) { - this.showAuthDataFrame = showAuthDataFrame; - } - public String getSingleLogOutURL() { - return singleLogOutURL; - } - public void setSingleLogOutURL(String singleLogOutURL) { - this.singleLogOutURL = singleLogOutURL; - } +public class OASSOConfig implements IOnlineApplicationData { + + private boolean useSSO = false; + private boolean showAuthDataFrame = true; + private String singleLogOutURL = null; + + public OASSOConfig() { + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OASingleSignOn"; + } + + @Override + public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, + HttpServletRequest request) { + final AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); + if (authdata != null) { + final OASSO ssoconfig = authdata.getOASSO(); + if (ssoconfig != null) { + useSSO = ssoconfig.isUseSSO(); + showAuthDataFrame = ssoconfig.isAuthDataFrame(); + singleLogOutURL = ssoconfig.getSingleLogOutURL(); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, + HttpServletRequest request) { + return new OASSOConfigValidation().validate(this, authUser.isAdmin(), request); + } + + @Override + public String store(OnlineApplication dboa, AuthenticatedUser authUser, HttpServletRequest request) { + + AuthComponentOA authoa = dboa.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dboa.setAuthComponentOA(authoa); + } + + OASSO sso = authoa.getOASSO(); + if (sso == null) { + sso = new OASSO(); + authoa.setOASSO(sso); + sso.setAuthDataFrame(true); + } + sso.setUseSSO(this.useSSO); + + if (authUser.isAdmin()) { + sso.setAuthDataFrame(this.showAuthDataFrame); + } + + sso.setSingleLogOutURL(this.singleLogOutURL); + + return null; + } + + public boolean isUseSSO() { + return useSSO; + } + + public void setUseSSO(boolean useSSO) { + this.useSSO = useSSO; + } + + public boolean isShowAuthDataFrame() { + return showAuthDataFrame; + } + + public void setShowAuthDataFrame(boolean showAuthDataFrame) { + this.showAuthDataFrame = showAuthDataFrame; + } + + public String getSingleLogOutURL() { + return singleLogOutURL; + } + + public void setSingleLogOutURL(String singleLogOutURL) { + this.singleLogOutURL = singleLogOutURL; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java index fb096a2a0..82ef9d1d1 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OASTORKConfig.java @@ -27,8 +27,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.commons.MOAIDConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AttributeProviderPlugin; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentOA; @@ -44,306 +42,331 @@ import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import at.gv.egovernment.moa.id.configuration.validation.oa.OASTORKConfigValidation; import at.gv.egovernment.moa.util.MiscUtil; //import at.gv.egovernment.moa.id.protocols.stork2.AttributeProviderFactory; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class OASTORKConfig implements IOnlineApplicationData { + + private boolean isStorkLogonEnabled = false; + private String qaa; + + private List<AttributeHelper> attributes = null; + + /* + * VIDP settings below + */ + private boolean vidpEnabled = false; + private List<AttributeProviderPlugin> attributeProviderPlugins = new ArrayList<>(); + private boolean requireConsent = false; + private final List<String> citizenCountries; + private List<String> enabledCitizenCountries; + + private MOAIDConfiguration dbconfig = null; + + public OASTORKConfig() { + // fetch available citizen countries + citizenCountries = new ArrayList<>(); + try { + dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); + + for (final CPEPS current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() + .getCPEPS()) { + citizenCountries.add(current.getCountryCode()); + } + + } catch (final NullPointerException e) { + + } catch (final ConfigurationException e) { + log.error("MOA-ID-Configuration initialization FAILED.", e); + + } + + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OASTORK2"; + } + + /** + * Parses the OA config for stork entities. + * + * @param dbOAConfig the db oa config + */ + @Override + public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, + HttpServletRequest request) { + final AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); + if (authdata != null) { + final OASTORK config = authdata.getOASTORK(); + if (config != null) { + setStorkLogonEnabled(config.isStorkLogonEnabled()); + + try { + setQaa(config.geteIDAS_LOA()); + } catch (final NullPointerException e) { + // if there is no configuration available for the OA, get the default qaa level + try { + setQaa(dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() + .getGeneral_eIDAS_LOA()); + + } catch (final NullPointerException e1) { + setQaa(MOAIDConstants.eIDAS_LOA_HIGH); + + } + } + + enabledCitizenCountries = new ArrayList<>(); + if (config.getCPEPS() != null) { + for (final CPEPS current : config.getCPEPS()) { + enabledCitizenCountries.add(current.getCountryCode()); + } + } -public class OASTORKConfig implements IOnlineApplicationData{ - - private static final Logger log = Logger.getLogger(OASTORKConfig.class); - - private boolean isStorkLogonEnabled = false; - private String qaa; - - private List<AttributeHelper> attributes = null; - - /* - * VIDP settings below - */ - private boolean vidpEnabled = false; - private List<AttributeProviderPlugin> attributeProviderPlugins = new ArrayList<AttributeProviderPlugin>(); - private boolean requireConsent = false; - private List<String> citizenCountries; - private List<String> enabledCitizenCountries; - - private MOAIDConfiguration dbconfig = null; - - public OASTORKConfig() { - // fetch available citizen countries - citizenCountries = new ArrayList<String>(); - try { - dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); - - - for(CPEPS current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS()) { - citizenCountries.add(current.getCountryCode()); - } - - }catch (NullPointerException e) { - - } catch (ConfigurationException e) { - log.error("MOA-ID-Configuration initialization FAILED.", e); - - } - - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OASTORK2"; - } - - /** - * Parses the OA config for stork entities. - * - * @param dbOAConfig - * the db oa config - */ - public List<String> parse(OnlineApplication dbOAConfig, AuthenticatedUser authUser, HttpServletRequest request) { - AuthComponentOA authdata = dbOAConfig.getAuthComponentOA(); - if (authdata != null) { - OASTORK config = authdata.getOASTORK(); - if(config != null) { - setStorkLogonEnabled(config.isStorkLogonEnabled()); - - try { - setQaa(config.geteIDAS_LOA()); - } catch(NullPointerException e) { - // if there is no configuration available for the OA, get the default qaa level - try { - setQaa(dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getGeneral_eIDAS_LOA()); - - } catch (NullPointerException e1) { - setQaa(MOAIDConstants.eIDAS_LOA_HIGH); - - } - } - - - enabledCitizenCountries = new ArrayList<String>(); - if (config.getCPEPS() != null) { - for(CPEPS current : config.getCPEPS()) - enabledCitizenCountries.add(current.getCountryCode()); - } - - // prepare attribute helper list - attributes = new ArrayList<AttributeHelper>(); - try { - try { - for(StorkAttribute current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getAttributes()) { - AttributeHelper tmp = null; - - if (config.getOAAttributes() != null) { - for(OAStorkAttribute sepp : config.getOAAttributes()) - if(sepp.getName() != null && sepp.getName().equals(current.getName())) - tmp = new AttributeHelper(sepp); - } - - if(null == tmp) - tmp = new AttributeHelper(current); - - attributes.add(tmp); - } - - } catch (NullPointerException ex) { - - } - - // fetch vidp config - if (config.isVidpEnabled() != null) - setVidpEnabled(config.isVidpEnabled()); - else - setVidpEnabled(false); - - if (config.isRequireConsent() != null) - setRequireConsent(config.isRequireConsent()); - else - setRequireConsent(false); - - attributeProviderPlugins = config.getAttributeProviders(); - // - if no attribute providers are configured, add a dummy - // TODO this is a dirty hack since we have to have one entry to - // clone from in the web form. Happens when time is short. - // Sorry. - if (attributeProviderPlugins == null || attributeProviderPlugins.isEmpty()) - attributeProviderPlugins.add(new AttributeProviderPlugin()); - } catch (NullPointerException ex) { - log.error("Nullpointerexception encountered in Configurationinterface", ex); + // prepare attribute helper list + attributes = new ArrayList<>(); + try { + try { + for (final StorkAttribute current : dbconfig.getAuthComponentGeneral().getForeignIdentities() + .getSTORK().getAttributes()) { + AttributeHelper tmp = null; + + if (config.getOAAttributes() != null) { + for (final OAStorkAttribute sepp : config.getOAAttributes()) { + if (sepp.getName() != null && sepp.getName().equals(current.getName())) { + tmp = new AttributeHelper(sepp); + } } - } - } - - return null; - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, - HttpServletRequest request) { - return new OASTORKConfigValidation().validate(this, request); - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); + } + + if (null == tmp) { + tmp = new AttributeHelper(current); + } + + attributes.add(tmp); + } + + } catch (final NullPointerException ex) { + + } + + // fetch vidp config + if (config.isVidpEnabled() != null) { + setVidpEnabled(config.isVidpEnabled()); + } else { + setVidpEnabled(false); + } + + if (config.isRequireConsent() != null) { + setRequireConsent(config.isRequireConsent()); + } else { + setRequireConsent(false); + } + + attributeProviderPlugins = config.getAttributeProviders(); + // - if no attribute providers are configured, add a dummy + // TODO this is a dirty hack since we have to have one entry to + // clone from in the web form. Happens when time is short. + // Sorry. + if (attributeProviderPlugins == null || attributeProviderPlugins.isEmpty()) { + attributeProviderPlugins.add(new AttributeProviderPlugin()); + } + } catch (final NullPointerException ex) { + log.error("Nullpointerexception encountered in Configurationinterface", ex); } - - // fetch stork configuration from database model - OASTORK stork = authoa.getOASTORK(); - if (stork == null) { - // if there is none, create a new one with default values. - stork = new OASTORK(); - authoa.setOASTORK(stork); - stork.setStorkLogonEnabled(false); + } + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, AuthenticatedUser authUser, + HttpServletRequest request) { + return new OASTORKConfigValidation().validate(this, request); + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } + + // fetch stork configuration from database model + OASTORK stork = authoa.getOASTORK(); + if (stork == null) { + // if there is none, create a new one with default values. + stork = new OASTORK(); + authoa.setOASTORK(stork); + stork.setStorkLogonEnabled(false); + } + // transfer the incoming data to the database model + stork.setStorkLogonEnabled(isStorkLogonEnabled()); + stork.seteIDAS_LOA(getQaa()); + stork.setOAAttributes(getAttributes()); + stork.setVidpEnabled(isVidpEnabled()); + stork.setRequireConsent(isRequireConsent()); + stork.setAttributeProviders(getAttributeProviderPlugins()); + stork.setCPEPS(getEnabledCPEPS()); + + return null; + + } + + public boolean isStorkLogonEnabled() { + return isStorkLogonEnabled; + } + + public void setStorkLogonEnabled(boolean enabled) { + this.isStorkLogonEnabled = enabled; + } + + public String getQaa() { + return qaa; + } + + public void setQaa(String qaa) { + this.qaa = qaa; + } + + public List<OAStorkAttribute> getAttributes() { + final List<OAStorkAttribute> result = new ArrayList<>(); + + if (null == getHelperAttributes()) { + return result; + } + + for (final AttributeHelper current : getHelperAttributes()) { + List<StorkAttribute> generalConfStorkAttr = null; + try { + generalConfStorkAttr = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() + .getAttributes(); + + } catch (final NullPointerException e) { + log.trace("No STORK attributes in 'General Configuration'"); + + } + + if (generalConfStorkAttr != null) { + for (final StorkAttribute currentAttribute : generalConfStorkAttr) { + if (MiscUtil.isNotEmpty(currentAttribute.getName()) && + currentAttribute.getName().equals(current.getName())) { + if (current.isUsed() || currentAttribute.isMandatory()) { + final OAStorkAttribute tmp = new OAStorkAttribute(); + tmp.setName(current.getName()); + tmp.setMandatory(current.isMandatory()); + result.add(tmp); + + } + break; + } } - // transfer the incoming data to the database model - stork.setStorkLogonEnabled(isStorkLogonEnabled()); - stork.seteIDAS_LOA(getQaa()); - stork.setOAAttributes(getAttributes()); - stork.setVidpEnabled(isVidpEnabled()); - stork.setRequireConsent(isRequireConsent()); - stork.setAttributeProviders(getAttributeProviderPlugins()); - stork.setCPEPS(getEnabledCPEPS()); - - return null; - - } - - public boolean isStorkLogonEnabled() { - return isStorkLogonEnabled; - } - - public void setStorkLogonEnabled(boolean enabled) { - this.isStorkLogonEnabled = enabled; - } - - public String getQaa() { - return qaa; - } - - public void setQaa(String qaa) { - this.qaa = qaa; - } - - public List<OAStorkAttribute> getAttributes() { - List<OAStorkAttribute> result = new ArrayList<OAStorkAttribute>(); - - if(null == getHelperAttributes()) - return result; - - for(AttributeHelper current : getHelperAttributes()) { - List<StorkAttribute> generalConfStorkAttr = null; - try { - generalConfStorkAttr = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getAttributes(); - - } catch (NullPointerException e) { - log.trace("No STORK attributes in 'General Configuration'"); - - } - - if (generalConfStorkAttr != null) { - for(StorkAttribute currentAttribute : generalConfStorkAttr) - if(MiscUtil.isNotEmpty(currentAttribute.getName()) && - currentAttribute.getName().equals(current.getName())) { - if(current.isUsed() || currentAttribute.isMandatory()) { - OAStorkAttribute tmp = new OAStorkAttribute(); - tmp.setName(current.getName()); - tmp.setMandatory(current.isMandatory()); - result.add(tmp); - - } - break; - } - } - } - - return result; - } - - public List<AttributeHelper> getHelperAttributes() { - return attributes; - } - - public void setHelperAttributes(List<AttributeHelper> attributes) { - this.attributes = attributes; - } - - public List<String> getAvailableCitizenCountries() { - return citizenCountries; - } - - - public List<String> getAllowedLoALevels() { - return MOAIDConstants.ALLOWED_eIDAS_LOA; - } - - public List<String> getEnabledCitizenCountries() { - return enabledCitizenCountries; - } - - public void setEnabledCitizenCountries(List<String> update) { - enabledCitizenCountries = update; - } - - public List<CPEPS> getEnabledCPEPS() { - if (enabledCitizenCountries != null) { - List<CPEPS> result = new ArrayList<CPEPS>(); - - try { - for(CPEPS current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS()) { - if(enabledCitizenCountries.contains(current.getCountryCode())) - result.add(current); - } - - } catch (NullPointerException e){ - - } - return result; - } - - return null; - - } - - public List<String> getAvailableAttributeProviderPlugins() { - //TODO: remove in final version - - return new ArrayList<String>(); - //return AttributeProviderFactory.getAvailablePlugins(); - } - - public List<AttributeProviderPlugin> getAttributeProviderPlugins() { - return attributeProviderPlugins; - } - - public void setAttributeProviderPlugins(List<AttributeProviderPlugin> update) { - attributeProviderPlugins = update; - } - - public boolean isVidpEnabled() { - return vidpEnabled; - } - - public void setVidpEnabled(boolean update) { - vidpEnabled = update; - } - - public boolean isRequireConsent() { - return requireConsent; - } - - public void setRequireConsent(boolean update) { - requireConsent = update; - } + } + } + + return result; + } + + public List<AttributeHelper> getHelperAttributes() { + return attributes; + } + + public void setHelperAttributes(List<AttributeHelper> attributes) { + this.attributes = attributes; + } + + public List<String> getAvailableCitizenCountries() { + return citizenCountries; + } + + public List<String> getAllowedLoALevels() { + return MOAIDConstants.ALLOWED_eIDAS_LOA; + } + + public List<String> getEnabledCitizenCountries() { + return enabledCitizenCountries; + } + + public void setEnabledCitizenCountries(List<String> update) { + enabledCitizenCountries = update; + } + + public List<CPEPS> getEnabledCPEPS() { + if (enabledCitizenCountries != null) { + final List<CPEPS> result = new ArrayList<>(); + + try { + for (final CPEPS current : dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() + .getCPEPS()) { + if (enabledCitizenCountries.contains(current.getCountryCode())) { + result.add(current); + } + } + + } catch (final NullPointerException e) { + + } + return result; + } + + return null; + + } + + public List<String> getAvailableAttributeProviderPlugins() { + // TODO: remove in final version + + return new ArrayList<>(); + // return AttributeProviderFactory.getAvailablePlugins(); + } + + public List<AttributeProviderPlugin> getAttributeProviderPlugins() { + return attributeProviderPlugins; + } + + public void setAttributeProviderPlugins(List<AttributeProviderPlugin> update) { + attributeProviderPlugins = update; + } + + public boolean isVidpEnabled() { + return vidpEnabled; + } + + public void setVidpEnabled(boolean update) { + vidpEnabled = update; + } + + public boolean isRequireConsent() { + return requireConsent; + } + + public void setRequireConsent(boolean update) { + requireConsent = update; + } } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java index 84516c73f..be1b937f0 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/OATargetConfiguration.java @@ -43,464 +43,473 @@ import at.gv.egovernment.moa.util.MiscUtil; */ public class OATargetConfiguration implements IOnlineApplicationData { - private boolean deaktivededBusinessService = false; - - private boolean subTargetSet = false; - - private String target = null; - private String target_subsector = null; - private String target_admin = null; - private static List<String> targetList = null; - private String targetFriendlyName = null; - private boolean isAdminTarget = false; - - private String identificationNumber = null; - private String identificationType = null; - private static List<String> identificationTypeList = null; - - private String foreignbPKTargets = null; - private String additionalbPKTargets = null; - private boolean eidDemoActive = false; + private boolean deaktivededBusinessService = false; + + private boolean subTargetSet = false; + + private String target = null; + private String target_subsector = null; + private String target_admin = null; + private static List<String> targetList = null; + private String targetFriendlyName = null; + private boolean isAdminTarget = false; + + private String identificationNumber = null; + private String identificationType = null; + private static List<String> identificationTypeList = null; + + private String foreignbPKTargets = null; + private String additionalbPKTargets = null; + private boolean eidDemoActive = false; private boolean eidProxyActive = false; - - public OATargetConfiguration() { - targetList = TargetValidator.getListOfTargets(); - target = ""; - - identificationTypeList = Arrays.asList( - Constants.IDENIFICATIONTYPE_FN, - Constants.IDENIFICATIONTYPE_ZVR, - Constants.IDENIFICATIONTYPE_ERSB, - Constants.IDENIFICATIONTYPE_STORK, - Constants.IDENIFICATIONTYPE_EIDAS); - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "OATargetConfig"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, - AuthenticatedUser authUser, HttpServletRequest request) { - String target_full = dbOA.getTarget(); - if (MiscUtil.isNotEmpty(target_full)) { - if (TargetValidator.isValidTarget(target_full)) { - target = target_full; - - } else { - String[] target_split = target_full.split("-"); - - if (TargetValidator.isValidTarget(target_split[0])) { - target = target_split[0]; - if (target_split.length > 1) { - target_subsector = target_split[1]; - subTargetSet = true; - } - - } else { - target = ""; - target_subsector = null; - target_admin = target_full; - isAdminTarget = true; - } - } - targetFriendlyName = dbOA.getTargetFriendlyName(); - } - - AuthComponentOA oaauth = dbOA.getAuthComponentOA(); - if (oaauth != null) { - - IdentificationNumber idnumber = oaauth.getIdentificationNumber(); - if (idnumber != null) { - String number = idnumber.getValue(); - if (MiscUtil.isNotEmpty(number)) { - String[] split = number.split("\\+"); - - if (Constants.PREFIX_WPBK.startsWith(split[0]) && split.length >= 2) { - identificationType = split[1]; - identificationNumber = split[2]; - - } else if (Constants.PREFIX_EIDAS.startsWith(split[0]) && split.length >= 2) { - //identificationType = split[1]; // setting at as iden category ? - identificationType = Constants.IDENIFICATIONTYPE_EIDAS; - identificationNumber = split[1] + "+" + split[2]; // setting sp country as ident type -> sp ident - - } else if (Constants.PREFIX_STORK.startsWith(split[0]) && split.length >= 2) { - //identificationType = split[1]; // setting at as iden category ? - identificationType = Constants.IDENIFICATIONTYPE_STORK; - identificationNumber = split[2]; // setting sp country as ident type -> sp ident - } - } - - if (authUser.isOnlyBusinessService()) { - deaktivededBusinessService = authUser.isOnlyBusinessService(); - - identificationType = authUser.getBusinessServiceType(); - identificationNumber = authUser.getBusinessServiceNumber(); - - } - - } - } - - - //parse foreign bPK sector list - if (dbOA.getForeignbPKTargetList() != null) { - if (KeyValueUtils.isCSVValueString(dbOA.getForeignbPKTargetList())) - foreignbPKTargets = KeyValueUtils.normalizeCSVValueString(dbOA.getForeignbPKTargetList()); - - else { - if (dbOA.getForeignbPKTargetList().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - foreignbPKTargets = dbOA.getForeignbPKTargetList().substring(0, - dbOA.getForeignbPKTargetList().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - foreignbPKTargets = dbOA.getForeignbPKTargetList(); - - } - } - - //parse additional bPK sector list - if (dbOA.getAdditionalbPKTargetList() != null) { - if (KeyValueUtils.isCSVValueString(dbOA.getAdditionalbPKTargetList())) - additionalbPKTargets = KeyValueUtils.normalizeCSVValueString(dbOA.getAdditionalbPKTargetList()); - - else { - if (dbOA.getAdditionalbPKTargetList().contains(KeyValueUtils.CSV_DELIMITER)) { - //remove trailing comma if exist - additionalbPKTargets = dbOA.getAdditionalbPKTargetList().substring(0, - dbOA.getAdditionalbPKTargetList().indexOf(KeyValueUtils.CSV_DELIMITER)); - - } else - additionalbPKTargets = dbOA.getAdditionalbPKTargetList(); - - } - } - - //parse 'Austrian eID mode' flag - eidDemoActive = dbOA.getIseIDDemoModeActive(); - eidProxyActive = dbOA.getIseIDProxyModeActive(); - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - - AuthComponentOA authoa = dbOA.getAuthComponentOA(); - if (authoa == null) { - authoa = new AuthComponentOA(); - dbOA.setAuthComponentOA(authoa); + + public OATargetConfiguration() { + targetList = TargetValidator.getListOfTargets(); + target = ""; + + identificationTypeList = Arrays.asList( + Constants.IDENIFICATIONTYPE_FN, + Constants.IDENIFICATIONTYPE_ZVR, + Constants.IDENIFICATIONTYPE_ERSB, + Constants.IDENIFICATIONTYPE_STORK, + Constants.IDENIFICATIONTYPE_EIDAS); + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "OATargetConfig"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + final String target_full = dbOA.getTarget(); + if (MiscUtil.isNotEmpty(target_full)) { + if (TargetValidator.isValidTarget(target_full)) { + target = target_full; + + } else { + final String[] target_split = target_full.split("-"); + + if (TargetValidator.isValidTarget(target_split[0])) { + target = target_split[0]; + if (target_split.length > 1) { + target_subsector = target_split[1]; + subTargetSet = true; + } + + } else { + target = ""; + target_subsector = null; + target_admin = target_full; + isAdminTarget = true; + } + } + targetFriendlyName = dbOA.getTargetFriendlyName(); + } + + final AuthComponentOA oaauth = dbOA.getAuthComponentOA(); + if (oaauth != null) { + + final IdentificationNumber idnumber = oaauth.getIdentificationNumber(); + if (idnumber != null) { + final String number = idnumber.getValue(); + if (MiscUtil.isNotEmpty(number)) { + final String[] split = number.split("\\+"); + + if (Constants.PREFIX_WPBK.startsWith(split[0]) && split.length >= 2) { + identificationType = split[1]; + identificationNumber = split[2]; + + } else if (Constants.PREFIX_EIDAS.startsWith(split[0]) && split.length >= 2) { + // identificationType = split[1]; // setting at as iden category ? + identificationType = Constants.IDENIFICATIONTYPE_EIDAS; + identificationNumber = split[1] + "+" + split[2]; // setting sp country as ident type -> sp ident + + } else if (Constants.PREFIX_STORK.startsWith(split[0]) && split.length >= 2) { + // identificationType = split[1]; // setting at as iden category ? + identificationType = Constants.IDENIFICATIONTYPE_STORK; + identificationNumber = split[2]; // setting sp country as ident type -> sp ident + } } - - if (isBusinessService(dbOA) || authUser.isOnlyBusinessService()) { - - dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); - - String num = null; - if (authUser.isOnlyBusinessService()) { - deaktivededBusinessService = authUser.isOnlyBusinessService(); - num = authUser.getBusinessServiceType() + authUser.getBusinessServiceNumber(); - - } else { - - num = getIdentificationNumber().replaceAll(" ", ""); - if (num.startsWith(Constants.IDENIFICATIONTYPE_FN)) { - num = num.substring(Constants.IDENIFICATIONTYPE_FN.length()); - - num = at.gv.egovernment.moa.util.StringUtils.deleteLeadingZeros(num); - - /*Fixme: - * Company numbers had to be padded with '0' on left site - * But this bugfix can not be activated, because this would - * change all bPKs for company numbers. - * - * Change this in case of new bPK generation algorithms - */ - // num = StringUtils.leftPad(num, 7, '0'); - } - - if (num.startsWith(Constants.IDENIFICATIONTYPE_ZVR)) - num = num.substring(Constants.IDENIFICATIONTYPE_ZVR.length()); - - if (num.startsWith(Constants.IDENIFICATIONTYPE_ERSB)) - num = num.substring(Constants.IDENIFICATIONTYPE_ERSB.length()); - } - - IdentificationNumber idnumber = authoa.getIdentificationNumber(); - if (idnumber == null) - idnumber = new IdentificationNumber(); - - if (getIdentificationType().equals(Constants.IDENIFICATIONTYPE_EIDAS)) { - idnumber.setValue(Constants.PREFIX_EIDAS + num); - idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); - - } else if (getIdentificationType().equals(Constants.IDENIFICATIONTYPE_STORK)) { - idnumber.setValue(Constants.PREFIX_STORK + "AT" + "+" + num); - idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); - } else { - idnumber.setValue(Constants.PREFIX_WPBK + getIdentificationType() + "+" + num); - idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); - } - - authoa.setIdentificationNumber(idnumber); + + if (authUser.isOnlyBusinessService()) { + deaktivededBusinessService = authUser.isOnlyBusinessService(); + + identificationType = authUser.getBusinessServiceType(); + identificationNumber = authUser.getBusinessServiceNumber(); + + } + + } + } + + // parse foreign bPK sector list + if (dbOA.getForeignbPKTargetList() != null) { + if (KeyValueUtils.isCSVValueString(dbOA.getForeignbPKTargetList())) { + foreignbPKTargets = KeyValueUtils.normalizeCSVValueString(dbOA.getForeignbPKTargetList()); + } else { + if (dbOA.getForeignbPKTargetList().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + foreignbPKTargets = dbOA.getForeignbPKTargetList().substring(0, + dbOA.getForeignbPKTargetList().indexOf(KeyValueUtils.CSV_DELIMITER)); } else { - dbOA.setType(null); + foreignbPKTargets = dbOA.getForeignbPKTargetList(); + } + + } + } - if (authUser.isAdmin()) { - if (MiscUtil.isNotEmpty(getTarget_admin()) && isAdminTarget()) { - dbOA.setTarget(getTarget_admin()); - dbOA.setTargetFriendlyName(getTargetFriendlyName()); + // parse additional bPK sector list + if (dbOA.getAdditionalbPKTargetList() != null) { + if (KeyValueUtils.isCSVValueString(dbOA.getAdditionalbPKTargetList())) { + additionalbPKTargets = KeyValueUtils.normalizeCSVValueString(dbOA.getAdditionalbPKTargetList()); + } else { + if (dbOA.getAdditionalbPKTargetList().contains(KeyValueUtils.CSV_DELIMITER)) { + // remove trailing comma if exist + additionalbPKTargets = dbOA.getAdditionalbPKTargetList().substring(0, + dbOA.getAdditionalbPKTargetList().indexOf(KeyValueUtils.CSV_DELIMITER)); - } else { + } else { + additionalbPKTargets = dbOA.getAdditionalbPKTargetList(); + } - String target = getTarget(); + } + } - if (MiscUtil.isNotEmpty(getTarget_subsector()) && subTargetSet) - dbOA.setTarget(target + "-" + getTarget_subsector()); - else - dbOA.setTarget(target); + // parse 'Austrian eID mode' flag + eidDemoActive = dbOA.getIseIDDemoModeActive(); + eidProxyActive = dbOA.getIseIDProxyModeActive(); + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + AuthComponentOA authoa = dbOA.getAuthComponentOA(); + if (authoa == null) { + authoa = new AuthComponentOA(); + dbOA.setAuthComponentOA(authoa); + } - String targetname = TargetValidator.getTargetFriendlyName(target); - if (MiscUtil.isNotEmpty(targetname)) dbOA.setTargetFriendlyName(targetname); + if (isBusinessService(dbOA) || authUser.isOnlyBusinessService()) { - } + dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); - } else { + String num = null; + if (authUser.isOnlyBusinessService()) { + deaktivededBusinessService = authUser.isOnlyBusinessService(); + num = authUser.getBusinessServiceType() + authUser.getBusinessServiceNumber(); - if (MiscUtil.isNotEmpty(getTarget())) { + } else { - String target = getTarget(); + num = getIdentificationNumber().replaceAll(" ", ""); + if (num.startsWith(Constants.IDENIFICATIONTYPE_FN)) { + num = num.substring(Constants.IDENIFICATIONTYPE_FN.length()); - if (MiscUtil.isNotEmpty(getTarget_subsector()) && subTargetSet) - dbOA.setTarget(target + "-" + getTarget_subsector()); + num = at.gv.egovernment.moa.util.StringUtils.deleteLeadingZeros(num); - else - dbOA.setTarget(target); + /* + * Fixme: Company numbers had to be padded with '0' on left site But this bugfix + * can not be activated, because this would change all bPKs for company numbers. + * + * Change this in case of new bPK generation algorithms + */ + // num = StringUtils.leftPad(num, 7, '0'); + } - String targetname = TargetValidator.getTargetFriendlyName(target); - if (MiscUtil.isNotEmpty(targetname)) dbOA.setTargetFriendlyName(targetname); + if (num.startsWith(Constants.IDENIFICATIONTYPE_ZVR)) { + num = num.substring(Constants.IDENIFICATIONTYPE_ZVR.length()); + } - } - } + if (num.startsWith(Constants.IDENIFICATIONTYPE_ERSB)) { + num = num.substring(Constants.IDENIFICATIONTYPE_ERSB.length()); } - - dbOA.setForeignbPKTargetList(getForeignbPKTargets()); - dbOA.setAdditionalbPKTargetList(getAdditionalbPKTargets()); - dbOA.setIseIDDemoModeActive(isEidDemoActive()); - dbOA.setIseIDProxyModeActive(isEidProxyActive()); - - return null; - } - - /** - * @return - */ - private boolean isBusinessService(OnlineApplication dbOA) { - if (dbOA.getType().equals(Constants.MOA_CONFIG_BUSINESSSERVICE)) - return true; - else - return false; - } - - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - return new OATargetConfigValidation().validate(this, authUser.isAdmin(), general, request); - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - public String getTargetFriendlyName() { - return targetFriendlyName; - } - - public void setTargetFriendlyName(String targetFriendlyName) { - this.targetFriendlyName = targetFriendlyName; - } - - public String getIdentificationNumber() { - return identificationNumber; - } - - public void setIdentificationNumber(String identificationNumber) { - this.identificationNumber = identificationNumber; - } - - public String getIdentificationType() { - return identificationType; - } - - public void setIdentificationType(String identificationType) { - this.identificationType = identificationType; - } - - /** - * @return the target_subsector - */ - public String getTarget_subsector() { - return target_subsector; - } - - - /** - * @param target_subsector the target_subsector to set - */ - public void setTarget_subsector(String target_subsector) { - this.target_subsector = target_subsector; - } - - - /** - * @return the target_admin - */ - public String getTarget_admin() { - return target_admin; - } - - - /** - * @param target_admin the target_admin to set - */ - public void setTarget_admin(String target_admin) { - this.target_admin = target_admin; - } - - - /** - * @return the targetList - */ - public List<String> getTargetList() { - return targetList; - } - - - /** - * @return the identificationTypeList - */ - public List<String> getIdentificationTypeList() { - return identificationTypeList; - } - - - /** - * @return the isAdminTarget - */ - public boolean isAdminTarget() { - return isAdminTarget; - } - - - /** - * @param isAdminTarget the isAdminTarget to set - */ - public void setAdminTarget(boolean isAdminTarget) { - this.isAdminTarget = isAdminTarget; - } - - /** - * @return the deaktivededBusinessService - */ - public boolean isDeaktivededBusinessService() { - return deaktivededBusinessService; - } + } + IdentificationNumber idnumber = authoa.getIdentificationNumber(); + if (idnumber == null) { + idnumber = new IdentificationNumber(); + } - /** - * @param deaktivededBusinessService the deaktivededBusinessService to set - */ - public void setDeaktivededBusinessService(boolean deaktivededBusinessService) { - this.deaktivededBusinessService = deaktivededBusinessService; - } + if (getIdentificationType().equals(Constants.IDENIFICATIONTYPE_EIDAS)) { + idnumber.setValue(Constants.PREFIX_EIDAS + num); + idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); + } else if (getIdentificationType().equals(Constants.IDENIFICATIONTYPE_STORK)) { + idnumber.setValue(Constants.PREFIX_STORK + "AT" + "+" + num); + idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); + } else { + idnumber.setValue(Constants.PREFIX_WPBK + getIdentificationType() + "+" + num); + idnumber.setType(Constants.BUSINESSSERVICENAMES.get(getIdentificationType())); + } - /** - * @return the subTargetSet - */ - public boolean isSubTargetSet() { - return subTargetSet; - } + authoa.setIdentificationNumber(idnumber); + } else { + dbOA.setType(null); - /** - * @param subTargetSet the subTargetSet to set - */ - public void setSubTargetSet(boolean subTargetSet) { - this.subTargetSet = subTargetSet; - } + if (authUser.isAdmin()) { + if (MiscUtil.isNotEmpty(getTarget_admin()) && isAdminTarget()) { + dbOA.setTarget(getTarget_admin()); + dbOA.setTargetFriendlyName(getTargetFriendlyName()); + } else { - public String getForeignbPKTargets() { - return foreignbPKTargets; - } + final String target = getTarget(); + if (MiscUtil.isNotEmpty(getTarget_subsector()) && subTargetSet) { + dbOA.setTarget(target + "-" + getTarget_subsector()); + } else { + dbOA.setTarget(target); + } - public void setForeignbPKTargets(String foreignbPKTargets) { - if (MiscUtil.isNotEmpty(foreignbPKTargets)) - this.foreignbPKTargets = - KeyValueUtils.removeAllNewlineFromString(foreignbPKTargets); - else - this.foreignbPKTargets = foreignbPKTargets; - } + final String targetname = TargetValidator.getTargetFriendlyName(target); + if (MiscUtil.isNotEmpty(targetname)) { + dbOA.setTargetFriendlyName(targetname); + } + } + + } else { + + if (MiscUtil.isNotEmpty(getTarget())) { - public String getAdditionalbPKTargets() { - return additionalbPKTargets; - } + final String target = getTarget(); + if (MiscUtil.isNotEmpty(getTarget_subsector()) && subTargetSet) { + dbOA.setTarget(target + "-" + getTarget_subsector()); + } else { + dbOA.setTarget(target); + } - public void setAdditionalbPKTargets(String additionalbPKTargets) { - if (MiscUtil.isNotEmpty(additionalbPKTargets)) - this.additionalbPKTargets = - KeyValueUtils.removeAllNewlineFromString(additionalbPKTargets); - else - this.additionalbPKTargets = additionalbPKTargets; + final String targetname = TargetValidator.getTargetFriendlyName(target); + if (MiscUtil.isNotEmpty(targetname)) { + dbOA.setTargetFriendlyName(targetname); + } - } + } + } + } + + dbOA.setForeignbPKTargetList(getForeignbPKTargets()); + dbOA.setAdditionalbPKTargetList(getAdditionalbPKTargets()); + dbOA.setIseIDDemoModeActive(isEidDemoActive()); + dbOA.setIseIDProxyModeActive(isEidProxyActive()); + + return null; + } + + /** + * @return + */ + private boolean isBusinessService(OnlineApplication dbOA) { + if (dbOA.getType().equals(Constants.MOA_CONFIG_BUSINESSSERVICE)) { + return true; + } else { + return false; + } + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + return new OATargetConfigValidation().validate(this, authUser.isAdmin(), general, request); + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public String getTargetFriendlyName() { + return targetFriendlyName; + } + + public void setTargetFriendlyName(String targetFriendlyName) { + this.targetFriendlyName = targetFriendlyName; + } + + public String getIdentificationNumber() { + return identificationNumber; + } + + public void setIdentificationNumber(String identificationNumber) { + this.identificationNumber = identificationNumber; + } + + public String getIdentificationType() { + return identificationType; + } + + public void setIdentificationType(String identificationType) { + this.identificationType = identificationType; + } + + /** + * @return the target_subsector + */ + public String getTarget_subsector() { + return target_subsector; + } + + /** + * @param target_subsector the target_subsector to set + */ + public void setTarget_subsector(String target_subsector) { + this.target_subsector = target_subsector; + } + + /** + * @return the target_admin + */ + public String getTarget_admin() { + return target_admin; + } + + /** + * @param target_admin the target_admin to set + */ + public void setTarget_admin(String target_admin) { + this.target_admin = target_admin; + } + + /** + * @return the targetList + */ + public List<String> getTargetList() { + return targetList; + } + + /** + * @return the identificationTypeList + */ + public List<String> getIdentificationTypeList() { + return identificationTypeList; + } + + /** + * @return the isAdminTarget + */ + public boolean isAdminTarget() { + return isAdminTarget; + } + + /** + * @param isAdminTarget the isAdminTarget to set + */ + public void setAdminTarget(boolean isAdminTarget) { + this.isAdminTarget = isAdminTarget; + } + + /** + * @return the deaktivededBusinessService + */ + public boolean isDeaktivededBusinessService() { + return deaktivededBusinessService; + } + + /** + * @param deaktivededBusinessService the deaktivededBusinessService to set + */ + public void setDeaktivededBusinessService(boolean deaktivededBusinessService) { + this.deaktivededBusinessService = deaktivededBusinessService; + } + + /** + * @return the subTargetSet + */ + public boolean isSubTargetSet() { + return subTargetSet; + } + + /** + * @param subTargetSet the subTargetSet to set + */ + public void setSubTargetSet(boolean subTargetSet) { + this.subTargetSet = subTargetSet; + } + + public String getForeignbPKTargets() { + return foreignbPKTargets; + } + + public void setForeignbPKTargets(String foreignbPKTargets) { + if (MiscUtil.isNotEmpty(foreignbPKTargets)) { + this.foreignbPKTargets = + KeyValueUtils.removeAllNewlineFromString(foreignbPKTargets); + } else { + this.foreignbPKTargets = foreignbPKTargets; + } + } + + public String getAdditionalbPKTargets() { + return additionalbPKTargets; + } + + public void setAdditionalbPKTargets(String additionalbPKTargets) { + if (MiscUtil.isNotEmpty(additionalbPKTargets)) { + this.additionalbPKTargets = + KeyValueUtils.removeAllNewlineFromString(additionalbPKTargets); + } else { + this.additionalbPKTargets = additionalbPKTargets; + } + } - public boolean isEidDemoActive() { - return eidDemoActive; - } + public boolean isEidDemoActive() { + return eidDemoActive; + } + public void setEidDemoActive(boolean eidDemoActive) { + this.eidDemoActive = eidDemoActive; + } - public void setEidDemoActive(boolean eidDemoActive) { - this.eidDemoActive = eidDemoActive; - } - - public boolean isEidProxyActive() { - return eidProxyActive; - } + public boolean isEidProxyActive() { + return eidProxyActive; + } + public void setEidProxyActive(boolean eidProxyActive) { + this.eidProxyActive = eidProxyActive; + } - public void setEidProxyActive(boolean eidProxyActive) { - this.eidProxyActive = eidProxyActive; - } - - - } diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java index e27c55c90..29598a679 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/oa/PVPGatewayInterfederationConfig.java @@ -27,110 +27,128 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.apache.log4j.Logger; - import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationGatewayType; -import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.InterfederationIDPType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineApplication; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.util.MiscUtil; +import lombok.extern.slf4j.Slf4j; /** * @author tlenz * */ +@Slf4j public class PVPGatewayInterfederationConfig implements IOnlineApplicationData { - private static final Logger log = Logger.getLogger(PVPGatewayInterfederationConfig.class); - - private String entityID = null; - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName() - */ - @Override - public String getName() { - return "PVPGatewayInterfederation"; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> parse(OnlineApplication dbOA, - AuthenticatedUser authUser, HttpServletRequest request) { - - InterfederationGatewayType gateway = dbOA.getInterfederationGateway(); - if (gateway != null) { - this.entityID = gateway.getForwardIDPIdentifier(); - - } - - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store(at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public String store(OnlineApplication dbOA, AuthenticatedUser authUser, - HttpServletRequest request) { - - if (authUser.isAdmin()) { - dbOA.setIsInterfederationGateway(true); - - InterfederationGatewayType gateway = dbOA.getInterfederationGateway(); - if (gateway == null) { - gateway = new InterfederationGatewayType(); - dbOA.setInterfederationGateway(gateway); - } - - gateway.setForwardIDPIdentifier(entityID); - } - - dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); - return null; - } - - /* (non-Javadoc) - * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, javax.servlet.http.HttpServletRequest) - */ - @Override - public List<String> validate(OAGeneralConfig general, - AuthenticatedUser authUser, HttpServletRequest request) { - - List<String> errors = new ArrayList<String>(); - - if (MiscUtil.isNotEmpty(entityID)) { - if (!ValidationHelper.validateURL(entityID)) { - log.info("PVP gateway EntityID is not valid"); - errors.add(LanguageHelper.getErrorString("validation.interfederation.gateway.entityID.valid", request)); - - } - - } else - errors.add(LanguageHelper.getErrorString("validation.interfederation.gateway.entityID.empty", request)); - - return errors; - } - - /** - * @return the entityID - */ - public String getEntityID() { - return entityID; - } - - /** - * @param entityID the entityID to set - */ - public void setEntityID(String entityID) { - this.entityID = entityID; - } - - - + private String entityID = null; + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#getName + * () + */ + @Override + public String getName() { + return "PVPGatewayInterfederation"; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#parse( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> parse(OnlineApplication dbOA, + AuthenticatedUser authUser, HttpServletRequest request) { + + final InterfederationGatewayType gateway = dbOA.getInterfederationGateway(); + if (gateway != null) { + this.entityID = gateway.getForwardIDPIdentifier(); + + } + + return null; + } + + /* + * (non-Javadoc) + * + * @see + * at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData#store( + * at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public String store(OnlineApplication dbOA, AuthenticatedUser authUser, + HttpServletRequest request) { + + if (authUser.isAdmin()) { + dbOA.setIsInterfederationGateway(true); + + InterfederationGatewayType gateway = dbOA.getInterfederationGateway(); + if (gateway == null) { + gateway = new InterfederationGatewayType(); + dbOA.setInterfederationGateway(gateway); + } + + gateway.setForwardIDPIdentifier(entityID); + } + + dbOA.setType(Constants.MOA_CONFIG_BUSINESSSERVICE); + return null; + } + + /* + * (non-Javadoc) + * + * @see at.gv.egovernment.moa.id.configuration.data.oa.IOnlineApplicationData# + * validate(at.gv.egovernment.moa.id.configuration.data.oa.OAGeneralConfig, + * at.gv.egovernment.moa.id.configuration.auth.AuthenticatedUser, + * javax.servlet.http.HttpServletRequest) + */ + @Override + public List<String> validate(OAGeneralConfig general, + AuthenticatedUser authUser, HttpServletRequest request) { + + final List<String> errors = new ArrayList<>(); + + if (MiscUtil.isNotEmpty(entityID)) { + if (!ValidationHelper.validateURL(entityID)) { + log.info("PVP gateway EntityID is not valid"); + errors.add(LanguageHelper.getErrorString("validation.interfederation.gateway.entityID.valid", + request)); + + } + + } else { + errors.add(LanguageHelper.getErrorString("validation.interfederation.gateway.entityID.empty", request)); + } + + return errors; + } + + /** + * @return the entityID + */ + public String getEntityID() { + return entityID; + } + + /** + * @param entityID the entityID to set + */ + public void setEntityID(String entityID) { + this.entityID = entityID; + } + } |