4923 |
10 Aug 18 |
nicklas |
1 |
/** |
4923 |
10 Aug 18 |
nicklas |
$Id: IncludeContentTabFactory.java 6875 2015-04-20 09:08:18Z nicklas $ |
4923 |
10 Aug 18 |
nicklas |
3 |
|
4923 |
10 Aug 18 |
nicklas |
Copyright (C) 2010 Nicklas Nordborg |
4923 |
10 Aug 18 |
nicklas |
5 |
|
4923 |
10 Aug 18 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4923 |
10 Aug 18 |
nicklas |
Available at http://base.thep.lu.se/ |
4923 |
10 Aug 18 |
nicklas |
8 |
|
4923 |
10 Aug 18 |
nicklas |
BASE is free software; you can redistribute it and/or |
4923 |
10 Aug 18 |
nicklas |
modify it under the terms of the GNU General Public License |
4923 |
10 Aug 18 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4923 |
10 Aug 18 |
nicklas |
of the License, or (at your option) any later version. |
4923 |
10 Aug 18 |
nicklas |
13 |
|
4923 |
10 Aug 18 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4923 |
10 Aug 18 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4923 |
10 Aug 18 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4923 |
10 Aug 18 |
nicklas |
GNU General Public License for more details. |
4923 |
10 Aug 18 |
nicklas |
18 |
|
4923 |
10 Aug 18 |
nicklas |
You should have received a copy of the GNU General Public License |
4923 |
10 Aug 18 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4923 |
10 Aug 18 |
nicklas |
21 |
*/ |
4923 |
10 Aug 18 |
nicklas |
22 |
package net.sf.basedb.otp; |
4923 |
10 Aug 18 |
nicklas |
23 |
|
4923 |
10 Aug 18 |
nicklas |
24 |
import net.sf.basedb.clients.web.extensions.tabcontrol.IncludeContentTabFactory; |
4923 |
10 Aug 18 |
nicklas |
25 |
import net.sf.basedb.clients.web.extensions.tabcontrol.TabAction; |
4923 |
10 Aug 18 |
nicklas |
26 |
import net.sf.basedb.core.User; |
4923 |
10 Aug 18 |
nicklas |
27 |
import net.sf.basedb.util.extensions.InvokationContext; |
4923 |
10 Aug 18 |
nicklas |
28 |
|
4923 |
10 Aug 18 |
nicklas |
29 |
/** |
4923 |
10 Aug 18 |
nicklas |
Adds a tab to the user information dialog if the user has |
4923 |
10 Aug 18 |
nicklas |
OTP configured. We inherit all functionality from the BASE implementation |
4923 |
10 Aug 18 |
nicklas |
and onl checks if the user has configured OTP or not. |
4923 |
10 Aug 18 |
nicklas |
33 |
*/ |
4923 |
10 Aug 18 |
nicklas |
34 |
public class OtpQRCodeTabFactory |
4923 |
10 Aug 18 |
nicklas |
35 |
extends IncludeContentTabFactory |
4923 |
10 Aug 18 |
nicklas |
36 |
{ |
4923 |
10 Aug 18 |
nicklas |
37 |
|
4923 |
10 Aug 18 |
nicklas |
38 |
/** |
4923 |
10 Aug 18 |
nicklas |
Create a new factory instance. |
4923 |
10 Aug 18 |
nicklas |
40 |
*/ |
4923 |
10 Aug 18 |
nicklas |
41 |
public OtpQRCodeTabFactory() |
4923 |
10 Aug 18 |
nicklas |
42 |
{} |
4923 |
10 Aug 18 |
nicklas |
43 |
|
4923 |
10 Aug 18 |
nicklas |
44 |
@Override |
4923 |
10 Aug 18 |
nicklas |
45 |
public boolean prepareContext(InvokationContext<? super TabAction> context) |
4923 |
10 Aug 18 |
nicklas |
46 |
{ |
4923 |
10 Aug 18 |
nicklas |
47 |
Object currentItem = context.getClientContext().getCurrentItem(); |
4923 |
10 Aug 18 |
nicklas |
48 |
if (!(currentItem instanceof User)) return false; |
4923 |
10 Aug 18 |
nicklas |
49 |
|
4923 |
10 Aug 18 |
nicklas |
50 |
User currentUser = (User)currentItem; |
4923 |
10 Aug 18 |
nicklas |
51 |
String otpKeyEncrypted = (String)currentUser.getExtended("otpSecretKey"); |
4923 |
10 Aug 18 |
nicklas |
52 |
if (otpKeyEncrypted == null) return false; |
4923 |
10 Aug 18 |
nicklas |
53 |
|
4923 |
10 Aug 18 |
nicklas |
54 |
return super.prepareContext(context); |
4923 |
10 Aug 18 |
nicklas |
55 |
} |
4923 |
10 Aug 18 |
nicklas |
56 |
|
4923 |
10 Aug 18 |
nicklas |
57 |
} |