Search in sources :

Example 1 with EnableTwoFactorAuthRequest

use of com.zimbra.soap.account.message.EnableTwoFactorAuthRequest in project zm-mailbox by Zimbra.

the class ZMailbox method enableTwoFactorAuth.

public EnableTwoFactorAuthResponse enableTwoFactorAuth(String password, TOTPAuthenticator auth) throws ServiceException {
    EnableTwoFactorAuthRequest req = new EnableTwoFactorAuthRequest();
    req.setName(getName());
    req.setPassword(password);
    EnableTwoFactorAuthResponse resp = invokeJaxb(req);
    String secret = resp.getSecret();
    long timestamp = System.currentTimeMillis() / 1000;
    String totp = auth.generateCode(secret, timestamp, Encoding.BASE32);
    req.setTwoFactorCode(totp);
    req.setAuthToken(resp.getAuthToken());
    resp = invokeJaxb(req);
    resp.setSecret(secret);
    initAuthToken(new ZAuthToken(resp.getAuthToken().getValue()));
    return resp;
}
Also used : EnableTwoFactorAuthRequest(com.zimbra.soap.account.message.EnableTwoFactorAuthRequest) EnableTwoFactorAuthResponse(com.zimbra.soap.account.message.EnableTwoFactorAuthResponse) ZAuthToken(com.zimbra.common.auth.ZAuthToken)

Aggregations

ZAuthToken (com.zimbra.common.auth.ZAuthToken)1 EnableTwoFactorAuthRequest (com.zimbra.soap.account.message.EnableTwoFactorAuthRequest)1 EnableTwoFactorAuthResponse (com.zimbra.soap.account.message.EnableTwoFactorAuthResponse)1