View Javadoc
1   package org.metricshub.ipmi.core.coding.commands.session;
2   
3   /*-
4    * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
5    * IPMI Java Client
6    * ჻჻჻჻჻჻
7    * Copyright 2023 Verax Systems, MetricsHub
8    * ჻჻჻჻჻჻
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation, either version 3 of the
12   * License, or (at your option) any later version.
13   *
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Lesser Public License for more details.
18   *
19   * You should have received a copy of the GNU General Lesser Public
20   * License along with this program.  If not, see
21   * <http://www.gnu.org/licenses/lgpl-3.0.html>.
22   * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
23   */
24  
25  import org.metricshub.ipmi.core.coding.commands.CommandsConstants;
26  import org.metricshub.ipmi.core.coding.commands.PrivilegeLevel;
27  import org.metricshub.ipmi.core.coding.commands.ResponseData;
28  
29  /**
30   * A wrapper for Open Session command response
31   * 
32   * @see OpenSession
33   */
34  public class OpenSessionResponseData implements ResponseData {
35      /**
36       * The BMC returns the Message Tag value that was passed by the remote
37       * console in the Open Session Request message
38       */
39      private byte messageTag;
40  
41      /**
42       * Identifies the status of the previous message. If the previous message
43       * generated an error, then only the Status Code, Reserved, and Remote
44       * Console Session ID fields are returned.
45       */
46      private byte statusCode;
47  
48      /**
49       * Indicates the Maximum Privilege Level allowed for the session.
50       */
51      private byte privilegeLevel;
52  
53      /**
54       * The Remote Console Session ID specified by RMCP+ Open Session Request
55       * message associated with this response.
56       */
57      private int remoteConsoleSessionId;
58  
59      /**
60       * The Session ID selected by the Managed System for this new session.
61       */
62      private int managedSystemSessionId;
63  
64      /**
65       * This payload defines the authentication algorithm proposal selected by
66       * the Managed System to be used for this session
67       */
68      private byte authenticationAlgorithm;
69  
70      /**
71       * This payload defines the integrity algorithm proposal selected by the
72       * Managed System to be used for this session
73       */
74      private byte integrityAlgorithm;
75  
76      /**
77       * This payload defines the confidentiality algorithm proposal selected by
78       * the Managed System to be used for this session
79       */
80      private byte confidentialityAlgorithm;
81  
82      public void setMessageTag(byte messageTag) {
83          this.messageTag = messageTag;
84      }
85  
86      public byte getMessageTag() {
87          return messageTag;
88      }
89  
90      public void setStatusCode(byte statusCode) {
91          this.statusCode = statusCode;
92      }
93  
94      public byte getStatusCode() {
95          return statusCode;
96      }
97  
98      public void setPrivilegeLevel(byte privilegeLevel) {
99          this.privilegeLevel = privilegeLevel;
100     }
101 
102     public PrivilegeLevel getPrivilegeLevel() {
103         switch (privilegeLevel) {
104         case CommandsConstants.AL_CALLBACK:
105             return PrivilegeLevel.Callback;
106         case CommandsConstants.AL_USER:
107             return PrivilegeLevel.User;
108         case CommandsConstants.AL_OPERATOR:
109             return PrivilegeLevel.Operator;
110         case CommandsConstants.AL_ADMINISTRATOR:
111             return PrivilegeLevel.Administrator;
112         default:
113             throw new IllegalArgumentException("Invalid privilege level");
114         }
115     }
116 
117     public void setRemoteConsoleSessionId(int remoteConsoleSessionId) {
118         this.remoteConsoleSessionId = remoteConsoleSessionId;
119     }
120 
121     public int getRemoteConsoleSessionId() {
122         return remoteConsoleSessionId;
123     }
124 
125     public void setManagedSystemSessionId(int managedSystemSessionId) {
126         this.managedSystemSessionId = managedSystemSessionId;
127     }
128 
129     public int getManagedSystemSessionId() {
130         return managedSystemSessionId;
131     }
132 
133     public void setAuthenticationAlgorithm(byte authenticationAlgorithm) {
134         this.authenticationAlgorithm = authenticationAlgorithm;
135     }
136 
137     public byte getAuthenticationAlgorithm() {
138         return authenticationAlgorithm;
139     }
140 
141     public void setIntegrityAlgorithm(byte integrityAlgorithm) {
142         this.integrityAlgorithm = integrityAlgorithm;
143     }
144 
145     public byte getIntegrityAlgorithm() {
146         return integrityAlgorithm;
147     }
148 
149     public void setConfidentialityAlgorithm(byte confidentialityAlgorithm) {
150         this.confidentialityAlgorithm = confidentialityAlgorithm;
151     }
152 
153     public byte getConfidentialityAlgorithm() {
154         return confidentialityAlgorithm;
155     }
156 }