2 * Copyright (C) 2013 Tobias Brunner
3 * Copyright (C) 2012 Christoph Buehler
4 * Copyright (C) 2012 Patrick Loetscher
6 * Copyright (C) secunet Security Networks AG
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 package org
.strongswan
.android
.logic
.imc
.attributes
;
21 import java
.util
.LinkedList
;
23 import org
.strongswan
.android
.utils
.BufferedByteWriter
;
25 import android
.util
.Pair
;
28 * PA-TNC Installed Packages attribute (see section 4.2.7 of RFC 5792)
31 * 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
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * | Reserved | Package Count |
34 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 * | Pkg Name Len | Package Name (Variable Length) |
36 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * | Version Len | Package Version Number (Variable Length) |
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 public class InstalledPackagesAttribute
implements Attribute
42 private final short RESERVED
= 0;
43 private final LinkedList
<Pair
<String
, String
>> mPackages
= new LinkedList
<Pair
<String
, String
>>();
46 * Add an installed package to this attribute.
47 * @param name name of the package
48 * @param version version number of the package
50 public void addPackage(String name
, String version
)
52 mPackages
.add(new Pair
<String
, String
>(name
, version
));
56 public byte[] getEncoding()
58 BufferedByteWriter writer
= new BufferedByteWriter();
59 writer
.put16(RESERVED
);
60 writer
.put16((short)mPackages
.size());
61 for (Pair
<String
, String
> pair
: mPackages
)
63 writer
.putLen8(pair
.first
.getBytes());
64 writer
.putLen8(pair
.second
.getBytes());
66 return writer
.toByteArray();