Path: blob/master/src/java.security.jgss/share/classes/sun/security/jgss/spnego/SpNegoCredElement.java
41161 views
/*1* Copyright (c) 2005, 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*/24package sun.security.jgss.spnego;2526import org.ietf.jgss.*;27import java.security.Provider;28import sun.security.jgss.GSSUtil;29import sun.security.jgss.spi.GSSNameSpi;30import sun.security.jgss.spi.GSSCredentialSpi;3132/**33* This class is the cred element implementation for SPNEGO mech.34* NOTE: The current implementation can only support one mechanism.35* This should be changed once multi-mechanism support is needed.36*37* @author Valerie Peng38* @since 1.639*/40public class SpNegoCredElement implements GSSCredentialSpi {4142private GSSCredentialSpi cred = null;4344public SpNegoCredElement(GSSCredentialSpi cred) throws GSSException {45this.cred = cred;46}4748Oid getInternalMech() {49return cred.getMechanism();50}5152// Used by GSSUtil.populateCredentials()53public GSSCredentialSpi getInternalCred() {54return cred;55}5657public Provider getProvider() {58return SpNegoMechFactory.PROVIDER;59}6061public void dispose() throws GSSException {62cred.dispose();63}6465public GSSNameSpi getName() throws GSSException {66return cred.getName();67}6869public int getInitLifetime() throws GSSException {70return cred.getInitLifetime();71}7273public int getAcceptLifetime() throws GSSException {74return cred.getAcceptLifetime();75}7677public boolean isInitiatorCredential() throws GSSException {78return cred.isInitiatorCredential();79}8081public boolean isAcceptorCredential() throws GSSException {82return cred.isAcceptorCredential();83}8485public Oid getMechanism() {86return GSSUtil.GSS_SPNEGO_MECH_OID;87}8889@Override90public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException {91return cred.impersonate(name);92}93}949596