001/* 002 * (C) Copyright 2015 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nelson Silva 016 */ 017package org.nuxeo.ecm.admin.oauth2; 018 019import java.util.ArrayList; 020import java.util.Arrays; 021import java.util.List; 022 023import org.apache.commons.lang.StringUtils; 024import org.jboss.seam.ScopeType; 025import org.jboss.seam.annotations.Name; 026import org.jboss.seam.annotations.Scope; 027import org.nuxeo.ecm.admin.oauth.DirectoryBasedEditor; 028import org.nuxeo.ecm.platform.oauth2.tokens.OAuth2TokenStore; 029 030@Name("oauth2ProvidersTokensActions") 031@Scope(ScopeType.CONVERSATION) 032public class OAuth2ProvidersTokensActionBean extends DirectoryBasedEditor { 033 034 private static final long serialVersionUID = 1L; 035 036 @Override 037 protected String getDirectoryName() { 038 return OAuth2TokenStore.DIRECTORY_NAME; 039 } 040 041 @Override 042 protected String getSchemaName() { 043 return "oauth2Token"; 044 } 045 046 public List<String> getSharedWith() { 047 List<String> sharedWith = new ArrayList<>(); 048 String sharedWithProperty = (String) editableEntry.getProperty(getSchemaName(), "sharedWith"); 049 if (sharedWithProperty != null) { 050 sharedWith = Arrays.asList(sharedWithProperty.split(",")); 051 } 052 return sharedWith; 053 } 054 055 public void setSharedWith(List<String> sharedWith) { 056 String list = StringUtils.join(sharedWith, ","); 057 editableEntry.setProperty(getSchemaName(), "sharedWith", list); 058 } 059}