code: public Principal getLocalPrincipal() {
  
          java.security.cert.Certificate[] certs = getLocalCertificates();
          if (certs != null) {
              return ((X500Principal)
                  ((X509Certificate)certs[0]).getSubjectX500Principal());
          } else {
              return null;
          }
      }
docs: Returns the principal that was sent to the server during handshaking.
  <P>
  Note: Subclasses should override this method. If not overridden, it
  will default to returning the X500Principal of the end-entity certificate
  that was sent to the server for certificate-based ciphersuites or,
  return null for non-certificate based ciphersuites, such as Kerberos.
  
  @return the principal sent to the server. 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.
  
  @throws IllegalStateException if this method is called before
  the connection has been established.
  
  @see #getLocalCertificates()
  @see #getPeerPrincipal()
  
  @since 1.5