< prev index next >

src/share/classes/sun/net/www/protocol/https/HttpsClient.java

Print this page
rev 1564 : 7090158: Networking Libraries don't build with javac -Werror
7125055: ContentHandler.getContent API changed in error
Summary: Minor changes to networking java files to remove warnings
Reviewed-by: chegar, weijun, hawtin, alanb
Contributed-by: kurchi.subhra.hazra@oracle.com, sasha_bu@hotmail.com
   1 /*
   2  * Copyright (c) 2001, 2010, 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


 562     {
 563         return session.getPeerCertificateChain();
 564     }
 565 
 566     /**
 567      * Returns the principal with which the server authenticated
 568      * itself, or throw a SSLPeerUnverifiedException if the
 569      * server did not authenticate.
 570      */
 571     Principal getPeerPrincipal()
 572             throws SSLPeerUnverifiedException
 573     {
 574         Principal principal;
 575         try {
 576             principal = session.getPeerPrincipal();
 577         } catch (AbstractMethodError e) {
 578             // if the provider does not support it, fallback to peer certs.
 579             // return the X500Principal of the end-entity cert.
 580             java.security.cert.Certificate[] certs =
 581                         session.getPeerCertificates();
 582             principal = (X500Principal)
 583                 ((X509Certificate)certs[0]).getSubjectX500Principal();
 584         }
 585         return principal;
 586     }
 587 
 588     /**
 589      * Returns the principal the client sent to the
 590      * server, or null if the client did not authenticate.
 591      */
 592     Principal getLocalPrincipal()
 593     {
 594         Principal principal;
 595         try {
 596             principal = session.getLocalPrincipal();
 597         } catch (AbstractMethodError e) {
 598             principal = null;
 599             // if the provider does not support it, fallback to local certs.
 600             // return the X500Principal of the end-entity cert.
 601             java.security.cert.Certificate[] certs =
 602                         session.getLocalCertificates();
 603             if (certs != null) {
 604                 principal = (X500Principal)
 605                     ((X509Certificate)certs[0]).getSubjectX500Principal();
 606             }
 607         }
 608         return principal;
 609     }
 610 
 611     /**
 612      * This method implements the SSL HandshakeCompleted callback,
 613      * remembering the resulting session so that it may be queried
 614      * for the current cipher suite and peer certificates.  Servers
 615      * sometimes re-initiate handshaking, so the session in use on
 616      * a given connection may change.  When sessions change, so may
 617      * peer identities and cipher suites.
 618      */
 619     @Override
 620     public void handshakeCompleted(HandshakeCompletedEvent event)
 621     {
 622         session = event.getSession();
 623     }
 624 
 625     /**


   1 /*
   2  * Copyright (c) 2001, 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


 562     {
 563         return session.getPeerCertificateChain();
 564     }
 565 
 566     /**
 567      * Returns the principal with which the server authenticated
 568      * itself, or throw a SSLPeerUnverifiedException if the
 569      * server did not authenticate.
 570      */
 571     Principal getPeerPrincipal()
 572             throws SSLPeerUnverifiedException
 573     {
 574         Principal principal;
 575         try {
 576             principal = session.getPeerPrincipal();
 577         } catch (AbstractMethodError e) {
 578             // if the provider does not support it, fallback to peer certs.
 579             // return the X500Principal of the end-entity cert.
 580             java.security.cert.Certificate[] certs =
 581                         session.getPeerCertificates();
 582             principal = ((X509Certificate)certs[0]).getSubjectX500Principal();

 583         }
 584         return principal;
 585     }
 586 
 587     /**
 588      * Returns the principal the client sent to the
 589      * server, or null if the client did not authenticate.
 590      */
 591     Principal getLocalPrincipal()
 592     {
 593         Principal principal;
 594         try {
 595             principal = session.getLocalPrincipal();
 596         } catch (AbstractMethodError e) {
 597             principal = null;
 598             // if the provider does not support it, fallback to local certs.
 599             // return the X500Principal of the end-entity cert.
 600             java.security.cert.Certificate[] certs =
 601                         session.getLocalCertificates();
 602             if (certs != null) {
 603                 principal = ((X509Certificate)certs[0]).getSubjectX500Principal();

 604             }
 605         }
 606         return principal;
 607     }
 608 
 609     /**
 610      * This method implements the SSL HandshakeCompleted callback,
 611      * remembering the resulting session so that it may be queried
 612      * for the current cipher suite and peer certificates.  Servers
 613      * sometimes re-initiate handshaking, so the session in use on
 614      * a given connection may change.  When sessions change, so may
 615      * peer identities and cipher suites.
 616      */
 617     @Override
 618     public void handshakeCompleted(HandshakeCompletedEvent event)
 619     {
 620         session = event.getSession();
 621     }
 622 
 623     /**


< prev index next >