Search in sources :

Example 1 with AltusToken

use of com.sequenceiq.thunderhead.model.AltusToken in project cloudbreak by hortonworks.

the class MockUserManagementService method verifyInteractiveUserSessionToken.

@Override
public void verifyInteractiveUserSessionToken(VerifyInteractiveUserSessionTokenRequest request, StreamObserver<VerifyInteractiveUserSessionTokenResponse> responseObserver) {
    LOGGER.trace("Verify interative user session token: {}", request.getSessionToken());
    String sessionToken = request.getSessionToken();
    Jwt token = decodeAndVerify(sessionToken, SIGNATURE_VERIFIER);
    AltusToken introspectResponse = jsonUtil.toObject(token.getClaims(), AltusToken.class);
    String userIdOrCrn = introspectResponse.getSub();
    String[] splittedCrn = userIdOrCrn.split(":");
    responseObserver.onNext(VerifyInteractiveUserSessionTokenResponse.newBuilder().setAccountId(splittedCrn[4]).setAccountType(AccountType.REGULAR).setUserCrn(userIdOrCrn).build());
    responseObserver.onCompleted();
}
Also used : AltusToken(com.sequenceiq.thunderhead.model.AltusToken) Jwt(org.springframework.security.jwt.Jwt)

Example 2 with AltusToken

use of com.sequenceiq.thunderhead.model.AltusToken in project cloudbreak by hortonworks.

the class MockUmsService method getAltusToken.

private String getAltusToken(String tenant, String user) {
    AltusToken altusToken = new AltusToken();
    altusToken.setIss(ISS_ALTUS);
    altusToken.setAud(ISS_ALTUS);
    altusToken.setJti(UUID.randomUUID().toString());
    altusToken.setIat(Instant.now().toEpochMilli());
    altusToken.setExp(Instant.now().plus(PLUS_QUANTITY, DAYS).toEpochMilli());
    altusToken.setIat(Instant.now().toEpochMilli());
    altusToken.setSub(CrnHelper.generateCrn(tenant, user));
    String token = encode(jsonUtil.toJsonString(altusToken), SIGNATURE_VERIFIER).getEncoded();
    LOGGER.info(format("Token generated for Altus: %s", token));
    return token;
}
Also used : AltusToken(com.sequenceiq.thunderhead.model.AltusToken)

Aggregations

AltusToken (com.sequenceiq.thunderhead.model.AltusToken)2 Jwt (org.springframework.security.jwt.Jwt)1