Search in sources :

Example 1 with ObjectUserSecretKey

use of com.emc.storageos.db.client.model.ObjectUserSecretKey in project coprhd-controller by CoprHD.

the class StorageSystemService method addUserSecretKey.

/**
 * Create a secret key for an object storage array
 *
 * @param param secret key
 * @param id storage system URN
 * @param userId user in array
 * @brief Add a secret key for a storage system user
 * @return secret key details
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/object-user/{userId}/secret-keys")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ObjectUserSecretKeyAddRestRep addUserSecretKey(ObjectUserSecretKeyRequestParam param, @PathParam("id") URI id, @PathParam("userId") String userId) throws InternalException {
    // Make sure storage system is registered and object storage
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    if (!StorageSystem.Type.ecs.toString().equals(system.getSystemType())) {
        throw APIException.badRequests.invalidParameterURIInvalid("id", id);
    }
    ObjectController controller = getController(ObjectController.class, system.getSystemType());
    String secretKey = null;
    if (param != null && !StringUtil.isBlank(param.getSecretkey())) {
        secretKey = param.getSecretkey();
    }
    ObjectUserSecretKey secretKeyRes = controller.addUserSecretKey(id, userId, secretKey);
    // Return key details as this is synchronous call
    return map(secretKeyRes, true);
}
Also used : ObjectController(com.emc.storageos.volumecontroller.ObjectController) ObjectUserSecretKey(com.emc.storageos.db.client.model.ObjectUserSecretKey) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ObjectUserSecretKey

use of com.emc.storageos.db.client.model.ObjectUserSecretKey in project coprhd-controller by CoprHD.

the class ECSObjectStorageDevice method doAddUserSecretKey.

@Override
public ObjectUserSecretKey doAddUserSecretKey(StorageSystem storageObj, String userId, String secretKey) throws InternalException {
    ECSApi ecsApi = getAPI(storageObj);
    ObjectUserSecretKey secretKeyRes = new ObjectUserSecretKey();
    try {
        UserSecretKeysAddCommandResult cmdRes = ecsApi.addUserSecretKey(userId, secretKey);
        // secretKeyRes.setSecret_key_1(cmdRes.getSecret_key()); //for security reason hiding the secrete key
        secretKeyRes.setSecret_key_1_expiry_timestamp(cmdRes.getKey_expiry_timestamp());
        return secretKeyRes;
    } catch (Exception e) {
        _log.error("ECSObjectStorageDevice:doAddUserSecretKey failed");
        throw e;
    }
}
Also used : ECSApi(com.emc.storageos.ecs.api.ECSApi) ObjectUserSecretKey(com.emc.storageos.db.client.model.ObjectUserSecretKey) UserSecretKeysAddCommandResult(com.emc.storageos.ecs.api.UserSecretKeysAddCommandResult) URISyntaxException(java.net.URISyntaxException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ECSException(com.emc.storageos.ecs.api.ECSException)

Aggregations

ObjectUserSecretKey (com.emc.storageos.db.client.model.ObjectUserSecretKey)2 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1 ECSApi (com.emc.storageos.ecs.api.ECSApi)1 ECSException (com.emc.storageos.ecs.api.ECSException)1 UserSecretKeysAddCommandResult (com.emc.storageos.ecs.api.UserSecretKeysAddCommandResult)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 ObjectController (com.emc.storageos.volumecontroller.ObjectController)1 URISyntaxException (java.net.URISyntaxException)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1