2 * Copyright (C) 2013 Tobias Brunner
3 * Copyright (C) 2012 Christoph Buehler
4 * Copyright (C) 2012 Patrick Loetscher
5 * Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 package org
.strongswan
.android
.logic
.imc
.attributes
;
20 import java
.util
.LinkedList
;
22 import org
.strongswan
.android
.utils
.BufferedByteWriter
;
24 import android
.util
.Pair
;
27 * PA-TNC Installed Packages attribute (see section 4.2.7 of RFC 5792)
30 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
31 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32 * | Reserved | Package Count |
33 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 * | Pkg Name Len | Package Name (Variable Length) |
35 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 * | Version Len | Package Version Number (Variable Length) |
37 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 public class InstalledPackagesAttribute
implements Attribute
41 private final short RESERVED
= 0;
42 private final LinkedList
<Pair
<String
, String
>> mPackages
= new LinkedList
<Pair
<String
, String
>>();
45 * Add an installed package to this attribute.
46 * @param name name of the package
47 * @param version version number of the package
49 public void addPackage(String name
, String version
)
51 mPackages
.add(new Pair
<String
, String
>(name
, version
));
55 public byte[] getEncoding()
57 BufferedByteWriter writer
= new BufferedByteWriter();
58 writer
.put16(RESERVED
);
59 writer
.put16((short)mPackages
.size());
60 for (Pair
<String
, String
> pair
: mPackages
)
62 writer
.putLen8(pair
.first
.getBytes());
63 writer
.putLen8(pair
.second
.getBytes());
65 return writer
.toByteArray();