2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ihc.internal.ws.datatypes;
15 import java.io.IOException;
17 import javax.xml.xpath.XPathExpressionException;
19 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
22 * Class for WSLoginResult complex type.
24 * @author Pauli Anttila - Initial contribution
26 public class WSLoginResult {
28 protected WSUser loggedInUser;
29 protected boolean loginWasSuccessful;
30 protected boolean loginFailedDueToConnectionRestrictions;
31 protected boolean loginFailedDueToInsufficientUserRights;
32 protected boolean loginFailedDueToAccountInvalid;
34 public WSLoginResult() {
37 public WSLoginResult(WSUser loggedInUser, boolean loginWasSuccessful,
38 boolean loginFailedDueToConnectionRestrictions, boolean loginFailedDueToInsufficientUserRights,
39 boolean loginFailedDueToAccountInvalid) {
40 this.loggedInUser = loggedInUser;
41 this.loginWasSuccessful = loginWasSuccessful;
42 this.loginFailedDueToConnectionRestrictions = loginFailedDueToConnectionRestrictions;
43 this.loginFailedDueToInsufficientUserRights = loginFailedDueToInsufficientUserRights;
44 this.loginFailedDueToAccountInvalid = loginFailedDueToAccountInvalid;
48 * Gets the value of the loggedInUser property.
50 * @return possible object is {@link WSUser }
53 public WSUser getLoggedInUser() {
58 * Sets the value of the loggedInUser property.
60 * @param value allowed object is {@link WSUser }
63 public void setLoggedInUser(WSUser value) {
64 this.loggedInUser = value;
68 * Gets the value of the loginWasSuccessful property.
71 public boolean isLoginWasSuccessful() {
72 return loginWasSuccessful;
76 * Sets the value of the loginWasSuccessful property.
79 public void setLoginWasSuccessful(boolean value) {
80 this.loginWasSuccessful = value;
84 * Gets the value of the loginFailedDueToConnectionRestrictions property.
87 public boolean isLoginFailedDueToConnectionRestrictions() {
88 return loginFailedDueToConnectionRestrictions;
92 * Sets the value of the loginFailedDueToConnectionRestrictions property.
95 public void setLoginFailedDueToConnectionRestrictions(boolean value) {
96 this.loginFailedDueToConnectionRestrictions = value;
100 * Gets the value of the loginFailedDueToInsufficientUserRights property.
103 public boolean isLoginFailedDueToInsufficientUserRights() {
104 return loginFailedDueToInsufficientUserRights;
108 * Sets the value of the loginFailedDueToInsufficientUserRights property.
111 public void setLoginFailedDueToInsufficientUserRights(boolean value) {
112 this.loginFailedDueToInsufficientUserRights = value;
116 * Gets the value of the loginFailedDueToAccountInvalid property.
119 public boolean isLoginFailedDueToAccountInvalid() {
120 return loginFailedDueToAccountInvalid;
124 * Sets the value of the loginFailedDueToAccountInvalid property.
127 public void setLoginFailedDueToAccountInvalid(boolean value) {
128 this.loginFailedDueToAccountInvalid = value;
131 public WSLoginResult parseXMLData(String data) throws IhcExecption {
133 loginWasSuccessful = XPathUtils.parseValueToBoolean(data,
134 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:authenticate2/ns1:loginWasSuccessful");
136 loginFailedDueToConnectionRestrictions = XPathUtils.parseValueToBoolean(data,
137 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:authenticate2/ns1:loginFailedDueToConnectionRestrictions");
139 loginFailedDueToInsufficientUserRights = XPathUtils.parseValueToBoolean(data,
140 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:authenticate2/ns1:loginFailedDueToInsufficientUserRights");
142 loginFailedDueToAccountInvalid = XPathUtils.parseValueToBoolean(data,
143 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:authenticate2/ns1:loginFailedDueToAccountInvalid");
146 } catch (IOException | XPathExpressionException e) {
147 throw new IhcExecption("Error occured during XML data parsing", e);