1
/*******************************************************************************
2
*Copyright (c) 2009 Eucalyptus Systems, Inc.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, only version 3 of the License.
9
* This file is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Please contact Eucalyptus Systems, Inc., 130 Castilian
18
* Dr., Goleta, CA 93101 USA or visit <http://www.eucalyptus.com/licenses/>
19
* if you need additional information or have any questions.
21
* This file may incorporate work covered under the following copyright and
24
* Software License Agreement (BSD License)
26
* Copyright (c) 2008, Regents of the University of California
27
* All rights reserved.
29
* Redistribution and use of this software in source and binary forms, with
30
* or without modification, are permitted provided that the following
33
* Redistributions of source code must retain the above copyright notice,
34
* this list of conditions and the following disclaimer.
36
* Redistributions in binary form must reproduce the above copyright
37
* notice, this list of conditions and the following disclaimer in the
38
* documentation and/or other materials provided with the distribution.
40
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
41
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
42
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
43
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
44
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
46
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
47
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
48
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
49
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. USERS OF
51
* THIS SOFTWARE ACKNOWLEDGE THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE
52
* LICENSED MATERIAL, COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS
53
* SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
54
* IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
55
* BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
56
* THE REGENTSā DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
57
* OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
58
* WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
59
* ANY SUCH LICENSES OR RIGHTS.
60
*******************************************************************************/
63
* Author: Dmitrii Zagorodnov dmitrii@cs.ucsb.edu
66
package edu.ucsb.eucalyptus.admin.server;
68
import java.util.ArrayList;
69
import java.util.HashMap;
70
import java.util.HashSet;
71
import java.util.List;
74
import com.google.gwt.user.client.rpc.SerializableException;
75
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
77
import edu.ucsb.eucalyptus.admin.client.CloudInfoWeb;
78
import edu.ucsb.eucalyptus.admin.client.ClusterInfoWeb;
79
import edu.ucsb.eucalyptus.admin.client.DownloadsWeb;
80
import edu.ucsb.eucalyptus.admin.client.EucalyptusWebBackend;
81
import edu.ucsb.eucalyptus.admin.client.StorageInfoWeb;
82
import edu.ucsb.eucalyptus.admin.client.SystemConfigWeb;
83
import edu.ucsb.eucalyptus.admin.client.UserInfoWeb;
84
import edu.ucsb.eucalyptus.admin.client.VmTypeWeb;
85
import edu.ucsb.eucalyptus.admin.client.WalrusInfoWeb;
88
* Created by IntelliJ IDEA.
89
* User: dmitriizagorodnov
92
* To change this template use File | Settings | File Templates.
94
public class EucalyptusWebBackendImpl extends RemoteServiceServlet implements EucalyptusWebBackend {
96
static UserInfoWeb adminUser = new UserInfoWeb();
97
static Set<UserInfoWeb> users = new HashSet<UserInfoWeb>();
100
adminUser.setUserName("admin");
101
adminUser.setIsAdministrator(true); // so we see all tabs
102
adminUser.setIsApproved(true);
103
adminUser.setIsConfirmed(true);
104
adminUser.setIsEnabled(true);
105
adminUser.setEmail("foo@bar"); // so we skip first-time login screen
106
users.add(adminUser);
108
for (int i=0; i<9; i++) {
109
UserInfoWeb newUser = new UserInfoWeb();
110
newUser.setUserName("user" + i);
111
newUser.setEmail("foo" + i + "@bar");
112
newUser.setIsAdministrator(false);
113
newUser.setIsApproved((i%2==0)?false:true);
114
newUser.setIsConfirmed((i%3==0)?false:true);
115
newUser.setIsEnabled((i%4==0)?false:true);
120
public String addUserRecord ( UserInfoWeb user )
121
throws SerializableException
123
return addUserRecord(null, user);
126
public String addUserRecord(String sessionId, UserInfoWeb user)
127
throws SerializableException
133
public String recoverPassword ( UserInfoWeb web_user )
134
throws SerializableException
139
public String getNewSessionID (String userId, String md5Password)
140
throws SerializableException
145
public String performAction (String sessionId, String action, String param)
146
throws SerializableException
151
public void logoutSession(String sessionId)
152
throws SerializableException
157
public List getUserRecord (String sessionId, String userId)
158
throws SerializableException
161
List l = new ArrayList();
165
return new ArrayList(users);
169
public static UserInfoWeb getUserRecord (String sessionId) // a *static* getUserRecord, for ImageStoreService
170
throws SerializableException
175
public List getImageInfo (String sessionId, String userId)
176
throws SerializableException
178
return new ArrayList();
181
/* from here on down, all requests require users to be enabled, approved, and confirmed */
183
public String getNewCert(String sessionId)
184
throws SerializableException
189
public HashMap getProperties()
190
throws SerializableException
192
HashMap h = new HashMap();
193
h.put("ready", true);
194
h.put("cloud-name", "Back-end stub");
195
h.put("version", "1.6.2");
196
h.put("signup-greeting", "<signup greeting>");
197
h.put("certificate-download-text", "<certificate-download-text>");
198
h.put("rest-credentials-text", "<rest-credentials-text>");
199
h.put("user-account-text", "user-account-text");
200
h.put("admin-first-time-config-text", "admin-first-time-config-text");
201
h.put("admin-email-change-text", "admin-email-change-text");
202
h.put("admin-cloud-ip-setup-text", "admin-cloud-ip-setup-text");
206
public String changePassword (String sessionId, String oldPassword, String newPassword )
207
throws SerializableException
212
public String updateUserRecord (String sessionId, UserInfoWeb newRecord )
213
throws SerializableException
218
public List<ClusterInfoWeb> getClusterList(String sessionId) throws SerializableException
220
ArrayList<ClusterInfoWeb> a = new ArrayList<ClusterInfoWeb>();
221
ClusterInfoWeb c = new ClusterInfoWeb("CLUSTER", "hostname", 43210, 44, 55);
226
public void setClusterList(String sessionId, List<ClusterInfoWeb> clusterList ) throws SerializableException
231
public List<StorageInfoWeb> getStorageList(String sessionId) throws SerializableException
233
ArrayList<StorageInfoWeb> a = new ArrayList<StorageInfoWeb>();
234
StorageInfoWeb s = new StorageInfoWeb("CLUSTER", "hostname", 54321, 55, 555, new ArrayList<String>());
239
public void setStorageList(String sessionId, List<StorageInfoWeb> storageList ) throws SerializableException
244
public List<WalrusInfoWeb> getWalrusList(String sessionId) throws SerializableException
246
return new ArrayList<WalrusInfoWeb>();
249
public void setWalrusList(String sessionId, List<WalrusInfoWeb> walrusList ) throws SerializableException
254
public SystemConfigWeb getSystemConfig( final String sessionId ) throws SerializableException
256
SystemConfigWeb c = new SystemConfigWeb();
257
c.setDoDynamicPublicAddresses(false);
261
public void setSystemConfig( final String sessionId, final SystemConfigWeb systemConfig ) throws SerializableException
266
public List<VmTypeWeb> getVmTypes( final String sessionId ) throws SerializableException
268
return new ArrayList<VmTypeWeb>();
271
public void setVmTypes( final String sessionId, final List<VmTypeWeb> vmTypes ) throws SerializableException
276
public CloudInfoWeb getCloudInfo(final String sessionId, final boolean setExternalHostPort) throws SerializableException
278
return new CloudInfoWeb();
281
private static List<DownloadsWeb> getDownloadsFromUrl(final String downloadsUrl) {
282
return new ArrayList<DownloadsWeb>();
285
public List<DownloadsWeb> getDownloads(final String sessionId, final String downloadsUrl) throws SerializableException {
286
return new ArrayList<DownloadsWeb>();