TrustedSignonSample.java 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 TrustedSignonSample
  17. extends Namespace
  18. implements INamespaceTrustedSignonProvider
  19. {
  20. public TrustedSignonSample()
  21. {
  22. super();
  23. }
  24. public void processLogonRequest(ITrustedSignonRequest theRequest)
  25. throws
  26. UserRecoverableException,
  27. SystemRecoverableException,
  28. UnrecoverableException
  29. {
  30. String cookieValue[] = null;
  31. cookieValue = theRequest.getCookieValue( "TRUSTED_SIGNON_USER" );
  32. if( cookieValue == null )
  33. {
  34. throw new UnrecoverableException( "Authentication error", "The user is not authenticated or the cookie TRUSTED_SIGNON_USER is not set");
  35. }
  36. // The namespace ID of the authentication namespace to use. For the purpose of this sample, it is hardcoded.
  37. theRequest.setNamespaceID( "TS" );
  38. //
  39. // Set the trusted environment variable REMOTE_USER to achieve SSO against the TS namespace.
  40. //
  41. theRequest.removeTrustedEnvVar( "REMOTE_USER" );
  42. theRequest.addTrustedEnvVar( "REMOTE_USER", cookieValue[0] );
  43. //
  44. // The following are required because the NTLM provider triggers on those to enable NTCR.
  45. //
  46. theRequest.removeEnvVar( "AUTH_TYPE" );
  47. theRequest.addEnvVar( "AUTH_TYPE", "NTLM" );
  48. theRequest.removeEnvVar( "REMOTE_USER" );
  49. theRequest.addEnvVar( "REMOTE_USER", cookieValue[0] );
  50. }
  51. }