net.bryansaunders.jee6divelog.util
Class SecurityUtils

java.lang.Object
  extended by net.bryansaunders.jee6divelog.util.SecurityUtils

public final class SecurityUtils
extends java.lang.Object

Security Utilities.

Author:
Bryan Saunders

Method Summary
static java.lang.String generatePasswordHash(java.lang.String passwordToHash)
          Generate Password Hash for Application.
static java.lang.String generateRestApiKey()
          Generates a Random REST API Key.
static java.lang.String generateRestSignature(java.lang.String verb, java.lang.String contentType, java.lang.String contentMd5, java.lang.String date, java.lang.String requestUrl, java.lang.String key)
          Generates a Request Signature using the Specified Parameters.
static boolean isAnnotationSecure(java.lang.annotation.Annotation annotation)
          Determines is the given Annotation is Secured.
static boolean isMethodSecure(org.jboss.resteasy.core.ResourceMethod resourceMethod)
          Determines if the Method is Secure or Not based on its Declared Annotations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

generatePasswordHash

public static java.lang.String generatePasswordHash(java.lang.String passwordToHash)
Generate Password Hash for Application. Uses SHA-256 & Base64 Encoding.

Parameters:
passwordToHash - String to hash for password
Returns:
Hashed password.

generateRestApiKey

public static java.lang.String generateRestApiKey()
Generates a Random REST API Key.

Returns:
Random API Key

isMethodSecure

public static boolean isMethodSecure(org.jboss.resteasy.core.ResourceMethod resourceMethod)
Determines if the Method is Secure or Not based on its Declared Annotations.

Parameters:
resourceMethod - Called Method
Returns:
true if the Method is Secured

isAnnotationSecure

public static boolean isAnnotationSecure(java.lang.annotation.Annotation annotation)
Determines is the given Annotation is Secured.

Parameters:
annotation - Annotation to check
Returns:
true if the annotation is secured, false if it is not

generateRestSignature

public static java.lang.String generateRestSignature(java.lang.String verb,
                                                     java.lang.String contentType,
                                                     java.lang.String contentMd5,
                                                     java.lang.String date,
                                                     java.lang.String requestUrl,
                                                     java.lang.String key)
Generates a Request Signature using the Specified Parameters.

Parameters:
verb - HTTP Request Method
contentType - Request Content Type
contentMd5 - MD5 Hash of Request Content
date - Request Date, yyyy-MM-dd
requestUrl - Request URL
key - Key to Sign String with
Returns:
Generated Signature


Copyright © 2012 Bryan Saunders. All Rights Reserved.