4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts/*
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * The contents of this file are subject to the terms of the Common Development and
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * Distribution License (the License). You may not use this file except in compliance with the
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * License.
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts *
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * specific language governing permission and limitations under the License.
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts *
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * When distributing Covered Software, include this CDDL Header Notice in each file and include
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * Header, with the fields enclosed by brackets [] replaced by your own identifying
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * information: "Portions copyright [year] [name of copyright owner]".
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts *
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts * Copyright 2015 ForgeRock AS.
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts */
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottspackage com.sun.identity.console.task;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport java.io.IOException;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport java.io.UnsupportedEncodingException;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport java.net.URLEncoder;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport com.iplanet.jato.RequestContext;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport com.iplanet.jato.RequestManager;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport com.sun.identity.console.XuiRedirectHelper;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottsimport com.sun.identity.console.base.AMPrimaryMastHeadViewBean;
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpottspublic abstract class RedirectToRealmHomeViewBean extends AMPrimaryMastHeadViewBean {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts public RedirectToRealmHomeViewBean(String name) {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts super(name);
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts }
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts protected void redirectToHome() {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts if (XuiRedirectHelper.isXuiAdminConsoleEnabled()) {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts RequestContext rc = RequestManager.getRequestContext();
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts try {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts String realm = URLEncoder.encode(rc.getRequest().getParameter("realm"), "UTF-8");
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts rc.getResponse().sendRedirect("../XUI#realms/" + realm + "/dashboard");
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts } catch (UnsupportedEncodingException e) {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts throw new IllegalStateException("UTF-8 not supported", e);
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts } catch (IOException e) {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts debug.message("Unexpected IOException during redirect", e);
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts }
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts } else {
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts HomeViewBean vb = (HomeViewBean) getViewBean(HomeViewBean.class);
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts backTrail();
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts passPgSessionMap(vb);
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts vb.forwardTo(getRequestContext());
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts }
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts }
4c2ed873ce0d69780e28220e175a838a6829d4eaJames Phillpotts}