code: @Function
      public static GSSContext createServerGSSContext() {
          System.out.println("createServerGSSContext()...");
          try {
              final GSSManager manager = GSSManager.getInstance();
  
              //
              // Create server credentials to accept kerberos tokens.  This should
              // make use of the sun.security.krb5.principal system property to
              // authenticate with the KDC.
              //
              GSSCredential serverCreds;
              try {
                  serverCreds = Subject.doAs(new Subject(), new PrivilegedExceptionAction<GSSCredential>() {
                      public GSSCredential run() throws GSSException {
                          return manager.createCredential(null, GSSCredential.INDEFINITE_LIFETIME, krb5Oid,
                                  GSSCredential.ACCEPT_ONLY);
                      }
                  });
              } catch (PrivilegedActionException e) {
                  throw new RuntimeException("Exception creating server credentials", e);
              }
  
              //
              // Create the GSSContext used to process requests from clients.  The client
              // requets should use Kerberos since the server credentials are Kerberos
              // based.
              //
              GSSContext retVal = manager.createContext(serverCreds);
              System.out.println("createServerGSSContext(), context: " + retVal);
              return retVal;
          } catch (GSSException ex) {
              System.out.println("createServerGSSContext(), finished with exception");
              throw new RuntimeException("Exception creating server GSSContext", ex);
          }
      }
docs: Create a GSS Context not tied to any server name.  Peers acting as a server
  create their context this way.
  @return the newly created GSS Context