001 /**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements. See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.geronimo.console.ca;
019
020 import java.io.IOException;
021
022 import javax.portlet.ActionRequest;
023 import javax.portlet.ActionResponse;
024 import javax.portlet.PortletException;
025 import javax.portlet.RenderRequest;
026 import javax.portlet.RenderResponse;
027
028 import org.apache.geronimo.console.MultiPageModel;
029
030 /**
031 * Handler for the Confirm Certificate Request screen.
032 *
033 * @version $Rev: 706640 $ $Date: 2008-10-21 14:44:05 +0000 (Tue, 21 Oct 2008) $
034 */
035 public class ConfirmCertReqHandler extends BaseCAHandler {
036 public ConfirmCertReqHandler() {
037 super(CONFIRM_CERT_REQ_MODE, "/WEB-INF/view/ca/confirmCertReq.jsp");
038 }
039
040 public String actionBeforeView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
041 String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "requestId"};
042 for(int i = 0; i < params.length; ++i) {
043 String value = request.getParameter(params[i]);
044 if(value != null) response.setRenderParameter(params[i], value);
045 }
046 return getMode();
047 }
048
049 public void renderView(RenderRequest request, RenderResponse response, MultiPageModel model) throws PortletException, IOException {
050 String[] params = {ERROR_MSG, INFO_MSG, "subject", "publickey", "requestId"};
051 for(int i = 0; i < params.length; ++i) {
052 String value = request.getParameter(params[i]);
053 if(value != null) request.setAttribute(params[i], value);
054 }
055 }
056
057 public String actionAfterView(ActionRequest request, ActionResponse response, MultiPageModel model) throws PortletException, IOException {
058 String requestId = request.getParameter("requestId");
059 String approve = request.getParameter("approve");
060 String reject = request.getParameter("reject");
061 if(approve != null) {
062 getCertificateRequestStore(request).setRequestVerified(requestId);
063 response.setRenderParameter(INFO_MSG, "Approved CSR. id = "+requestId);
064 } else if(reject != null) {
065 getCertificateRequestStore(request).deleteRequest(requestId);
066 response.setRenderParameter(INFO_MSG, "Rejected and deleted CSR. id = "+requestId);
067 }
068 return LIST_REQUESTS_VERIFY_MODE+BEFORE_ACTION;
069 }
070 }