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 */
016 package org.opengion.plugin.column;
017
018 import org.opengion.fukurou.security.HybsCryptography;
019 import org.opengion.fukurou.util.StringUtil;
020 import org.opengion.hayabusa.db.AbstractDBType;
021
022 /**
023 * パスワード情報などã€?‡�要なæƒ??のハッシュコーãƒ?MD5)を扱ã�?‚ºの、カラãƒ?±žæ?を定義しますã?
024 *
025 * パスワード情報などã€?‡�要なæƒ??のハッシュコードに、MD5 がありますã?こã?クラスはã€?
026 * MessageDigestにより、MD5 でハッシュしたæ–?—を作æ?しますã?
027 * 値としては、標準ã? X と同じ半角文字å?ã€?c < 0x20 || c > 0x7e 以外ã?でのみ
028 * 処ç�?�™ることがå?来ますã?
029 *
030 * タイプチェãƒ?‚¯として、以下ã?条件を判定しますã?
031 * ・æ–?—å?長は、Byte換算でのæ–?—数との比è¼?
032 * ・半角文字å?チェãƒ?‚¯ã€?c < 0x20 || c > 0x7e 以外ã?エラー
033 * ・æ–?—パラメータの 正規表現チェãƒ?‚¯
034 * ・クロスサイトスクリプティングチェãƒ?‚¯
035 *
036 * @og.group ãƒ??タ属æ?
037 *
038 * @version 4.0
039 * @author Kazuhiko Hasegawa
040 * @since JDK5.0,
041 */
042 public class DBType_MD5 extends AbstractDBType {
043 //* こã?プログラãƒ??VERSIONæ–?—å?を設定しますã? {@value} */
044 private static final String VERSION = "5.2.2.0 (2010/11/01)" ;
045
046 /**
047 * String引数のæ–?—å?を+1した文字å?を返しますã?
048 * ※ こã?クラスでは実è£?�•れてã�?�¾せんã€?
049 *
050 * @param value String引数のæ–?—å?
051 * @throws UnsupportedOperationException こã?クラスを実行すると、å¿?�š発生しますã?
052 *
053 * @return String引数のæ–?—å?を+1した文字å?
054 */
055 @Override
056 public String valueAdd( final String value ) {
057 String errMsg = "こã?メソãƒ?ƒ‰は、このクラスからは使用できませんã€?;
058 throw new UnsupportedOperationException( errMsg );
059 }
060
061 /**
062 * MessageDigestにより、MD5 でハッシュしたæ–?—を返しますã?
063 *
064 * MD5でã€?¼‘5Byteのバイトに変換されますが、ここでは、ã?イナス時には,
065 * 符号を反転させてã€?¼‘6é?数でæ–?—å?に変換してã�?�¾すã?
066 * よって、このメソãƒ?ƒ‰で変換したæ–?—でのみ突き合わせて正しいかどã�?�‹ã‚?
067 * 判断してくださいã€?
068 *
069 * @og.rev 3.3.3.0 (2003/07/09) 前後ã?スペã?スを取り除ã�?�¦おくã€?
070 * @og.rev 3.3.3.1 (2003/07/18) 後ろスペã?スを取り除くã?(StringUtil#rTrim)
071 * @og.rev 5.2.2.0 (2010/11/01) util.StringUtil から security.HybsCryptography へ移å‹?
072 *
073 * @param value (ä¸?ˆ¬に編é›?ƒ‡ータとして登録されたデータ)
074 *
075 * @return 修正後ã?æ–?—å?(ä¸?ˆ¬にãƒ??タベã?スに登録するãƒ??タ)
076 */
077 @Override
078 public String valueSet( final String value ) {
079 // return StringUtil.getMD5( StringUtil.rTrim( value ) );
080 return HybsCryptography.getMD5( StringUtil.rTrim( value ) ); // 5.2.2.0 (2010/11/01) クラス変更
081 }
082 }