Search in sources :

Example 6 with ApiKeyBO

use of com.nexblocks.authguard.service.model.ApiKeyBO in project AuthGuard by AuthGuard.

the class ApiKeysServiceImpl method generateApiKey.

@Override
public ApiKeyBO generateApiKey(final AppBO app) {
    final AuthResponseBO token = apiKeyExchange.generateKey(app);
    final String generatedKey = (String) token.getToken();
    final ApiKeyBO persisted = create(ApiKeyBO.builder().appId(app.getId()).key(apiKeyHash.hash(generatedKey)).build());
    // we store the hashed version but we return back the clear version
    return persisted.withKey(generatedKey);
}
Also used : ApiKeyBO(com.nexblocks.authguard.service.model.ApiKeyBO) AuthResponseBO(com.nexblocks.authguard.service.model.AuthResponseBO)

Aggregations

ApiKeyBO (com.nexblocks.authguard.service.model.ApiKeyBO)6 ApiKeyDO (com.nexblocks.authguard.dal.model.ApiKeyDO)4 Test (org.junit.jupiter.api.Test)4 ApiKeyRequestDTO (com.nexblocks.authguard.api.dto.requests.ApiKeyRequestDTO)1 AppBO (com.nexblocks.authguard.service.model.AppBO)1 AuthResponseBO (com.nexblocks.authguard.service.model.AuthResponseBO)1