From 398100298aaff50e0daf687154e512f1bb5aabcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Mon, 8 Sep 2014 15:13:02 +0200 Subject: [PATCH] Feature #2796: Add login method to Java api --- .../src/org/opennebula/client/user/User.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/oca/java/src/org/opennebula/client/user/User.java b/src/oca/java/src/org/opennebula/client/user/User.java index b55e9cc92e..8db9e35c6a 100644 --- a/src/oca/java/src/org/opennebula/client/user/User.java +++ b/src/oca/java/src/org/opennebula/client/user/User.java @@ -38,6 +38,7 @@ public class User extends PoolElement{ private static final String QUOTA = METHOD_PREFIX + "quota"; private static final String ADDGROUP = METHOD_PREFIX + "addgroup"; private static final String DELGROUP = METHOD_PREFIX + "delgroup"; + private static final String LOGIN = METHOD_PREFIX + "login"; /** * Creates a new User representation. @@ -221,6 +222,24 @@ public class User extends PoolElement{ return client.call(QUOTA, id, quota_template); } + /** + * Sets the LOGIN_TOKEN for the user + * + * @param username of the user + * @param token the login token, if empty OpenNebula will + * generate one + * @param expire valid period of the token in secs. If <= 0 + * the token will be reset + * @return token in case of success, Error otherwise + */ + public static OneResponse login(Client client, + String username, + String token, + int expire) + { + return client.call(LOGIN, username, token, expire); + } + // ================================= // Instanced object XML-RPC methods // ================================= @@ -352,6 +371,20 @@ public class User extends PoolElement{ return setQuota(client, id, quota_template); } + /** + * Sets the LOGIN_TOKEN for the user. The method info() must be called before. + * + * @param token the login token, if empty OpenNebula will + * generate one + * @param expire valid period of the token in secs. If <= 0 + * the token will be reset + * @return token in case of success, Error otherwise + */ + public OneResponse login(String token, int expire) + { + return client.call(LOGIN, getName(), token, expire); + } + // ================================= // Helpers // =================================