Java Doc for RandomGuid.java in  » Workflow-Engines » spring-webflow-1.0.4 » org » springframework » webflow » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » spring webflow 1.0.4 » org.springframework.webflow.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.webflow.util.RandomGuid

RandomGuid
public class RandomGuid (Code)
Globally unique identifier generator.

In the multitude of java GUID generators, I found none that guaranteed randomness. GUIDs are guaranteed to be globally unique by using ethernet MACs, IP addresses, time elements, and sequential numbers. GUIDs are not expected to be random and most often are easy/possible to guess given a sample from a given generator. SQL Server, for example generates GUID that are unique but sequencial within a given instance.

GUIDs can be used as security devices to hide things such as files within a filesystem where listings are unavailable (e.g. files that are served up from a Web server with indexing turned off). This may be desireable in cases where standard authentication is not appropriate. In this scenario, the RandomGuids are used as directories. Another example is the use of GUIDs for primary keys in a database where you want to ensure that the keys are secret. Random GUIDs can then be used in a URL to prevent hackers (or users) from accessing records by guessing or simply by incrementing sequential numbers.

There are many other possiblities of using GUIDs in the realm of security and encryption where the element of randomness is important. This class was written for these purposes but can also be used as a general purpose GUID generator as well.

RandomGuid generates truly random GUIDs by using the system's IP address (name/IP), system time in milliseconds (as an integer), and a very large random number joined together in a single String that is passed through an MD5 hash. The IP address and system time make the MD5 seed globally unique and the random number guarantees that the generated GUIDs will have no discernable pattern and cannot be guessed given any number of previously generated GUIDs. It is generally not possible to access the seed information (IP, time, random number) from the resulting GUIDs as the MD5 hash algorithm provides one way encryption.

Security of RandomGuid: RandomGuid can be called one of two ways -- with the basic java Random number generator or a cryptographically strong random generator (SecureRandom). The choice is offered because the secure random generator takes about 3.5 times longer to generate its random numbers and this performance hit may not be worth the added security especially considering the basic generator is seeded with a cryptographically strong random seed.

Seeding the basic generator in this way effectively decouples the random numbers from the time component making it virtually impossible to predict the random number component even if one had absolute knowledge of the System time. Thanks to Ashutosh Narhari for the suggestion of using the static method to prime the basic random generator.

Using the secure random option, this class complies with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, secition 4.9.1.

I converted all the pieces of the seed to a String before handing it over to the MD5 hash so that you could print it out to make sure it contains the data you expect to see and to give a nice warm fuzzy. If you need better performance, you may want to stick to byte[] arrays.

I believe that it is important that the algorithm for generating random GUIDs be open for inspection and modification. This class is free for all uses.
version:
   1.2.1 11/05/02
author:
   Marc A. Mnich




Constructor Summary
public  RandomGuid()
     Default constructor.
public  RandomGuid(boolean secure)
     Constructor with security option.

Method Summary
public  StringtoString()
     Convert to the standard format for GUID (Useful for SQL Server UniqueIdentifiers, etc).


Constructor Detail
RandomGuid
public RandomGuid()(Code)
Default constructor. With no specification of security option, this constructor defaults to lower security, high performance.



RandomGuid
public RandomGuid(boolean secure)(Code)
Constructor with security option. Setting secure true enables each random number generated to be cryptographically strong. Secure false defaults to the standard Random function seeded with a single cryptographically strong random number.




Method Detail
toString
public String toString()(Code)
Convert to the standard format for GUID (Useful for SQL Server UniqueIdentifiers, etc). Example: "C2FEEEAC-CFCD-11D1-8B05-00600806D9B6".



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.