TrustedSignonReplaceSample.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: CAMAAA
  5. *
  6. * (C) Copyright IBM Corp. 2005, 2012
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
  9. * IBM Corp.
  10. */
  11. import com.cognos.CAM_AAA.authentication.INamespaceTrustedSignonProvider;
  12. import com.cognos.CAM_AAA.authentication.ITrustedSignonRequest;
  13. import com.cognos.CAM_AAA.authentication.SystemRecoverableException;
  14. import com.cognos.CAM_AAA.authentication.UnrecoverableException;
  15. import com.cognos.CAM_AAA.authentication.UserRecoverableException;
  16. public class TrustedSignonReplaceSample
  17. extends Namespace
  18. implements INamespaceTrustedSignonProvider
  19. {
  20. public TrustedSignonReplaceSample()
  21. {
  22. super();
  23. }
  24. public void processLogonRequest(ITrustedSignonRequest theRequest)
  25. throws
  26. UserRecoverableException,
  27. SystemRecoverableException,
  28. UnrecoverableException
  29. {
  30. String[] username = null;
  31. // 1 - Look for trusted credentials
  32. username = theRequest.getTrustedEnvVarValue("REMOTE_USER");
  33. if (username == null)
  34. {
  35. String[] theRequestedVars = new String[] {"REMOTE_USER"};
  36. SystemRecoverableException e = new SystemRecoverableException(
  37. "Requesting trusted REMOTE_USER.",
  38. theRequestedVars);
  39. throw e;
  40. }
  41. int slashPosition = username[0].indexOf('\\');
  42. if (slashPosition > 0)
  43. {
  44. username[0] = username[0].substring(slashPosition+1);
  45. }
  46. // The namespace ID of the authentication namespace to use. For the purpose of this sample, it is hardcoded.
  47. theRequest.setNamespaceID( "TS" );
  48. //
  49. // Set the trusted environment variable REMOTE_USER to achieve SSO against the TS namespace.
  50. //
  51. theRequest.removeTrustedEnvVar( "REMOTE_USER" );
  52. theRequest.addTrustedEnvVar( "REMOTE_USER", username[0] );
  53. }
  54. }