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);
}
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;
}
}
Aggregations