code: public Principal getLocalPrincipal()
      {
          Principal principal;
          try {
              principal = session.getLocalPrincipal();
          } catch (AbstractMethodError e) {
              principal = null;
              // if the provider does not support it, fallback to local certs.
              // return the X500Principal of the end-entity cert.
              Certificate[] certs = getLocalCertificates();
              if (certs != null) {
                  principal =
                          ((X509Certificate)certs[0]).getSubjectX500Principal();
              }
          }
          return principal;
      }
docs: Returns the principal that was sent to the peer during handshaking.
  
  @return the principal sent to the peer. Returns an X500Principal
  of the end-entity certificate for X509-based cipher suites, and
  KerberosPrincipal for Kerberos cipher suites. If no principal was
  sent, then null is returned.
  
  @see #getLocalCertificates()
  @see #getPeerPrincipal()
  
  @since 1.5