< prev index next >

src/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.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


 148         Principal principal;
 149         try {
 150             principal = session.getPeerPrincipal();
 151         } catch (AbstractMethodError e) {
 152             // if the provider does not support it, return null, since
 153             // we need it only for Kerberos.
 154             principal = null;
 155         }
 156         return principal;
 157     }
 158 
 159     /*
 160      * Extract the name of the SSL server from the certificate.
 161      *
 162      * Note this code is essentially a subset of the hostname extraction
 163      * code in HostnameChecker.
 164      */
 165     private static String getServername(X509Certificate peerCert) {
 166         try {
 167             // compare to subjectAltNames if dnsName is present
 168             Collection subjAltNames = peerCert.getSubjectAlternativeNames();
 169             if (subjAltNames != null) {
 170                 for (Iterator itr = subjAltNames.iterator(); itr.hasNext(); ) {
 171                     List next = (List)itr.next();
 172                     if (((Integer)next.get(0)).intValue() == 2) {
 173                         // compare dNSName with host in url
 174                         String dnsName = ((String)next.get(1));
 175                         return dnsName;
 176                     }
 177                 }
 178             }
 179 
 180             // else check against common name in the subject field
 181             X500Name subject = HostnameChecker.getSubjectX500Name(peerCert);
 182 
 183             DerValue derValue = subject.findMostSpecificAttribute
 184                                                 (X500Name.commonName_oid);
 185             if (derValue != null) {
 186                 try {
 187                     String name = derValue.getAsString();
 188                     return name;
 189                 } catch (IOException e) {
 190                     // ignore
 191                 }


 148         Principal principal;
 149         try {
 150             principal = session.getPeerPrincipal();
 151         } catch (AbstractMethodError e) {
 152             // if the provider does not support it, return null, since
 153             // we need it only for Kerberos.
 154             principal = null;
 155         }
 156         return principal;
 157     }
 158 
 159     /*
 160      * Extract the name of the SSL server from the certificate.
 161      *
 162      * Note this code is essentially a subset of the hostname extraction
 163      * code in HostnameChecker.
 164      */
 165     private static String getServername(X509Certificate peerCert) {
 166         try {
 167             // compare to subjectAltNames if dnsName is present
 168             Collection<List<?>> subjAltNames = peerCert.getSubjectAlternativeNames();
 169             if (subjAltNames != null) {
 170                 for (Iterator<List<?>> itr = subjAltNames.iterator(); itr.hasNext(); ) {
 171                     List<?> next = itr.next();
 172                     if (((Integer)next.get(0)).intValue() == 2) {
 173                         // compare dNSName with host in url
 174                         String dnsName = ((String)next.get(1));
 175                         return dnsName;
 176                     }
 177                 }
 178             }
 179 
 180             // else check against common name in the subject field
 181             X500Name subject = HostnameChecker.getSubjectX500Name(peerCert);
 182 
 183             DerValue derValue = subject.findMostSpecificAttribute
 184                                                 (X500Name.commonName_oid);
 185             if (derValue != null) {
 186                 try {
 187                     String name = derValue.getAsString();
 188                     return name;
 189                 } catch (IOException e) {
 190                     // ignore
 191                 }
< prev index next >