f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemaypackage com.sun.identity.console.task;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpottsimport java.text.MessageFormat;
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpottsimport java.util.Set;
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpottsimport javax.servlet.http.HttpServletRequest;
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.iplanet.jato.view.View;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.iplanet.jato.view.event.ChildContentDisplayEvent;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.iplanet.jato.view.event.DisplayEvent;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.base.AMPrimaryMastHeadViewBean;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.base.AMPropertySheet;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.base.model.AMConsoleException;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.base.model.AMModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.base.model.AMPropertySheetModel;
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpottsimport com.sun.identity.console.task.model.OAuth2Model;
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpottsimport com.sun.identity.console.task.model.OAuth2ModelImpl;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.identity.console.task.model.TaskModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.web.ui.model.CCActionTableModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.web.ui.model.CCPageTitleModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.web.ui.view.alert.CCAlert;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.web.ui.view.html.CCDropDownMenu;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemayimport com.sun.web.ui.view.pagetitle.CCPageTitle;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemaypublic class ConfigureOAuth2ViewBean
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay extends AMPrimaryMastHeadViewBean
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay{
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay public static final String DEFAULT_DISPLAY_URL =
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay "/console/task/ConfigureOAuth2.jsp";
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private static final String PAGETITLE = "pgtitle";
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private static final String PROPERTY_ATTRIBUTE = "propertyAttributes";
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private static final String REALM = "tfRealm";
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts private static final String TITLE_MESSAGE = "configure.oauth2profile.title.message";
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private CCPageTitleModel ptModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private CCActionTableModel tableModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private AMPropertySheetModel propertySheetModel;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay //public void forwardTo(RequestContext rc) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay //}
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay public ConfigureOAuth2ViewBean() {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay super("ConfigureOAuth2");
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay setDefaultDisplayURL(DEFAULT_DISPLAY_URL);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay createPageTitleModel();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay createPropertyModel();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay registerChildren();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay protected void registerChildren() {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay //ptModel.registerChildren(this);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay propertySheetModel.registerChildren(this);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay registerChild(PAGETITLE, CCPageTitle.class);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay super.registerChildren();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay protected View createChild(String name) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay View view = null;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay if (name.equals(PAGETITLE)) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay view = new CCPageTitle(this, ptModel, name);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay } else if (ptModel.isChildSupported(name)) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay view = ptModel.createChild(this, name);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay } else if (name.equals(PROPERTY_ATTRIBUTE)) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay view = new AMPropertySheet(this, propertySheetModel, name);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay } else if (propertySheetModel.isChildSupported(name)) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay view = propertySheetModel.createChild(this, name, getModel());
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay } else {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay view = super.createChild(name);
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay return view;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private void createPageTitleModel() {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay ptModel = new CCPageTitleModel(
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay getClass().getClassLoader().getResourceAsStream(
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay "com/sun/identity/console/twoBtnsPageTitle.xml"));
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay ptModel.setValue("button1", "button.create");
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay ptModel.setValue("button2", "button.cancel");
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay private void createPropertyModel() {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay propertySheetModel = new AMPropertySheetModel(
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay getClass().getClassLoader().getResourceAsStream(
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay "com/sun/identity/console/propertyConfigureOAuth2.xml"));
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay propertySheetModel.clear();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay protected AMModel getModelInternal() {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay HttpServletRequest req = getRequestContext().getRequest();
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts return new OAuth2ModelImpl(req, getPageSessionAttributes());
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay public void beginDisplay(DisplayEvent e) {
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp try {
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts OAuth2Model model = (OAuth2Model) getModel();
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp Set realms = model.getRealms();
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp CCDropDownMenu menuRealm = (CCDropDownMenu) getChild(REALM);
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp menuRealm.setOptions(createOptionList(realms));
7a85e989c5e460208534dcea16759d1a9f7d4967James Phillpotts
7a85e989c5e460208534dcea16759d1a9f7d4967James Phillpotts String realm = getRequestContext().getRequest().getParameter("realm");
7a85e989c5e460208534dcea16759d1a9f7d4967James Phillpotts if (realm != null && !realm.trim().isEmpty()) {
7a85e989c5e460208534dcea16759d1a9f7d4967James Phillpotts setDisplayFieldValue(REALM, realm);
7a85e989c5e460208534dcea16759d1a9f7d4967James Phillpotts }
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts final String titleMessage = model.getLocalizedString(TITLE_MESSAGE);
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts ptModel.setPageTitleText(MessageFormat.format(titleMessage, model.getDisplayName()));
8b6198b1170e3128c5df83267597f0058d07c70dJames Phillpotts ptModel.setPageTitleHelpMessage(model.getLocalizedHelpMessage());
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp } catch (AMConsoleException ex) {
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error",
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp ex.getMessage());
bd91193fe2e6ce7e56cf0d1c3c8f1b1d3e0570bcTravis Papp }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay public String endPropertyAttributesDisplay(
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay ChildContentDisplayEvent event
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay ) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay String html = event.getContent();
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay return html;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay static String removeSortHref(String html) {
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay return html;
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay }
f58c87ece2202b8f85310d8885c7e39a7f435c09Jason Lemay}