Path: blob/master/src/java.security.jgss/share/classes/sun/security/jgss/GSSExceptionImpl.java
41159 views
/*1* Copyright (c) 2000, 2006, 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 sun.security.jgss;2627import org.ietf.jgss.*;2829/**30* This class helps overcome a limitation of the org.ietf.jgss.GSSException31* class that does not allow the thrower to set a string corresponding to32* the major code.33*/34public class GSSExceptionImpl extends GSSException {3536private static final long serialVersionUID = 4251197939069005575L;3738private String majorMessage;3940/**41* A constructor that takes the majorCode as well as the mech oid that42* will be appended to the standard message defined in its super class.43*/44GSSExceptionImpl(int majorCode, Oid mech) {45super(majorCode);46this.majorMessage = super.getMajorString() + ": " + mech;47}4849/**50* A constructor that takes the majorCode as well as the message that51* corresponds to it.52*/53public GSSExceptionImpl(int majorCode, String majorMessage) {54super(majorCode);55this.majorMessage = majorMessage;56}5758/**59* A constructor that takes the majorCode and the exception cause.60*/61public GSSExceptionImpl(int majorCode, Exception cause) {62super(majorCode);63initCause(cause);64}6566/**67* A constructor that takes the majorCode, the message that68* corresponds to it, and the exception cause.69*/70public GSSExceptionImpl(int majorCode, String majorMessage,71Exception cause) {72this(majorCode, majorMessage);73initCause(cause);74}7576/**77* Returns the message that was embedded in this object, otherwise it78* returns the default message that an org.ietf.jgss.GSSException79* generates.80*/81public String getMessage() {82if (majorMessage != null)83return majorMessage;84else85return super.getMessage();86}8788}899091