Source Code Cross Referenced for LoginTicketCache.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » yale » its » tp » cas » ticket » 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 » ERP CRM Financial » Kuali Financial System » edu.yale.its.tp.cas.ticket 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package edu.yale.its.tp.cas.ticket;
017:
018:        import java.security.SecureRandom;
019:        import java.util.Collections;
020:        import java.util.HashMap;
021:        import java.util.Map;
022:
023:        /**
024:         * Represents a cache of login tickets. These are one-time-use tickets provided on the login page that must be posted back to CAS in
025:         * order for a login to be successful. This fixes a bug in IE and Safari where going back through the history causes login
026:         * credentials to be reposted to CAS. This class is almost identical to ServiceTicketCache, except it is made to only hold
027:         * LoginTickets.
028:         */
029:        public class LoginTicketCache extends OTUTicketCache {
030:
031:            // *********************************************************************
032:            // KFSConstants
033:
034:            /** Length of random ticket identifiers. */
035:            private static final int TICKET_ID_LENGTH = 20;
036:
037:            // *********************************************************************
038:            // Private state
039:
040:            /** The actual cache of tickets (ticketId -> Ticket map) */
041:            private Map ticketCache;
042:
043:            /** Monotonically increasing serial number for tickets. */
044:            private static int serial = 0;
045:
046:            // *********************************************************************
047:            // Constructor
048:
049:            /**
050:             * Constructs a new ServiceTicketCache that is intended to store cookies of the given specific ticket type.
051:             */
052:            public LoginTicketCache(int tolerance) {
053:                super (tolerance);
054:                this .ticketCache = Collections.synchronizedMap(new HashMap());
055:            }
056:
057:            // *********************************************************************
058:            // Cache-management logic
059:
060:            public synchronized String addTicket() throws TicketException {
061:                return addTicket(new LoginTicket());
062:            }
063:
064:            /** Generates and returns a new, unique ticket ID */
065:            protected String newTicketId() {
066:                // determine appropriate ticketId prefix
067:                String prefix = "LT";
068:
069:                // produce the random identifier
070:                byte[] b = new byte[TICKET_ID_LENGTH];
071:                SecureRandom sr = new SecureRandom();
072:                sr.nextBytes(b);
073:                String ticketId = prefix + "-" + (serial++) + "-"
074:                        + Util.toPrintable(b);
075:
076:                // make sure the identifier isn't already used
077:                if (ticketCache.get(ticketId) != null)
078:                    return newTicketId(); // tail-recurse
079:                else
080:                    return ticketId;
081:            }
082:
083:            /** Stores the given ticket, associating it with the given identifier. */
084:            protected void storeTicket(String ticketId, Ticket t)
085:                    throws TicketException {
086:                // make sure the ticket is valid and new
087:                if (ticketCache.get(ticketId) != null)
088:                    throw new DuplicateTicketException();
089:
090:                // if it's okay, then store it
091:                ticketCache.put(ticketId, t);
092:            }
093:
094:            /** Retrieves the ticket with the given identifier. */
095:            protected Ticket retrieveTicket(String ticketId) {
096:                Object o = ticketCache.get(ticketId);
097:                if (o == null)
098:                    return null;
099:                else
100:                    return (Ticket) o;
101:            }
102:
103:            /** Removes the ticket from the cache. */
104:            public void deleteTicket(String ticketId) {
105:                Object o = ticketCache.remove(ticketId);
106:            }
107:
108:            /** Returns the current ticket serial number (for monitoring) */
109:            public int getSerialNumber() {
110:                return this .serial;
111:            }
112:
113:            /** Returns the current number of tickets in the ticket cache. */
114:            public int getCacheSize() {
115:                return ticketCache.size();
116:            }
117:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.