18 changed files with 92 additions and 270 deletions
@ -1,26 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.mqtt.credentials; |
|
||||
|
|
||||
import org.thingsboard.rule.engine.credentials.AnonymousCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
public class MqttAnonymousCredentials extends AnonymousCredentials implements MqttClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.ANONYMOUS; |
|
||||
} |
|
||||
} |
|
||||
@ -1,33 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.mqtt.credentials; |
|
||||
|
|
||||
import org.thingsboard.mqtt.MqttClientConfig; |
|
||||
import org.thingsboard.rule.engine.credentials.BasicCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
public class MqttBasicCredentials extends BasicCredentials implements MqttClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.BASIC; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public void configure(MqttClientConfig config) { |
|
||||
config.setUsername(getUsername()); |
|
||||
config.setPassword(getPassword()); |
|
||||
} |
|
||||
} |
|
||||
@ -1,26 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.mqtt.credentials; |
|
||||
|
|
||||
import org.thingsboard.rule.engine.credentials.CertPemCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
public class MqttCertPemCredentials extends CertPemCredentials implements MqttClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.CERT_PEM; |
|
||||
} |
|
||||
} |
|
||||
@ -1,26 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.rest.credentials; |
|
||||
|
|
||||
import org.thingsboard.rule.engine.credentials.AnonymousCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
public class HttpAnonymousCredentials extends AnonymousCredentials implements HttpClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.ANONYMOUS; |
|
||||
} |
|
||||
} |
|
||||
@ -1,35 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.rest.credentials; |
|
||||
|
|
||||
import org.apache.commons.codec.binary.Base64; |
|
||||
import org.thingsboard.rule.engine.credentials.BasicCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
import java.nio.charset.StandardCharsets; |
|
||||
|
|
||||
public class HttpBasicCredentials extends BasicCredentials implements HttpClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.BASIC; |
|
||||
} |
|
||||
|
|
||||
public String getBasicAuthHeaderValue() { |
|
||||
String authString = getUsername() + ":" + getPassword(); |
|
||||
String encodedAuthString = new String(Base64.encodeBase64(authString.getBytes(StandardCharsets.UTF_8))); |
|
||||
return "Basic " + encodedAuthString; |
|
||||
} |
|
||||
} |
|
||||
@ -1,26 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.rest.credentials; |
|
||||
|
|
||||
import org.thingsboard.rule.engine.credentials.CertPemCredentials; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
public class HttpCertPemCredentials extends CertPemCredentials implements HttpClientCredentials { |
|
||||
@Override |
|
||||
public CredentialsType getType() { |
|
||||
return CredentialsType.CERT_PEM; |
|
||||
} |
|
||||
} |
|
||||
@ -1,32 +0,0 @@ |
|||||
/** |
|
||||
* Copyright © 2016-2021 The Thingsboard Authors |
|
||||
* |
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||
* you may not use this file except in compliance with the License. |
|
||||
* You may obtain a copy of the License at |
|
||||
* |
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||
* |
|
||||
* Unless required by applicable law or agreed to in writing, software |
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||
* See the License for the specific language governing permissions and |
|
||||
* limitations under the License. |
|
||||
*/ |
|
||||
package org.thingsboard.rule.engine.rest.credentials; |
|
||||
|
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes; |
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo; |
|
||||
import org.thingsboard.rule.engine.credentials.CredentialsType; |
|
||||
|
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") |
|
||||
@JsonSubTypes({ |
|
||||
@JsonSubTypes.Type(value = HttpAnonymousCredentials.class, name = "anonymous"), |
|
||||
@JsonSubTypes.Type(value = HttpBasicCredentials.class, name = "basic"), |
|
||||
@JsonSubTypes.Type(value = HttpCertPemCredentials.class, name = "cert.PEM")}) |
|
||||
public interface HttpClientCredentials { |
|
||||
@JsonIgnore |
|
||||
CredentialsType getType(); |
|
||||
} |
|
||||
|
|
||||
Loading…
Reference in new issue