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.token;
017    
018    import org.opengion.hayabusa.common.HybsSystem;
019    import org.opengion.hayabusa.html.AbstractCreateToken;
020    import org.opengion.fukurou.util.StringUtil;
021    
022    import com.akamai.authentication.URLToken.URLTokenFactory;
023    
024    /**
025     * アカマイのト?クンを付加するためのプラグインです?
026     * 
027     * 以下?シス?リソース設定を行う事でパラメータの変更が可能です?
028     * AKAMAI_SALT:ト?クン作?時?saltを指定します?未??場?altとなります?
029     *
030     * @og.group 画面表示
031     * @og.rev 5.8.2.2 (2014/12/19)
032     *
033     * @version  5.0
034     * @author       Takahashi Masakazu
035     * @since    JDK5.0,
036     */
037    public class CreateToken_Akamai extends AbstractCreateToken {
038            //* こ?プログラ??VERSION??を設定します?       {@value} */
039            private static final String VERSION = "5.8.2.1 (2014/12/13)" ;
040            
041            private static final String AKAMAI_SALT = StringUtil.nval(HybsSystem.sys( "AKAMAI_SALT" ),"salt");
042            
043            private static final URLTokenFactory fact = new URLTokenFactory();
044    
045    
046            /**
047             * アカマイのト?クンを付けたURLを返します?
048             *
049             *
050             * @return  URL
051             */
052            @Override
053            public String  generateURL( final String inURL, final long time, final String user, final String[] param ){
054                    long wn = ( time - System.currentTimeMillis() ) /1000;
055                    return fact.generateURL(inURL, null, wn , AKAMAI_SALT, System.currentTimeMillis()); 
056            }       
057    
058    }