/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
private boolean destroyed = false;
/*
* We store all elements in a hashtable, using <oid, usage> as the
* key. This makes it easy to locate the specific kind of credential we
* need. The implementation needs to be optimized for the case where
* there is just one element (tempCred).
*/
// XXX Optimization for single mech usage
throws GSSException {
}
throws GSSException {
}
throws GSSException {
boolean defaultList = false;
defaultList = true;
}
try {
} catch (GSSException e) {
if (defaultList) {
// Try the next mechanism
+ mechs[i]);
//e.printStackTrace();
} else throw e; // else try the next mechanism
}
}
}
if (mechElement.isInitiatorCredential()) {
if (mechElement.isAcceptorCredential()) {
} else {
}
}
usage);
}
this.gssManager = gssManager;
}
if (!destroyed) {
while (values.hasMoreElements()) {
}
destroyed = true;
}
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
}
}
}
}
/**
* Returns the remaining lifetime of this credential. The remaining
* lifetime is defined as the minimum lifetime, either for initiate or
* for accept, across all elements contained in it. Not terribly
* useful, but required by GSS-API.
*/
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
int min = INDEFINITE_LIFETIME;
e.hasMoreElements(); ) {
tempKey = e.nextElement();
else {
}
}
return min;
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
boolean found = false;
int max = 0;
found = true;
}
found = true;
}
if (!found) {
}
return max;
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
boolean found = false;
int max = 0;
found = true;
}
found = true;
}
if (!found) {
}
return max;
}
/**
* Returns the usage mode for this credential. Returns
* INITIATE_AND_ACCEPT if any one element contained in it supports
* INITIATE_AND_ACCEPT or if two different elements exist where one
* support INITIATE_ONLY and the other supports ACCEPT_ONLY.
*/
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
boolean initiate = false;
boolean accept = false;
e.hasMoreElements(); ) {
tempKey = e.nextElement();
initiate = true;
accept = true;
else
return INITIATE_AND_ACCEPT;
}
if (initiate) {
if (accept)
return INITIATE_AND_ACCEPT;
else
return INITIATE_ONLY;
} else
return ACCEPT_ONLY;
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
boolean initiate = false;
boolean accept = false;
initiate = true;
}
accept = true;
}
initiate = true;
accept = true;
}
return GSSCredential.INITIATE_AND_ACCEPT;
else if (initiate)
return GSSCredential.INITIATE_ONLY;
else if (accept)
return GSSCredential.ACCEPT_ONLY;
else {
}
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
e.hasMoreElements(); ) {
}
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
"Duplicate element found: " +
}
// XXX If not instance of GSSNameImpl then throw exception
// Application mixing GSS implementations
mech,
usage);
/*
* Not all mechanisms support the concept of one credential element
* that can be used for both initiating and accepting a context. In
* the event that an application requests usage INITIATE_AND_ACCEPT
* for a credential from such a mechanism, the GSS framework will
* need to obtain two different credential elements from the
* mechanism, one that will have usage INITIATE_ONLY and another
* that will have usage ACCEPT_ONLY. The mechanism will help the
* GSS-API realize this by returning a credential element with
* usage INITIATE_ONLY or ACCEPT_ONLY prompting it to make another
* call to getCredentialElement, this time with the other usage
* mode.
*/
(!tempCred.isAcceptorCredential() ||
!tempCred.isInitiatorCredential())) {
int currentUsage;
int desiredUsage;
if (!tempCred.isInitiatorCredential()) {
} else {
}
mech,
} else {
}
}
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
if (this == another) {
return true;
}
if (!(another instanceof GSSCredentialImpl)) {
return false;
}
// NOTE: The specification does not define the criteria to compare
// credentials.
/*
* XXX
* The RFC says: "Tests if this GSSCredential refers to the same
* entity as the supplied object. The two credentials must be
* acquired over the same mechanisms and must refer to the same
* principal. Returns "true" if the two GSSCredentials refer to
* the same entity; "false" otherwise."
*
* Well, when do two credentials refer to the same principal? Do
* they need to have one GSSName in common for the different
* GSSName's that the credential elements return? Or do all
* GSSName's have to be in common when the names are exported with
* their respective mechanisms for the credential elements?
*/
return false;
}
/**
* Returns a hashcode value for this GSSCredential.
*
* @return a hashCode value
*/
public int hashCode() {
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
// NOTE: The specification does not define the criteria to compare
// credentials.
/*
* XXX
* Decide on a criteria for equals first then do this.
*/
return 1;
}
/**
* Returns the specified mechanism's credential-element.
*
* @param mechOid - the oid for mechanism to retrieve
* @param throwExcep - boolean indicating if the function is
* to throw exception or return null when element is not
* found.
* @return mechanism credential object
* @exception GSSException of invalid mechanism
*/
throws GSSException {
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
/*
* First see if the default mechanism satisfies the
* desired usage.
*/
/*
* Now just return any element that satisfies the
* desired usage.
*/
break;
} // for loop
}
}
} else {
if (initiate)
else
}
}
"No credential found for: " +
return element;
}
while (values.hasMoreElements()) {
}
return retVal;
}
} else {
}
return displayString;
}
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
try {
" Initiate" : "");
" Accept" : "");
} catch (GSSException e) {
// skip to next element
}
}
}
static class SearchKey {
}
return mechOid;
}
public int getUsage() {
return usage;
}
return false;
}
public int hashCode() {
}
}
}