Search in sources :

Example 1 with TokenFactory

use of com.codingchili.core.security.TokenFactory in project chili-core by codingchili.

the class SerializerTest method setUp.

@Before
public void setUp() {
    TokenFactory factory = new TokenFactory(SECRET.getBytes());
    token = new Token(factory, TEST);
    token = token.addProperty(OWNER, getClass().getSimpleName());
}
Also used : Token(com.codingchili.core.security.Token) TokenFactory(com.codingchili.core.security.TokenFactory) Before(org.junit.Before)

Example 2 with TokenFactory

use of com.codingchili.core.security.TokenFactory in project chili-core by codingchili.

the class RealmDB method signToken.

@Override
public void signToken(Handler<AsyncResult<Token>> future, String realm, String domain) {
    realms.query(ID_NAME).equalTo(realm).execute(map -> {
        Collection<RegisteredRealm> realms = map.result();
        if (map.succeeded() && realms.size() > 0) {
            RegisteredRealm settings = realms.iterator().next();
            future.handle(succeededFuture(new Token(new TokenFactory(getSecretBytes(settings)), domain)));
        } else {
            future.handle(failedFuture(map.cause()));
        }
    });
}
Also used : Token(com.codingchili.core.security.Token) TokenFactory(com.codingchili.core.security.TokenFactory) RegisteredRealm(com.codingchili.realmregistry.configuration.RegisteredRealm)

Example 3 with TokenFactory

use of com.codingchili.core.security.TokenFactory in project chili-core by codingchili.

the class ContextMock method getRealmStore.

@Override
public void getRealmStore(Handler<AsyncResult<AsyncRealmStore>> handler) {
    new StorageLoader<RegisteredRealm>().privatemap(new StorageContext<>(this)).withValue(RegisteredRealm.class).withDB("", "").build(result -> {
        this.realms = new RealmDB(result.result());
        RegisteredRealm realm = new RegisteredRealm().setName("realmName").setAuthentication(new Token(new TokenFactory("s".getBytes()), "realmName"));
        realms.put(Future.future(), realm);
        handler.handle(Future.succeededFuture(realms));
    });
}
Also used : StorageLoader(com.codingchili.core.storage.StorageLoader) Token(com.codingchili.core.security.Token) TokenFactory(com.codingchili.core.security.TokenFactory) StorageContext(com.codingchili.core.context.StorageContext) RegisteredRealm(com.codingchili.realmregistry.configuration.RegisteredRealm) RealmDB(com.codingchili.realmregistry.model.RealmDB)

Aggregations

Token (com.codingchili.core.security.Token)3 TokenFactory (com.codingchili.core.security.TokenFactory)3 RegisteredRealm (com.codingchili.realmregistry.configuration.RegisteredRealm)2 StorageContext (com.codingchili.core.context.StorageContext)1 StorageLoader (com.codingchili.core.storage.StorageLoader)1 RealmDB (com.codingchili.realmregistry.model.RealmDB)1 Before (org.junit.Before)1