01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.harmony.security.x509.tsp;
21:
22: import org.apache.harmony.security.asn1.ASN1OctetString;
23: import org.apache.harmony.security.asn1.ASN1Sequence;
24: import org.apache.harmony.security.asn1.ASN1Type;
25: import org.apache.harmony.security.asn1.BerInputStream;
26: import org.apache.harmony.security.x509.AlgorithmIdentifier;
27:
28: /**
29: * As defined in Time-Stamp Protocol (TSP)
30: * (http://www.ietf.org/rfc/rfc3161.txt)
31: *
32: * MessageImprint ::= SEQUENCE {
33: * hashAlgorithm AlgorithmIdentifier,
34: * hashedMessage OCTET STRING
35: * }
36: *
37: */
38: public class MessageImprint {
39: private final AlgorithmIdentifier algId;
40: private final byte[] hashedMessage;
41:
42: public MessageImprint(AlgorithmIdentifier algId,
43: byte[] hashedMessage) {
44: this .algId = algId;
45: this .hashedMessage = hashedMessage;
46: }
47:
48: public static final ASN1Sequence ASN1 = new ASN1Sequence(
49: new ASN1Type[] { AlgorithmIdentifier.ASN1,
50: ASN1OctetString.getInstance() }) {
51:
52: protected Object getDecodedObject(BerInputStream in) {
53: Object[] values = (Object[]) in.content;
54: return new MessageImprint((AlgorithmIdentifier) values[0],
55: (byte[]) values[1]);
56: }
57:
58: protected void getValues(Object object, Object[] values) {
59: MessageImprint mi = (MessageImprint) object;
60: values[0] = mi.algId;
61: values[1] = mi.hashedMessage;
62: }
63: };
64: }
|