All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jasypt.web.pbeconfig.WebPBEConfigHtmlUtils Maven / Gradle / Ivy

There is a newer version: 6.1.2
Show newest version
/*
 * =============================================================================
 * 
 *   Copyright (c) 2007-2010, The JASYPT team (http://www.jasypt.org)
 * 
 *   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.jasypt.web.pbeconfig;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.jasypt.encryption.pbe.config.WebPBEConfig;
import org.jasypt.exceptions.EncryptionInitializationException;

/**
 * 

* HTML creation class for internal use of {@link WebPBEConfigServlet} and * {@link WebPBEConfigFilter}. *

* * @since 1.3 * * @author Daniel Fernández * */ final class WebPBEConfigHtmlUtils { public static final String PASSWORD_SETTING_FLAG = "jasyptPwSetting"; public static final String VALIDATION_PREFIX = "jasyptVa"; public static final String PASSWORD_PREFIX = "jasyptPw"; public static final String PASSWORD_RETYPED_PREFIX = "jasyptRPw"; private static final String HTTPS_SCHEME = "https"; private WebPBEConfigHtmlUtils() { super(); } public static String createConfigurationDoneHtml() { final StringBuffer strBuff = new StringBuffer(); addHeader(strBuff); strBuff.append("

All Configuration Done

\n"); addFoot(strBuff); return strBuff.toString(); } public static String createInputFormHtml( final HttpServletRequest request, final boolean inputError) { final WebPBEConfigRegistry registry = WebPBEConfigRegistry.getInstance(); final List configs = registry.getConfigs(); final StringBuffer strBuff = new StringBuffer(); addHeader(strBuff); strBuff.append("

Please enter the PBE configuration parameters

\n"); if (!HTTPS_SCHEME.equals(request.getScheme().toLowerCase())) { strBuff.append("
WARNING: NOT IN SECURE MODE (HTTPS)
\n"); } if (inputError) { strBuff.append("
Validation error!
\n"); } strBuff.append("
\n"); strBuff.append("
\n"); final Iterator configsIter = configs.iterator(); int i = 0; while (configsIter.hasNext()) { WebPBEConfig config = (WebPBEConfig) configsIter.next(); if (!config.isComplete()) { throw new EncryptionInitializationException("Incomplete " + "WebPBEConfig object: all configs must specify " + "both a name and a validation word"); } strBuff.append("
\n"); strBuff.append(" " + config.getName() + "\n"); strBuff.append(" : \n"); strBuff.append("

\n"); strBuff.append(" : \n"); strBuff.append("

\n"); strBuff.append(" : \n"); strBuff.append("
\n"); i++; } strBuff.append("
\n"); strBuff.append("
\n"); strBuff.append(" \n"); strBuff.append(" \n"); strBuff.append("
\n"); strBuff.append("
\n"); addFoot(strBuff); return strBuff.toString(); } public static String createNotInitializedHtml() { final StringBuffer strBuff = new StringBuffer(); strBuff.append("\n"); strBuff.append(" \n"); strBuff.append(" Forbidden\n"); strBuff.append(" \n"); strBuff.append(" \n"); strBuff.append("

Access Forbidden

\n"); strBuff.append(" \n"); strBuff.append("\n"); return strBuff.toString(); } private static void addHeader(final StringBuffer strBuff) { strBuff.append("\n"); strBuff.append(" \n"); strBuff.append(" Web Password Based Encryption Configuration\n"); strBuff.append(" \n"); strBuff.append(" \n"); strBuff.append(" \n"); strBuff.append("
\n"); strBuff.append("

Web PBE Configuration

\n"); } private static void addFoot(final StringBuffer strBuff) { strBuff.append("
\n"); strBuff.append(" \n"); strBuff.append("\n"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy