001/* 002 * (C) Copyright 2006-2009 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.api.ws; 023 024import java.util.ArrayList; 025import java.util.List; 026 027import org.nuxeo.ecm.core.api.security.ACE; 028 029public class WsACE { 030 031 private String username; 032 033 private String permission; 034 035 private boolean isGranted; 036 037 public WsACE(String username, String permission, boolean isGranted) { 038 this.username = username; 039 this.permission = permission; 040 this.isGranted = isGranted; 041 } 042 043 public WsACE() { 044 this(null, null, false); 045 } 046 047 public WsACE(ACE ace) { 048 this(ace.getUsername(), ace.getPermission(), ace.isGranted()); 049 } 050 051 public String getUsername() { 052 return username; 053 } 054 055 public String getPermission() { 056 return permission; 057 } 058 059 public boolean isGranted() { 060 return isGranted; 061 } 062 063 public void setGranted(boolean isGranted) { 064 this.isGranted = isGranted; 065 } 066 067 public void setUsername(String username) { 068 this.username = username; 069 } 070 071 public void setPermission(String permission) { 072 this.permission = permission; 073 } 074 075 public static WsACE[] wrap(ACE[] aces) { 076 List<WsACE> result = new ArrayList<WsACE>(); 077 078 for (ACE ace : aces) { 079 result.add(new WsACE(ace)); 080 } 081 return result.toArray(new WsACE[result.size()]); 082 } 083 084}