Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/security/auth/NTNumericCredential.java
38924 views
/*1* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.security.auth;2627/**28* <p> This class abstracts an NT security token29* and provides a mechanism to do same-process security impersonation.30*31*/3233@jdk.Exported34public class NTNumericCredential {3536private long impersonationToken;3738/**39* Create an <code>NTNumericCredential</code> with an integer value.40*41* <p>42*43* @param token the Windows NT security token for this user. <p>44*45*/46public NTNumericCredential(long token) {47this.impersonationToken = token;48}4950/**51* Return an integer representation of this52* <code>NTNumericCredential</code>.53*54* <p>55*56* @return an integer representation of this57* <code>NTNumericCredential</code>.58*/59public long getToken() {60return impersonationToken;61}6263/**64* Return a string representation of this <code>NTNumericCredential</code>.65*66* <p>67*68* @return a string representation of this <code>NTNumericCredential</code>.69*/70public String toString() {71java.text.MessageFormat form = new java.text.MessageFormat72(sun.security.util.ResourcesMgr.getString73("NTNumericCredential.name",74"sun.security.util.AuthResources"));75Object[] source = {Long.toString(impersonationToken)};76return form.format(source);77}7879/**80* Compares the specified Object with this <code>NTNumericCredential</code>81* for equality. Returns true if the given object is also a82* <code>NTNumericCredential</code> and the two NTNumericCredentials83* represent the same NT security token.84*85* <p>86*87* @param o Object to be compared for equality with this88* <code>NTNumericCredential</code>.89*90* @return true if the specified Object is equal equal to this91* <code>NTNumericCredential</code>.92*/93public boolean equals(Object o) {94if (o == null)95return false;9697if (this == o)98return true;99100if (!(o instanceof NTNumericCredential))101return false;102NTNumericCredential that = (NTNumericCredential)o;103104if (impersonationToken == that.getToken())105return true;106return false;107}108109/**110* Return a hash code for this <code>NTNumericCredential</code>.111*112* <p>113*114* @return a hash code for this <code>NTNumericCredential</code>.115*/116public int hashCode() {117return (int)this.impersonationToken;118}119}120121122