Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2009 Erik Bengtson and others. All rights reserved. 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. Contributors: ... /
package org.datanucleus.store.json;
public class AmazonS3Utils
    private static final String UTF8_CHARSET = "UTF-8";
    private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

    
Compile the HMAC of the data using the secret key

Parameters:
key the secret key
data
Returns:
    public static String hmac(String keyString data)
    {
        try
        {
            byte[] secretyKeyBytes = key.getBytes();
            SecretKeySpec secretKeySpec = new SecretKeySpec(secretyKeyBytes);
            Mac mac = Mac.getInstance();
            mac.init(secretKeySpec);
            byte[] rawHmac = mac.doFinal(data.getBytes());
            return new String(Base64.encode(rawHmac));
        }
        catch (UnsupportedEncodingException e)
        {
            throw new NucleusException( + " is unsupported!"e);
        }
        catch (NoSuchAlgorithmException e)
        {
            throw new NucleusException(e.getMessage(), e);
        }
        catch (InvalidKeyException e)
        {
            throw new NucleusException(e.getMessage(), e);
        }
    }

    
get the date according to the HTTP standard

Returns:
the current date
    public static String getHTTPDate()
    {
        DateFormat httpDateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z");
        return httpDateFormat.format(new Date());
    }
New to GrepCode? Check out our FAQ X