1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
/* * @(#)MessageProp.java 1.10 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package org.ietf.jgss; /** * This is a utility class used within the per-message GSSContext * methods to convey per-message properties.<p> * * When used with the GSSContext interface's wrap and getMIC methods, an * instance of this class is used to indicate the desired * Quality-of-Protection (QOP) and to request if confidentiality services * are to be applied to caller supplied data (wrap only). To request * default QOP, the value of 0 should be used for QOP.<p> * * When used with the unwrap and verifyMIC methods of the GSSContext * interface, an instance of this class will be used to indicate the * applied QOP and confidentiality services over the supplied message. * In the case of verifyMIC, the confidentiality state will always be * <code>false</code>. Upon return from these methods, this object will also * contain any supplementary status values applicable to the processed * token. The supplementary status values can indicate old tokens, out * of sequence tokens, gap tokens or duplicate tokens.<p> * * @see GSSContext#wrap * @see GSSContext#unwrap * @see GSSContext#getMIC * @see GSSContext#verifyMIC * * @author Mayank Upadhyay * @version 1.10, 11/17/05 * @since 1.4 */ public class MessageProp { private boolean privacyState; private int qop; private boolean dupToken; private boolean oldToken; private boolean unseqToken; private boolean gapToken; private int minorStatus; private String minorString; /** * Constructor which sets the desired privacy state. The QOP value used * is 0. * * @param privState the privacy (i.e. confidentiality) state */ public MessageProp(boolean privState) { this(0, privState); } /** * Constructor which sets the values for the qop and privacy state. * * @param qop the QOP value * @param privState the privacy (i.e. confidentiality) state */ public MessageProp(int qop, boolean privState) { this.qop = qop; this.privacyState = privState; resetStatusValues(); } /** * Retrieves the QOP value. * * @return an int representing the QOP value * @see #setQOP */ public int getQOP() { return qop; } /** * Retrieves the privacy state. * * @return true if the privacy (i.e., confidentiality) state is true, * false otherwise. * @see #setPrivacy */ public boolean getPrivacy() { return (privacyState); } /** * Sets the QOP value. * * @param qop the int value to set the QOP to * @see #getQOP */ public void setQOP(int qop) { this.qop = qop; } /** * Sets the privacy state. * * @param privState true is the privacy (i.e., confidentiality) state * is true, false otherwise. * @see #getPrivacy */ public void setPrivacy(boolean privState) { this.privacyState = privState; } /** * Tests if this is a duplicate of an earlier token. * * @return true if this is a duplicate, false otherwise. */ public boolean isDuplicateToken() { return dupToken; } /** * Tests if this token's validity period has expired, i.e., the token * is too old to be checked for duplication. * * @return true if the token's validity period has expired, false * otherwise. */ public boolean isOldToken() { return oldToken; } /** * Tests if a later token had already been processed. * * @return true if a later token had already been processed, false otherwise. */ public boolean isUnseqToken() { return unseqToken; } /** * Tests if an expected token was not received, i.e., one or more * predecessor tokens have not yet been successfully processed. * * @return true if an expected per-message token was not received, * false otherwise. */ public boolean isGapToken() { return gapToken; } /** * Retrieves the minor status code that the underlying mechanism might * have set for this per-message operation. * * @return the int minor status */ public int getMinorStatus(){ return minorStatus; } /** * Retrieves a string explaining the minor status code. * * @return a String corresponding to the minor status * code. <code>null</code> will be returned when no minor status code * has been set. */ public String getMinorString(){ return minorString; } /** * This method sets the state for the supplementary information flags * and the minor status in MessageProp. It is not used by the * application but by the GSS implementation to return this information * to the caller of a per-message context method. * * @param duplicate true if the token was a duplicate of an earlier * token, false otherwise * @param old true if the token's validity period has expired, false * otherwise * @param unseq true if a later token has already been processed, false * otherwise * @param gap true if one or more predecessor tokens have not yet been * successfully processed, false otherwise * @param minorStatus the int minor status code for the per-message * operation * @param minorString the textual representation of the minorStatus value */ public void setSupplementaryStates(boolean duplicate, boolean old, boolean unseq, boolean gap, int minorStatus, String minorString) { this.dupToken = duplicate; this.oldToken = old; this.unseqToken = unseq; this.gapToken = gap; this.minorStatus = minorStatus; this.minorString = minorString; } /** * Resets the supplementary status values to false. */ private void resetStatusValues() { dupToken = false; oldToken = false; unseqToken = false; gapToken = false; minorStatus = 0; minorString = null; } }