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

cn.vertxup.rbac.api.AuthActor Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package cn.vertxup.rbac.api;

import cn.vertxup.rbac.service.login.AuthStub;
import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.Session;
import io.vertx.tp.rbac.cv.Addr;
import io.vertx.tp.rbac.cv.AuthKey;
import io.vertx.up.annotations.Address;
import io.vertx.up.annotations.Queue;
import io.vertx.up.atom.unity.Uson;

import javax.inject.Inject;

/*
 * Auth Actor
 */
@Queue
public class AuthActor {

    @Inject
    private transient AuthStub stub;

    @Address(Addr.Auth.LOGIN)
    public Future login(final JsonObject user) {
        return this.stub.login(user);
    }

    @Address(Addr.Auth.AUTHORIZE)
    public Future authorize(final JsonObject data) {
        return this.stub.authorize(Uson.create(data).denull()
                .remove(AuthKey.RESPONSE_TYPE)
                .convert(AuthKey.CLIENT_ID, AuthKey.F_CLIENT_ID)
                .convert(AuthKey.CLIENT_SECRET, AuthKey.F_CLIENT_SECRET)
                .to());
    }

    @Address(Addr.Auth.TOKEN)
    public Future token(final JsonObject data, final Session session) {
        return this.stub.token(data.copy(), session);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy