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    }