2017-04-12 17:40:32 +02:00
|
|
|
/*
|
2019-03-16 17:04:23 +08:00
|
|
|
* Copyright (c) 2012-2017 The original author or authors
|
2017-04-12 17:40:32 +02:00
|
|
|
* ------------------------------------------------------
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
|
* and Apache License v2.0 which accompanies this distribution.
|
|
|
|
|
*
|
|
|
|
|
* The Eclipse Public License is available at
|
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
*
|
|
|
|
|
* The Apache License v2.0 is available at
|
|
|
|
|
* http://www.opensource.org/licenses/apache2.0.php
|
|
|
|
|
*
|
|
|
|
|
* You may elect to redistribute this code under either of these licenses.
|
|
|
|
|
*/
|
2017-02-01 15:13:49 +01:00
|
|
|
|
2015-11-20 20:54:27 +01:00
|
|
|
package io.moquette.interception.messages;
|
2015-08-17 17:41:29 -03:00
|
|
|
|
2017-01-28 10:06:30 +01:00
|
|
|
import io.netty.handler.codec.mqtt.MqttConnectMessage;
|
2015-08-17 17:41:29 -03:00
|
|
|
|
|
|
|
|
public class InterceptConnectMessage extends InterceptAbstractMessage {
|
2017-02-01 15:13:49 +01:00
|
|
|
|
2017-01-28 10:06:30 +01:00
|
|
|
private final MqttConnectMessage msg;
|
2015-08-17 17:41:29 -03:00
|
|
|
|
2017-01-28 10:06:30 +01:00
|
|
|
public InterceptConnectMessage(MqttConnectMessage msg) {
|
2015-08-17 17:41:29 -03:00
|
|
|
super(msg);
|
|
|
|
|
this.msg = msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getClientID() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.payload().clientIdentifier();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isCleanSession() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().isCleanSession();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getKeepAlive() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().keepAliveTimeSeconds();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isPasswordFlag() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().hasPassword();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte getProtocolVersion() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return (byte) msg.variableHeader().version();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getProtocolName() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().name();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isUserFlag() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().hasUserName();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isWillFlag() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().isWillFlag();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte getWillQos() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return (byte) msg.variableHeader().willQos();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isWillRetain() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.variableHeader().isWillRetain();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getUsername() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.payload().userName();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
2015-09-16 23:25:15 +02:00
|
|
|
public byte[] getPassword() {
|
2022-09-18 22:05:22 +08:00
|
|
|
return msg.payload().passwordInBytes();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getWillTopic() {
|
2017-01-28 10:06:30 +01:00
|
|
|
return msg.payload().willTopic();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
|
2015-09-16 23:25:15 +02:00
|
|
|
public byte[] getWillMessage() {
|
2019-03-16 17:04:23 +08:00
|
|
|
return msg.payload().willMessage().getBytes();
|
2015-08-17 17:41:29 -03:00
|
|
|
}
|
|
|
|
|
}
|