| 1 |
775 |
jeremybenn |
/* MessageProp.java -- GSS-API message property.
|
| 2 |
|
|
Copyright (C) 2004 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
| 7 |
|
|
it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
| 9 |
|
|
any later version.
|
| 10 |
|
|
|
| 11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
| 12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
|
|
General Public License for more details.
|
| 15 |
|
|
|
| 16 |
|
|
You should have received a copy of the GNU General Public License
|
| 17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
| 18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
| 19 |
|
|
02110-1301 USA.
|
| 20 |
|
|
|
| 21 |
|
|
Linking this library statically or dynamically with other modules is
|
| 22 |
|
|
making a combined work based on this library. Thus, the terms and
|
| 23 |
|
|
conditions of the GNU General Public License cover the whole
|
| 24 |
|
|
combination.
|
| 25 |
|
|
|
| 26 |
|
|
As a special exception, the copyright holders of this library give you
|
| 27 |
|
|
permission to link this library with independent modules to produce an
|
| 28 |
|
|
executable, regardless of the license terms of these independent
|
| 29 |
|
|
modules, and to copy and distribute the resulting executable under
|
| 30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
| 31 |
|
|
independent module, the terms and conditions of the license of that
|
| 32 |
|
|
module. An independent module is a module which is not derived from
|
| 33 |
|
|
or based on this library. If you modify this library, you may extend
|
| 34 |
|
|
this exception to your version of the library, but you are not
|
| 35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
| 36 |
|
|
exception statement from your version.
|
| 37 |
|
|
|
| 38 |
|
|
The documentation comments of this class are derived from the text
|
| 39 |
|
|
of RFC 2853: Generic Security Service API Version 2: Java Bindings.
|
| 40 |
|
|
That document is covered under the following license notice:
|
| 41 |
|
|
|
| 42 |
|
|
Copyright (C) The Internet Society (2000). All Rights Reserved.
|
| 43 |
|
|
|
| 44 |
|
|
This document and translations of it may be copied and furnished to
|
| 45 |
|
|
others, and derivative works that comment on or otherwise explain it
|
| 46 |
|
|
or assist in its implementation may be prepared, copied, published and
|
| 47 |
|
|
distributed, in whole or in part, without restriction of any kind,
|
| 48 |
|
|
provided that the above copyright notice and this paragraph are
|
| 49 |
|
|
included on all such copies and derivative works. However, this
|
| 50 |
|
|
document itself may not be modified in any way, such as by removing
|
| 51 |
|
|
the copyright notice or references to the Internet Society or other
|
| 52 |
|
|
Internet organizations, except as needed for the purpose of developing
|
| 53 |
|
|
Internet standards in which case the procedures for copyrights defined
|
| 54 |
|
|
in the Internet Standards process must be followed, or as required to
|
| 55 |
|
|
translate it into languages other than English.
|
| 56 |
|
|
|
| 57 |
|
|
The limited permissions granted above are perpetual and will not be
|
| 58 |
|
|
revoked by the Internet Society or its successors or assigns.
|
| 59 |
|
|
|
| 60 |
|
|
This document and the information contained herein is provided on an
|
| 61 |
|
|
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
|
| 62 |
|
|
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT
|
| 63 |
|
|
NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN
|
| 64 |
|
|
WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
|
| 65 |
|
|
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. */
|
| 66 |
|
|
|
| 67 |
|
|
|
| 68 |
|
|
package org.ietf.jgss;
|
| 69 |
|
|
|
| 70 |
|
|
/**
|
| 71 |
|
|
* <p>This is a utility class used within the per-message {@link
|
| 72 |
|
|
* GSSContext} methods to convey per-message properties.</p>
|
| 73 |
|
|
*
|
| 74 |
|
|
* <p>When used with the GSSContext interface's {@link
|
| 75 |
|
|
* GSSContext#wrap(byte[],int,int,org.ietf.jgss.MessageProp)} and {@link
|
| 76 |
|
|
* GSSContext#getMIC(byte[],int,int,org.ietf.jgss.MessageProp)} methods, an
|
| 77 |
|
|
* instance of this class is used to indicate the desired QOP and to
|
| 78 |
|
|
* request if confidentiality services are to be applied to caller
|
| 79 |
|
|
* supplied data (wrap only). To request default QOP, the value of 0
|
| 80 |
|
|
* should be used for QOP.</p>
|
| 81 |
|
|
*
|
| 82 |
|
|
* <p>When used with the {@link
|
| 83 |
|
|
* GSSContext#unwrap(byte[],int,int,org.ietf.jgss.MessageProp)} and {@link
|
| 84 |
|
|
* GSSContext#verifyMIC(byte[],int,int,byte[],int,int,org.ietf.jgss.MessageProp)}
|
| 85 |
|
|
* methods of the GSSContext interface, an instance of this class will be
|
| 86 |
|
|
* used to indicate the applied QOP and confidentiality services over the
|
| 87 |
|
|
* supplied message. In the case of verifyMIC, the confidentiality state
|
| 88 |
|
|
* will always be "false". Upon return from these methods, this object will
|
| 89 |
|
|
* also contain any supplementary status values applicable to the processed
|
| 90 |
|
|
* token. The supplementary status values can indicate old tokens, out
|
| 91 |
|
|
* of sequence tokens, gap tokens or duplicate tokens.</p>
|
| 92 |
|
|
*/
|
| 93 |
|
|
public class MessageProp
|
| 94 |
|
|
{
|
| 95 |
|
|
|
| 96 |
|
|
// Fields.
|
| 97 |
|
|
// -------------------------------------------------------------------------
|
| 98 |
|
|
|
| 99 |
|
|
private int qopVal;
|
| 100 |
|
|
private boolean privState;
|
| 101 |
|
|
private boolean duplicate;
|
| 102 |
|
|
private boolean old;
|
| 103 |
|
|
private boolean unseq;
|
| 104 |
|
|
private boolean gap;
|
| 105 |
|
|
private int minorStatus;
|
| 106 |
|
|
private String minorString;
|
| 107 |
|
|
|
| 108 |
|
|
// Constructors.
|
| 109 |
|
|
// -------------------------------------------------------------------------
|
| 110 |
|
|
|
| 111 |
|
|
/**
|
| 112 |
|
|
* <p>Constructor which sets QOP to 0 indicating that the default QOP is
|
| 113 |
|
|
* requested.</p>
|
| 114 |
|
|
*
|
| 115 |
|
|
* @param privState The desired privacy state. "true" for privacy and
|
| 116 |
|
|
* "false" for integrity only.
|
| 117 |
|
|
*/
|
| 118 |
|
|
public MessageProp(boolean privState)
|
| 119 |
|
|
{
|
| 120 |
|
|
this(0, privState);
|
| 121 |
|
|
}
|
| 122 |
|
|
|
| 123 |
|
|
/**
|
| 124 |
|
|
* <p>Constructor which sets the values for the qop and privacy state.</p>
|
| 125 |
|
|
*
|
| 126 |
|
|
* @param qop The desired QOP. Use 0 to request a default QOP.
|
| 127 |
|
|
* @param privState The desired privacy state. "true" for privacy and
|
| 128 |
|
|
* "false" for integrity only.
|
| 129 |
|
|
*/
|
| 130 |
|
|
public MessageProp(int qop, boolean privState)
|
| 131 |
|
|
{
|
| 132 |
|
|
this.qopVal = qop;
|
| 133 |
|
|
this.privState = privState;
|
| 134 |
|
|
}
|
| 135 |
|
|
|
| 136 |
|
|
// Instance methods.
|
| 137 |
|
|
// -------------------------------------------------------------------------
|
| 138 |
|
|
|
| 139 |
|
|
/**
|
| 140 |
|
|
* Retrieves the QOP value.
|
| 141 |
|
|
*
|
| 142 |
|
|
* @return The QOP value.
|
| 143 |
|
|
*/
|
| 144 |
|
|
public int getQOP()
|
| 145 |
|
|
{
|
| 146 |
|
|
return qopVal;
|
| 147 |
|
|
}
|
| 148 |
|
|
|
| 149 |
|
|
/**
|
| 150 |
|
|
* Retrieves the privacy state.
|
| 151 |
|
|
*
|
| 152 |
|
|
* @return The privacy state.
|
| 153 |
|
|
*/
|
| 154 |
|
|
public boolean getPrivacy()
|
| 155 |
|
|
{
|
| 156 |
|
|
return privState;
|
| 157 |
|
|
}
|
| 158 |
|
|
|
| 159 |
|
|
/**
|
| 160 |
|
|
* Retrieves the minor status that the underlying mechanism might have
|
| 161 |
|
|
* set.
|
| 162 |
|
|
*
|
| 163 |
|
|
* @return The minor status.
|
| 164 |
|
|
*/
|
| 165 |
|
|
public int getMinorStatus()
|
| 166 |
|
|
{
|
| 167 |
|
|
return minorStatus;
|
| 168 |
|
|
}
|
| 169 |
|
|
|
| 170 |
|
|
/**
|
| 171 |
|
|
* Returns a string explaining the mechanism specific error code.
|
| 172 |
|
|
* <code>null</code> will be returned when no mechanism error code has
|
| 173 |
|
|
* been set.
|
| 174 |
|
|
*
|
| 175 |
|
|
* @return The minor status string.
|
| 176 |
|
|
*/
|
| 177 |
|
|
public String getMinorString()
|
| 178 |
|
|
{
|
| 179 |
|
|
return minorString;
|
| 180 |
|
|
}
|
| 181 |
|
|
|
| 182 |
|
|
/**
|
| 183 |
|
|
* Sets the QOP value.
|
| 184 |
|
|
*
|
| 185 |
|
|
* @param qopVal The QOP value to be set. Use 0 to request a default
|
| 186 |
|
|
* QOP value.
|
| 187 |
|
|
*/
|
| 188 |
|
|
public void setQOP(int qopVal)
|
| 189 |
|
|
{
|
| 190 |
|
|
this.qopVal = qopVal;
|
| 191 |
|
|
}
|
| 192 |
|
|
|
| 193 |
|
|
/**
|
| 194 |
|
|
* Sets the privacy state.
|
| 195 |
|
|
*
|
| 196 |
|
|
* @param privState The privacy state to set.
|
| 197 |
|
|
*/
|
| 198 |
|
|
public void setPrivacy(boolean privState)
|
| 199 |
|
|
{
|
| 200 |
|
|
this.privState = privState;
|
| 201 |
|
|
}
|
| 202 |
|
|
|
| 203 |
|
|
/**
|
| 204 |
|
|
* Returns "true" if this is a duplicate of an earlier token.
|
| 205 |
|
|
*
|
| 206 |
|
|
* @return True if this is a duplicate of an earlier token.
|
| 207 |
|
|
*/
|
| 208 |
|
|
public boolean isDuplicateToken()
|
| 209 |
|
|
{
|
| 210 |
|
|
return duplicate;
|
| 211 |
|
|
}
|
| 212 |
|
|
|
| 213 |
|
|
/**
|
| 214 |
|
|
* Returns "true" if the token's validity period has expired.
|
| 215 |
|
|
*
|
| 216 |
|
|
* @return True if the token's validity period has expired.
|
| 217 |
|
|
*/
|
| 218 |
|
|
public boolean isOldToken()
|
| 219 |
|
|
{
|
| 220 |
|
|
return old;
|
| 221 |
|
|
}
|
| 222 |
|
|
|
| 223 |
|
|
/**
|
| 224 |
|
|
* Returns "true" if a later token has already been processed.
|
| 225 |
|
|
*
|
| 226 |
|
|
* @return True if a later token has already been processed.
|
| 227 |
|
|
*/
|
| 228 |
|
|
public boolean isUnseqToken()
|
| 229 |
|
|
{
|
| 230 |
|
|
return unseq;
|
| 231 |
|
|
}
|
| 232 |
|
|
|
| 233 |
|
|
/**
|
| 234 |
|
|
* Returns "true" if an expected per-message token was not received.
|
| 235 |
|
|
*
|
| 236 |
|
|
* @return True if an expected per-message token was not received.
|
| 237 |
|
|
*/
|
| 238 |
|
|
public boolean isGapToken()
|
| 239 |
|
|
{
|
| 240 |
|
|
return gap;
|
| 241 |
|
|
}
|
| 242 |
|
|
|
| 243 |
|
|
/**
|
| 244 |
|
|
* This method sets the state for the supplementary information flags
|
| 245 |
|
|
* and the minor status in MessageProp. It is not used by the
|
| 246 |
|
|
* application but by the GSS implementation to return this information
|
| 247 |
|
|
* to the caller of a per-message context method.
|
| 248 |
|
|
*
|
| 249 |
|
|
* @param duplicate True if the token was a duplicate of an earlier
|
| 250 |
|
|
* token, false otherwise.
|
| 251 |
|
|
* @param old True if the token's validity period has expired,
|
| 252 |
|
|
* false otherwise.
|
| 253 |
|
|
* @param unseq True if a later token has already been processed,
|
| 254 |
|
|
* false otherwise.
|
| 255 |
|
|
* @param gap True if one or more predecessor tokens have not yet
|
| 256 |
|
|
* been successfully processed, false otherwise.
|
| 257 |
|
|
* @param minorStatus The integer minor status code that the underlying
|
| 258 |
|
|
* mechanism wants to set.
|
| 259 |
|
|
* @param minorString The textual representation of the minorStatus
|
| 260 |
|
|
* value.
|
| 261 |
|
|
*/
|
| 262 |
|
|
public void setSupplementaryStates(boolean duplicate, boolean old,
|
| 263 |
|
|
boolean unseq, boolean gap,
|
| 264 |
|
|
int minorStatus, String minorString)
|
| 265 |
|
|
{
|
| 266 |
|
|
this.duplicate = duplicate;
|
| 267 |
|
|
this.old = old;
|
| 268 |
|
|
this.unseq = unseq;
|
| 269 |
|
|
this.gap = gap;
|
| 270 |
|
|
this.minorStatus = minorStatus;
|
| 271 |
|
|
this.minorString = minorString;
|
| 272 |
|
|
}
|
| 273 |
|
|
}
|