Source Code Cross Referenced for Accuracy.java in  » Security » Bouncy-Castle » org » bouncycastle » asn1 » tsp » 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 » Security » Bouncy Castle » org.bouncycastle.asn1.tsp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.asn1.tsp;
002:
003:        import org.bouncycastle.asn1.ASN1Encodable;
004:        import org.bouncycastle.asn1.ASN1EncodableVector;
005:        import org.bouncycastle.asn1.DERInteger;
006:        import org.bouncycastle.asn1.DERTaggedObject;
007:        import org.bouncycastle.asn1.DERSequence;
008:        import org.bouncycastle.asn1.ASN1Sequence;
009:        import org.bouncycastle.asn1.DERObject;
010:
011:        public class Accuracy extends ASN1Encodable {
012:            DERInteger seconds;
013:
014:            DERInteger millis;
015:
016:            DERInteger micros;
017:
018:            // constantes
019:            protected static final int MIN_MILLIS = 1;
020:
021:            protected static final int MAX_MILLIS = 999;
022:
023:            protected static final int MIN_MICROS = 1;
024:
025:            protected static final int MAX_MICROS = 999;
026:
027:            protected Accuracy() {
028:            }
029:
030:            public Accuracy(DERInteger seconds, DERInteger millis,
031:                    DERInteger micros) {
032:                this .seconds = seconds;
033:
034:                //Verifications
035:                if (millis != null
036:                        && (millis.getValue().intValue() < MIN_MILLIS || millis
037:                                .getValue().intValue() > MAX_MILLIS)) {
038:                    throw new IllegalArgumentException(
039:                            "Invalid millis field : not in (1..999)");
040:                } else {
041:                    this .millis = millis;
042:                }
043:
044:                if (micros != null
045:                        && (micros.getValue().intValue() < MIN_MICROS || micros
046:                                .getValue().intValue() > MAX_MICROS)) {
047:                    throw new IllegalArgumentException(
048:                            "Invalid micros field : not in (1..999)");
049:                } else {
050:                    this .micros = micros;
051:                }
052:
053:            }
054:
055:            public Accuracy(ASN1Sequence seq) {
056:                seconds = null;
057:                millis = null;
058:                micros = null;
059:
060:                for (int i = 0; i < seq.size(); i++) {
061:                    // seconds
062:                    if (seq.getObjectAt(i) instanceof  DERInteger) {
063:                        seconds = (DERInteger) seq.getObjectAt(i);
064:                    } else if (seq.getObjectAt(i) instanceof  DERTaggedObject) {
065:                        DERTaggedObject extra = (DERTaggedObject) seq
066:                                .getObjectAt(i);
067:
068:                        switch (extra.getTagNo()) {
069:                        case 0:
070:                            millis = DERInteger.getInstance(extra, false);
071:                            if (millis.getValue().intValue() < MIN_MILLIS
072:                                    || millis.getValue().intValue() > MAX_MILLIS) {
073:                                throw new IllegalArgumentException(
074:                                        "Invalid millis field : not in (1..999).");
075:                            }
076:                            break;
077:                        case 1:
078:                            micros = DERInteger.getInstance(extra, false);
079:                            if (micros.getValue().intValue() < MIN_MICROS
080:                                    || micros.getValue().intValue() > MAX_MICROS) {
081:                                throw new IllegalArgumentException(
082:                                        "Invalid micros field : not in (1..999).");
083:                            }
084:                            break;
085:                        default:
086:                            throw new IllegalArgumentException(
087:                                    "Invalig tag number");
088:                        }
089:                    }
090:                }
091:            }
092:
093:            public static Accuracy getInstance(Object o) {
094:                if (o == null || o instanceof  Accuracy) {
095:                    return (Accuracy) o;
096:                } else if (o instanceof  ASN1Sequence) {
097:                    return new Accuracy((ASN1Sequence) o);
098:                }
099:
100:                throw new IllegalArgumentException(
101:                        "Unknown object in 'Accuracy' factory : "
102:                                + o.getClass().getName() + ".");
103:            }
104:
105:            public DERInteger getSeconds() {
106:                return seconds;
107:            }
108:
109:            public DERInteger getMillis() {
110:                return millis;
111:            }
112:
113:            public DERInteger getMicros() {
114:                return micros;
115:            }
116:
117:            /**
118:             * <pre>
119:             * Accuracy ::= SEQUENCE {
120:             *             seconds        INTEGER              OPTIONAL,
121:             *             millis     [0] INTEGER  (1..999)    OPTIONAL,
122:             *             micros     [1] INTEGER  (1..999)    OPTIONAL
123:             *             }
124:             * </pre>
125:             */
126:            public DERObject toASN1Object() {
127:
128:                ASN1EncodableVector v = new ASN1EncodableVector();
129:
130:                if (seconds != null) {
131:                    v.add(seconds);
132:                }
133:
134:                if (millis != null) {
135:                    v.add(new DERTaggedObject(false, 0, millis));
136:                }
137:
138:                if (micros != null) {
139:                    v.add(new DERTaggedObject(false, 1, micros));
140:                }
141:
142:                return new DERSequence(v);
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.