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 053 /** 054 * コンストラクター。 055 * 056 * @param clm DBColumnオブジェクト 057 */ 058 private Editor_CRYPT( final DBColumn clm ) { 059 super( clm ); 060 tagBuffer.add( XHTMLTag.inputAttri( attributes ) ); 061 } 062 063 /** 064 * 各オブジェクトから自分のインスタンスを返します。 065 * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に 066 * まかされます。 067 * 068 * @param clm DBColumnオブジェクト 069 * 070 * @return CellEditorオブジェクト 071 */ 072 public CellEditor newInstance( final DBColumn clm ) { 073 return new Editor_CRYPT( clm ); 074 } 075 076 /** 077 * データの編集用文字列を返します。 078 * 079 * @param value 入力値 080 * 081 * @return データの編集用文字列 082 */ 083 @Override 084 public String getValue( final String value ) { 085 return super.getValue( licence.decrypt( value ) ); 086 } 087 088 /** 089 * name属性を変えた、データ表示/編集用のHTML文字列を作成します。 090 * テーブル上の name に 行番号を付加して、名前_行番号 で登録するキーを作成し, 091 * リクエスト情報を1つ毎のフィールドで処理できます。 092 * 093 * @param row 行番号 094 * @param value 入力値 095 * 096 * @return データ表示/編集用の文字列 097 */ 098 @Override 099 public String getValue( final int row,final String value ) { 100 return super.getValue( row,licence.decrypt( value ) ); 101 } 102}