Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/packets/PacketUserauthFailure.java @ 273:91a31873c42a ganymed
start conversion from trilead to ganymed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 18 Jul 2014 11:21:46 -0700 |
parents | |
children | 071eccdff8ea |
comparison
equal
deleted
inserted
replaced
272:ce2f4e397703 | 273:91a31873c42a |
---|---|
1 /* | |
2 * Copyright (c) 2006-2013 Christian Plattner. All rights reserved. | |
3 * Please refer to the LICENSE.txt for licensing details. | |
4 */ | |
5 package ch.ethz.ssh2.packets; | |
6 | |
7 import java.io.IOException; | |
8 import java.util.Arrays; | |
9 import java.util.HashSet; | |
10 import java.util.Set; | |
11 | |
12 import ch.ethz.ssh2.PacketFormatException; | |
13 import ch.ethz.ssh2.PacketTypeException; | |
14 | |
15 /** | |
16 * @author Christian Plattner | |
17 * @version $Id: PacketUserauthFailure.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $ | |
18 */ | |
19 public final class PacketUserauthFailure { | |
20 | |
21 private final byte[] payload; | |
22 | |
23 private Set<String> authThatCanContinue; | |
24 | |
25 private boolean partialSuccess; | |
26 | |
27 public PacketUserauthFailure(Set<String> authThatCanContinue, boolean partialSuccess) { | |
28 this.authThatCanContinue = authThatCanContinue; | |
29 this.partialSuccess = partialSuccess; | |
30 TypesWriter tw = new TypesWriter(); | |
31 tw.writeByte(Packets.SSH_MSG_USERAUTH_FAILURE); | |
32 tw.writeNameList(authThatCanContinue.toArray(new String[authThatCanContinue.size()])); | |
33 tw.writeBoolean(partialSuccess); | |
34 payload = tw.getBytes(); | |
35 } | |
36 | |
37 public PacketUserauthFailure(byte payload[]) throws IOException { | |
38 this.payload = payload; | |
39 | |
40 TypesReader tr = new TypesReader(payload); | |
41 | |
42 int packet_type = tr.readByte(); | |
43 | |
44 if(packet_type != Packets.SSH_MSG_USERAUTH_FAILURE) { | |
45 throw new PacketTypeException(packet_type); | |
46 } | |
47 authThatCanContinue = new HashSet<String>(Arrays.asList(tr.readNameList())); | |
48 partialSuccess = tr.readBoolean(); | |
49 | |
50 if(tr.remain() != 0) { | |
51 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type))); | |
52 } | |
53 } | |
54 | |
55 public byte[] getPayload() { | |
56 return payload; | |
57 } | |
58 | |
59 public Set<String> getAuthThatCanContinue() { | |
60 return authThatCanContinue; | |
61 } | |
62 | |
63 public boolean isPartialSuccess() { | |
64 return partialSuccess; | |
65 } | |
66 } |