All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xlcloud.openstack.api.IdentityManagementClient Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2012 AMG.lab, a Bull Group Company
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.xlcloud.openstack.api;

import org.xlcloud.openstack.model.exceptions.OpenStackAuthenticationException;
import org.xlcloud.openstack.model.exceptions.OpenStackNotFoundException;
import org.xlcloud.openstack.model.identity.Role;
import org.xlcloud.openstack.model.identity.RoleList;
import org.xlcloud.openstack.model.identity.Tenant;
import org.xlcloud.openstack.model.identity.TenantList;
import org.xlcloud.openstack.model.identity.User;
import org.xlcloud.openstack.model.identity.UserForCreate;
import org.xlcloud.openstack.model.identity.UserList;

/**
 * This interface provides a concise way to manipulate identities
 * (org.xlcloud.openstack.model.identity package).
 * 
 * @author Ksiazczyk Grzegorz, AMG.net
 */
public interface IdentityManagementClient {

    /**
     * @param token
     * @return Access object connected with given token.
     */
    public boolean isTokenValid(String token);

    /**
     * Chceck is actual token is valid, if true returns
     * {@link OpenStackAuthenticationException} if token is not valid relogin
     * user in keystone.
     * 
     * @param token
     * @return Access object connected with given token.
     */
    public void reauthenticate(String userName, String password, String tennantName);

    /**
     * TODO Documentation
     * 
     * @return
     */
    public String getToken();

    /**
     * Lists all users.
     * 
     * @return list of all users
     */
    public UserList getUserResources();

    /**
     * Returns {@link User} identity with a given id.
     * 
     * @param id
     * @return
     */
    public User getUserById(String id);

    /**
     * Returns {@link User} identity with a given name.
     * 
     * @param name
     * @return
     * @throws OpenStackNotFoundException
     *             when user with the given name does not exist
     */
    public User getUserByName(String name) throws OpenStackNotFoundException;

    /**
     * Delete {@link User} with a given id.
     * 
     * @param id
     */
    public void deleteUserById(String id);

    /**
     * Create new {@link User} and returns it. Both id and name have to be
     * unique. Id may be not set - then the id will be assigned automatically.
     * 
     * @param user
     * @return
     */
    public User createUser(UserForCreate user);
    
    /**
     * Updates the existing {@link User} and returns it.
     */
    public User updateUser(UserForCreate user);
    
    /**
     * Returns {@link Tenant} identity with a given id.
     * 
     * @param id
     * @return
     */
    public Tenant getTenantById(String id);

    /**
     * Returns {@link Tenant} identity with a given name.
     * 
     * @param name
     * @return
     * @throws OpenStackNotFoundException
     *             when tenant with the given name does not exist
     */
    public Tenant getTenantByName(String name) throws OpenStackNotFoundException;

    /**
     * Deletes tenant (if existed)
     * 
     * @param id
     * @return
     */
    void removeTenant(String id);

    /**
     * Lists all tenants.
     * 
     * @return
     */
    public TenantList getTenantResources();

    /**
     * Create new {@link Role} and returns it. Both id and name have to be
     * unique. Id may be not set - then the id will be assigned automatically.
     * 
     * @param role
     * @return
     */
    public Role createRole(Role role);

    /**
     * Create new {@link Tenant} and returns it. Both id and name have to be
     * unique. Id may be not set - then the id will be assigned automatically.
     * 
     * @param tenant
     * @return
     */
    public Tenant createTentant(Tenant tenant);

    /**
     * Assigns the given role between user and tenant. All these identities have
     * to have been already created.
     * 
     * @param userId
     * @param roleId
     * @param tenantId
     * @return
     */
    public Role assignRole(String userId, String roleId, String tenantId);

    /**
     * Removes the assignment between role and its user and tenent. It does not
     * delete the role itself.
     * 
     * @param userId
     * @param roleId
     * @param tenantId
     */
    public void removeRole(String userId, String roleId, String tenantId);

    /**
     * Returns {@link Role} identity with a given name.
     * 
     * @param name
     * @return
     * @throws OpenStackNotFoundException
     *             when role with the given name does not exist
     */
    public Role getRoleByName(String name) throws OpenStackNotFoundException;

    /**
     * List all roles.
     * 
     * @return
     */
    public RoleList getRoleResources();

    /**
     * List keystone roles assigned to user in specified tenant.
     * 
     * @param userid
     * @param tenantId
     * @return
     */
    public RoleList getUserRolesInTenant(String userId, String tenantId);

    /**
     * Removes all roles connecting given user and tenant.
     * 
     * @param userId
     * @param tenantId
     */
    void removeAllUserRolesInTenant(String userId, String tenantId);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy