< prev index next >

src/share/classes/sun/security/jgss/wrapper/NativeGSSFactory.java

Print this page
rev 1387 : 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
Reviewed-by: xuelei, mullan
Contributed-by: alexandre.boulgakov@oracle.com
   1 /*
   2  * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  96     }
  97 
  98     public GSSCredentialSpi getCredentialElement(GSSNameSpi name,
  99                                                  int initLifetime,
 100                                                  int acceptLifetime,
 101                                                  int usage)
 102         throws GSSException {
 103         GSSNameElement nname = null;
 104         if (name != null && !(name instanceof GSSNameElement)) {
 105             nname = (GSSNameElement)
 106                 getNameElement(name.toString(), name.getStringNameType());
 107         } else nname = (GSSNameElement) name;
 108 
 109         if (usage == GSSCredential.INITIATE_AND_ACCEPT) {
 110             // Force separate acqusition of cred element since
 111             // MIT's impl does not correctly report NO_CRED error.
 112             usage = GSSCredential.INITIATE_ONLY;
 113         }
 114 
 115         GSSCredElement credElement =
 116             getCredFromSubject((GSSNameElement) nname,
 117                                (usage == GSSCredential.INITIATE_ONLY));
 118 
 119         if (credElement == null) {
 120             // No cred in the Subject
 121             if (usage == GSSCredential.INITIATE_ONLY) {
 122                 credElement = new GSSCredElement(nname, initLifetime,
 123                                                  usage, cStub);
 124             } else if (usage == GSSCredential.ACCEPT_ONLY) {
 125                 if (nname == null) {
 126                     nname = GSSNameElement.DEF_ACCEPTOR;
 127                 }
 128                 credElement = new GSSCredElement(nname, acceptLifetime,
 129                                                  usage, cStub);
 130             } else {
 131                 throw new GSSException(GSSException.FAILURE, -1,
 132                                        "Unknown usage mode requested");
 133             }
 134         }
 135         return credElement;
 136     }
 137 


   1 /*
   2  * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  96     }
  97 
  98     public GSSCredentialSpi getCredentialElement(GSSNameSpi name,
  99                                                  int initLifetime,
 100                                                  int acceptLifetime,
 101                                                  int usage)
 102         throws GSSException {
 103         GSSNameElement nname = null;
 104         if (name != null && !(name instanceof GSSNameElement)) {
 105             nname = (GSSNameElement)
 106                 getNameElement(name.toString(), name.getStringNameType());
 107         } else nname = (GSSNameElement) name;
 108 
 109         if (usage == GSSCredential.INITIATE_AND_ACCEPT) {
 110             // Force separate acqusition of cred element since
 111             // MIT's impl does not correctly report NO_CRED error.
 112             usage = GSSCredential.INITIATE_ONLY;
 113         }
 114 
 115         GSSCredElement credElement =
 116             getCredFromSubject(nname, (usage == GSSCredential.INITIATE_ONLY));

 117 
 118         if (credElement == null) {
 119             // No cred in the Subject
 120             if (usage == GSSCredential.INITIATE_ONLY) {
 121                 credElement = new GSSCredElement(nname, initLifetime,
 122                                                  usage, cStub);
 123             } else if (usage == GSSCredential.ACCEPT_ONLY) {
 124                 if (nname == null) {
 125                     nname = GSSNameElement.DEF_ACCEPTOR;
 126                 }
 127                 credElement = new GSSCredElement(nname, acceptLifetime,
 128                                                  usage, cStub);
 129             } else {
 130                 throw new GSSException(GSSException.FAILURE, -1,
 131                                        "Unknown usage mode requested");
 132             }
 133         }
 134         return credElement;
 135     }
 136 


< prev index next >