1. /*
  2. * @(#)GSSUtil.java 1.9 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.security.jgss;
  8. import javax.security.auth.Subject;
  9. import org.ietf.jgss.GSSName;
  10. import org.ietf.jgss.GSSCredential;
  11. /**
  12. * GSS-API Utilities for using in conjunction with Sun Microsystem's
  13. * implementation of Java GSS-API.
  14. */
  15. public class GSSUtil {
  16. /**
  17. * Use this method to convert a GSSName and GSSCredential into a
  18. * Subject. Typically this would be done by a server that wants to
  19. * impersonate a client thread at the Java level by setting a client
  20. * Subject in the current access control context. If the server is merely
  21. * interested in using a principal based policy in its local JVM, then
  22. * it only needs to provide the GSSName of the client.
  23. *
  24. * The elements from the GSSName are placed in the principals set of this
  25. * Subject and those from the GSSCredential are placed in the private
  26. * credentials set of the Subject. Any Kerberos specific elements that
  27. * are added to the subject will be instances of the standard Kerberos
  28. * implementation classes defined in javax.security.auth.kerberos.
  29. *
  30. * @return a Subject with the entries that contain elements from the
  31. * given GSSName and GSSCredential.
  32. *
  33. * @param principals a GSSName containing one or more mechanism specific
  34. * representations of the same entity. These mechanism specific
  35. * representations will be populated in the returned Subject's principal
  36. * set.
  37. *
  38. * @param credentials a GSSCredential containing one or more mechanism
  39. * specific credentials for the same entity. These mechanism specific
  40. * credentials will be populated in the returned Subject's private
  41. * credential set. Passing in a value of null will imply that the private
  42. * credential set should be left empty.
  43. */
  44. public static Subject createSubject(GSSName principals,
  45. GSSCredential credentials) {
  46. return sun.security.jgss.GSSUtil.getSubject(principals,
  47. credentials);
  48. }
  49. }