001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import java.nio.ByteBuffer;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Alexander Chow
024     * @author Connor McKay
025     */
026    public class DigesterUtil {
027    
028            public static String digest(ByteBuffer byteBuffer) {
029                    return getDigester().digest(byteBuffer);
030            }
031    
032            public static String digest(String text) {
033                    return getDigester().digest(text);
034            }
035    
036            public static String digest(String algorithm, ByteBuffer byteBuffer) {
037                    return getDigester().digest(algorithm, byteBuffer);
038            }
039    
040            public static String digest(String algorithm, String... text) {
041                    return getDigester().digest(algorithm, text);
042            }
043    
044            public static String digestBase64(ByteBuffer byteBuffer) {
045                    return getDigester().digestBase64(byteBuffer);
046            }
047    
048            public static String digestBase64(String text) {
049                    return getDigester().digestBase64(text);
050            }
051    
052            public static String digestBase64(String algorithm, ByteBuffer byteBuffer) {
053                    return getDigester().digestBase64(algorithm, byteBuffer);
054            }
055    
056            public static String digestBase64(String algorithm, String... text) {
057                    return getDigester().digestBase64(algorithm, text);
058            }
059    
060            public static String digestHex(ByteBuffer byteBuffer) {
061                    return getDigester().digestHex(byteBuffer);
062            }
063    
064            public static String digestHex(String text) {
065                    return getDigester().digestHex(text);
066            }
067    
068            public static String digestHex(String algorithm, ByteBuffer byteBuffer) {
069                    return getDigester().digestHex(algorithm, byteBuffer);
070            }
071    
072            public static String digestHex(String algorithm, String... text) {
073                    return getDigester().digestHex(algorithm, text);
074            }
075    
076            public static byte[] digestRaw(ByteBuffer byteBuffer) {
077                    return getDigester().digestRaw(byteBuffer);
078            }
079    
080            public static byte[] digestRaw(String text) {
081                    return getDigester().digestRaw(text);
082            }
083    
084            public static byte[] digestRaw(String algorithm, ByteBuffer byteBuffer) {
085                    return getDigester().digestRaw(algorithm, byteBuffer);
086            }
087    
088            public static byte[] digestRaw(String algorithm, String... text) {
089                    return getDigester().digestRaw(algorithm, text);
090            }
091    
092            public static Digester getDigester() {
093                    PortalRuntimePermission.checkGetBeanProperty(DigesterUtil.class);
094    
095                    return _digester;
096            }
097    
098            public void setDigester(Digester digester) {
099                    PortalRuntimePermission.checkSetBeanProperty(getClass());
100    
101                    _digester = digester;
102            }
103    
104            private static Digester _digester;
105    
106    }