001 /*
002 * Copyright (c) 2011, Cloudera, Inc. All Rights Reserved.
003 *
004 * Cloudera, Inc. licenses this file to you under the Apache License,
005 * Version 2.0 (the "License"). You may not use this file except in
006 * compliance with the License. You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * This software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
011 * CONDITIONS OF ANY KIND, either express or implied. See the License for
012 * the specific language governing permissions and limitations under the
013 * License.
014 */
015 package com.cloudera.lib.service.security;
016
017 import com.cloudera.lib.server.BaseService;
018 import com.cloudera.lib.server.ServiceException;
019 import com.cloudera.lib.service.Groups;
020 import com.cloudera.lib.util.XConfiguration;
021 import org.apache.hadoop.conf.Configuration;
022
023 import java.io.IOException;
024 import java.util.List;
025
026 public class GroupsService extends BaseService implements Groups {
027 private static final String PREFIX = "groups";
028
029 private org.apache.hadoop.security.Groups hGroups;
030
031 public GroupsService() {
032 super(PREFIX);
033 }
034
035 @Override
036 protected void init() throws ServiceException {
037 Configuration hConf = new XConfiguration();
038 XConfiguration.copy(getServiceConfig(), hConf);
039 hGroups = new org.apache.hadoop.security.Groups(hConf);
040 }
041
042 @Override
043 public Class getInterface() {
044 return Groups.class;
045 }
046
047 @Override
048 public List<String> getGroups(String user) throws IOException {
049 return hGroups.getGroups(user);
050 }
051
052 }