01: package com.sun.portal.proxylet.util;
02:
03: import com.iplanet.sso.SSOToken;
04: import com.iplanet.sso.SSOTokenManager;
05: import com.iplanet.sso.SSOException;
06:
07: import javax.servlet.http.HttpServletRequest;
08: import java.util.ResourceBundle;
09: import java.util.Locale;
10: import java.util.MissingResourceException;
11: import java.util.logging.Logger;
12:
13: /**
14: * User: vr121038
15: * Date: Jan 13, 2004
16: * Time: 12:20:09 PM
17: */
18: public class SSOUtil {
19:
20: SSOToken ssoToken = null;
21: private Logger logger = null;
22: UserAttributes userAttrs = null;
23:
24: public SSOUtil(HttpServletRequest req) {
25: logger = Logger.getLogger("com.sun.portal.sra.proxylet");
26: try {
27: ssoToken = SSOTokenManager.getInstance()
28: .createSSOToken(req);
29: userAttrs = new UserAttributes(ssoToken);
30: } catch (SSOException ssoe) {
31: logger
32: .info("SSOUtil: Unable to create ssoToken -> "
33: + ssoe);
34: }
35:
36: }
37:
38: /*
39: * returns SSOToken
40: */
41: public SSOToken getSSOToken() {
42: return ssoToken;
43: }
44:
45: public Locale getLocale() {
46: Locale locale = Locale.ENGLISH;
47: try {
48: String localeStr = ssoToken.getProperty("Locale");
49: locale = com.iplanet.am.util.Locale.getLocale(localeStr);
50: } catch (SSOException ssoe) {
51: logger.info("SSOUtil: Unable to get the locale -> "
52: + ssoe.getMessage());
53: }
54: return locale;
55: }
56:
57: public ResourceBundle getResourceBundle(String resource) {
58: ResourceBundle rb = null;
59: try {
60: rb = ResourceBundle.getBundle(resource, getLocale());
61: } catch (MissingResourceException mre) {
62: logger.info("Missing Resource:" + mre);
63: }
64: return rb;
65: }
66: }
|