This repository has been archived by the owner on Jul 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化 HttpConcatUtil 代码 enhancement fix #39
feilong concat version 支持 md5 或者sha fix #37
- Loading branch information
1 parent
d8c5ed8
commit dd8cbdf
Showing
8 changed files
with
306 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/java/com/feilong/taglib/display/httpconcat/handler/VersionEncodeUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2008 feilong | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.feilong.taglib.display.httpconcat.handler; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.feilong.security.oneway.MD5Util; | ||
import com.feilong.security.oneway.SHA1Util; | ||
|
||
/** | ||
* 独立成一个类,避免没有依赖 security 报错. | ||
* | ||
* @author <a href="http://feitianbenyue.iteye.com/">feilong</a> | ||
* @since 1.11.1 | ||
*/ | ||
public class VersionEncodeUtil{ | ||
|
||
/** The Constant LOGGER. */ | ||
private static final Logger LOGGER = LoggerFactory.getLogger(VersionEncodeUtil.class); | ||
|
||
/** | ||
* Encode. | ||
* | ||
* @param version | ||
* the version | ||
* @param versionEncode | ||
* the version encode | ||
* @return the string | ||
*/ | ||
static String encode(String version,String versionEncode){ | ||
if ("md5".equalsIgnoreCase(versionEncode)){ | ||
return MD5Util.encode(version + VersionFormatter.class.getName()); | ||
} | ||
|
||
if ("sha1".equalsIgnoreCase(versionEncode)){ | ||
return SHA1Util.encode(version + VersionFormatter.class.getName()); | ||
} | ||
|
||
LOGGER.warn("versionEncode:[{}] ,not md5 and not sha1", versionEncode); | ||
return version; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/feilong/taglib/display/httpconcat/handler/VersionFormatter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2008 feilong | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.feilong.taglib.display.httpconcat.handler; | ||
|
||
import static com.feilong.core.Validator.isNullOrEmpty; | ||
|
||
import com.feilong.taglib.display.httpconcat.command.HttpConcatGlobalConfig; | ||
|
||
/** | ||
* version 值格式化. | ||
* | ||
* @author <a href="http://feitianbenyue.iteye.com/">feilong</a> | ||
* @since 1.11.1 | ||
*/ | ||
public final class VersionFormatter{ | ||
|
||
//--------------------------------------------------------------- | ||
/** Don't let anyone instantiate this class. */ | ||
private VersionFormatter(){ | ||
//AssertionError不是必须的. 但它可以避免不小心在类的内部调用构造器. 保证该类在任何情况下都不会被实例化. | ||
//see 《Effective Java》 2nd | ||
throw new AssertionError("No " + getClass().getName() + " instances for you!"); | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
|
||
/** | ||
* Format. | ||
* | ||
* @param version | ||
* the version | ||
* @param httpConcatGlobalConfig | ||
* the http concat global config | ||
* @return 如果 version 没有值,那么直接返回<br> | ||
* 如果 version 有值,那么:<br> | ||
*/ | ||
public static String format(String version,HttpConcatGlobalConfig httpConcatGlobalConfig){ | ||
if (isNullOrEmpty(version)){ | ||
return version; | ||
} | ||
|
||
//--------------------------------------------------------------- | ||
String versionEncode = httpConcatGlobalConfig.getVersionEncode(); | ||
if (isNullOrEmpty(versionEncode)){ | ||
return version; | ||
} | ||
|
||
return VersionEncodeUtil.encode(version, versionEncode); | ||
} | ||
|
||
} |
Oops, something went wrong.