001/* 002 * Copyright (c) 2009 The openGion Project. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 013 * either express or implied. See the License for the specific language 014 * governing permissions and limitations under the License. 015 */ 016package org.opengion.plugin.column; 017 018import org.opengion.hayabusa.db.AbstractEditor; 019import org.opengion.hayabusa.db.CellEditor; 020import org.opengion.hayabusa.db.DBColumn; 021import org.opengion.fukurou.util.XHTMLTag; 022import org.opengion.fukurou.security.HybsCryptography ; 023 024/** 025 * パスワード情報など、重要な情報の暗号化された情報を編集する場合に使用するクラスです。 026 * 027 * このクラスの暗号化は秘密キーによる可逆変換なので、変換方式と秘密キーが判ると 028 * 元に戻すことが可能です。それでも、何もしないよりははるかにましです。 029 * データベース等へ登録した暗号化されたデータを編集する場合に、使用します。 030 * 031 * @og.rev 4.0.0.0 (2005/08/31) 新規作成 032 * @og.group データ編集 033 * 034 * @version 4.0 035 * @author Kazuhiko Hasegawa 036 * @since JDK5.0, 037 */ 038public class Editor_CRYPT extends AbstractEditor { 039 //* このプログラムのVERSION文字列を設定します。 {@value} */ 040 private static final String VERSION = "4.0.0.0 (2005/08/31)" ; 041 042 private final HybsCryptography licence = new HybsCryptography() ; 043 044 /** 045 * デフォルトコンストラクター。 046 * このコンストラクターで、基本オブジェクトを作成します。 047 * 048 * @og.rev 3.1.1.1 (2003/04/03) 各オブジェクトから自分のインスタンスを返すファクトリメソッドを追加。 049 * 050 */ 051 public Editor_CRYPT() { 052 // 4.3.4.4 (2009/01/01) 053// super(); 054 } 055 056 /** 057 * コンストラクター。 058 * 059 * @param clm DBColumnオブジェクト 060 */ 061 private Editor_CRYPT( final DBColumn clm ) { 062 super( clm ); 063 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 064 } 065 066 /** 067 * 各オブジェクトから自分のインスタンスを返します。 068 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 069 * まかされます。 070 * 071 * @param clm DBColumnオブジェクト 072 * 073 * @return CellEditorオブジェクト 074 */ 075 public CellEditor newInstance( final DBColumn clm ) { 076 return new Editor_CRYPT( clm ); 077 } 078 079 /** 080 * データの編集用文字列を返します。 081 * 082 * @param value 入力値 083 * 084 * @return データの編集用文字列 085 */ 086 @Override 087 public String getValue( final String value ) { 088 return super.getValue( licence.decrypt( value ) ); 089 } 090 091 /** 092 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 093 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 094 * リクエスト情報を1つ毎のフィールドで処理できます。 095 * 096 * @param row 行番号 097 * @param value 入力値 098 * 099 * @return データ表示/編集用の文字列 100 */ 101 @Override 102 public String getValue( final int row,final String value ) { 103 return super.getValue( row,licence.decrypt( value ) ); 104 } 105}