001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.login; 029 030import org.opencms.crypto.CmsEncryptionException; 031import org.opencms.main.CmsLog; 032import org.opencms.main.OpenCms; 033import org.opencms.ui.shared.login.I_CmsLoginTargetRpc; 034 035import org.apache.commons.logging.Log; 036 037import com.vaadin.server.AbstractExtension; 038import com.vaadin.ui.UI; 039 040/** 041 * Server side component used to open the login target for a logged in user.<p> 042 */ 043public class CmsLoginTargetOpener extends AbstractExtension { 044 045 /** The serial version id. */ 046 private static final long serialVersionUID = 1L; 047 048 /** Log instance for this class. */ 049 private static final Log LOG = CmsLog.getLog(CmsLoginTargetOpener.class); 050 051 /** 052 * Creates a new instance.<p> 053 * 054 * @param ui the UI to extend 055 */ 056 public CmsLoginTargetOpener(UI ui) { 057 058 extend(ui); 059 } 060 061 /** 062 * Opens the login target.<p> 063 * 064 * @param target the login target URL 065 * @param isPublicPC the public PC flag 066 */ 067 public void openTarget(String target, boolean isPublicPC) { 068 069 if (isPublicPC) { 070 getRpcProxy(I_CmsLoginTargetRpc.class).openTargetForPublicPc(target); 071 } else { 072 String encryptedTarget; 073 // for private PCs, another form submission step is used on the client to trigger the browser password manager. 074 // the form used to a contain a field with the plain redirect URI, but we now encrypt it beforehand. 075 try { 076 encryptedTarget = OpenCms.getDefaultTextEncryption().encrypt(target); 077 getRpcProxy(I_CmsLoginTargetRpc.class).openTargetForPrivatePc(encryptedTarget); 078 } catch (CmsEncryptionException e) { 079 LOG.warn(e.getLocalizedMessage(), e); 080 getRpcProxy(I_CmsLoginTargetRpc.class).openTargetForPublicPc(target); 081 } 082 } 083 } 084}