📄 editcardissuerconfigaction.java
字号:
/* * Copyright 2005-2007 WSO2, Inc. (http://wso2.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.wso2.solutions.identity.admin.ui.action;import java.io.File;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.wso2.solutions.identity.IdentityConstants;import org.wso2.solutions.identity.admin.ParameterAdmin;import org.wso2.solutions.identity.admin.ui.UIUtils;import org.wso2.solutions.identity.cards.CardIssuerConfig;import org.wso2.wsas.ServerConstants;public class EditCardissuerConfigAction extends ManagedAction { private static final long serialVersionUID = 0L; private String validPeriod = null; private String cardName = null; private String message = null; private boolean samlVersion10 = false; private boolean samlVersion11 = false; private boolean samlVersion20 = false; private File file = null; private String contentType = null; private String filename = null; private boolean useSymmBinding = false; private static Log log = LogFactory .getLog(EditCardissuerConfigAction.class); public String execute() throws Exception { ParameterAdmin admin = new ParameterAdmin(); validPeriod = admin.getParameterValue(IdentityConstants.PARAM_VALID_PERIOD); cardName = admin.getParameterValue(IdentityConstants.PARAM_CARD_NAME); String types = admin .getParameterValue(IdentityConstants.PARAM_SUPPORTED_TOKEN_TYPES); String[] arrTypes = types.split(","); for (int i = 0; i < arrTypes.length; i++) { if (arrTypes[i].equals(IdentityConstants.SAML10_URL)) { samlVersion10 = true; } else if (arrTypes[i].equals(IdentityConstants.SAML11_URL)) { samlVersion11 = true; } else if (arrTypes[i].equals(IdentityConstants.SAML20_URL)) { samlVersion20 = true; } } useSymmBinding = admin .getParameter(IdentityConstants.PARAM_USE_SYMM_BINDING) != null; return INPUT; } public String doUpdate() { String retString = SUCCESS; try { cardName = cardName.trim(); validPeriod = validPeriod.trim(); if (cardName.length() == 0 || validPeriod.length() == 0) { this.addErrorMessage(getText("required_feild_missing")); loadMessages(); return ERROR; } if (validPeriod == null) { this.addErrorMessage(getText("invalid_data_for", new String[] { "Valid Period" })); loadMessages(); return ERROR; } int period = 0; try { period = Integer.parseInt(validPeriod); } catch (NumberFormatException e) { this.addErrorMessage(getText("invalid_data_for", new String[] { "Valid Period" })); loadMessages(); return ERROR; } ParameterAdmin admin = new ParameterAdmin(); admin.createOrUpdatearameter(IdentityConstants.PARAM_VALID_PERIOD, validPeriod); admin.createOrUpdatearameter(IdentityConstants.PARAM_CARD_NAME, cardName); String tokValues = null; if (samlVersion10 == false && samlVersion11 == false) { this.addErrorMessage(getText("no_token_types_selected")); this.loadMessages(); return ERROR; } if (samlVersion10) { tokValues = IdentityConstants.SAML10_URL; } if (samlVersion11) { if (tokValues != null) { tokValues = tokValues + "," + IdentityConstants.SAML11_URL; } else { tokValues = IdentityConstants.SAML11_URL; } } if (samlVersion20) { if (tokValues != null) { tokValues = tokValues + "," + IdentityConstants.SAML20_URL; } else { tokValues = IdentityConstants.SAML20_URL; } } admin.createOrUpdatearameter( IdentityConstants.PARAM_SUPPORTED_TOKEN_TYPES, tokValues); if (useSymmBinding) { admin.createOrUpdatearameter( IdentityConstants.PARAM_USE_SYMM_BINDING, null); } else { admin.removeParam(IdentityConstants.PARAM_USE_SYMM_BINDING); } if (file.exists()) { String imagePath = System .getProperty(ServerConstants.WSO2WSAS_HOME) + IdentityConstants.CARD_IMAGE_PATH; File preFile = new File(imagePath); if (preFile.exists()) { if (preFile.delete() == false) { throw new Exception( getText("error_removing_existing_image")); } } UIUtils.createThumbnailImageFile(file, imagePath); } CardIssuerConfig.updateConfig(); } catch (Exception e) { String msg = getText("error_saving_card_issuer_info", new String[] { e.getMessage() }); log.error(msg, e); this.addActionError(msg + e.getMessage()); loadMessages(); retString = ERROR; } return retString; } public String getValidPeriod() { return validPeriod; } public void setValidPeriod(String validPeriod) { this.validPeriod = validPeriod; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public boolean isSamlVersion10() { return samlVersion10; } public void setSamlVersion10(boolean samlVersion10) { this.samlVersion10 = samlVersion10; } public boolean isSamlVersion11() { return samlVersion11; } public void setSamlVersion11(boolean samlVersion11) { this.samlVersion11 = samlVersion11; } public boolean isSamlVersion20() { return samlVersion20; } public void setSamlVersion1(boolean samlVersion20) { this.samlVersion20 = samlVersion20; } public String getCardName() { return cardName; } public void setCardName(String cardName) { this.cardName = cardName; } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public String getContentType() { return contentType; } public void setContentType(String contentType) { this.contentType = contentType; } public String getFilename() { return filename; } public void setFilename(String filename) { this.filename = filename; } public boolean isUseSymmBinding() { return useSymmBinding; } public void setUseSymmBinding(boolean useSymmBinding) { this.useSymmBinding = useSymmBinding; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -