Search in sources :

Example 46 with SneakyThrows

use of lombok.SneakyThrows in project ratauth by alfa-laboratory.

the class OpenIdAuthorizeService method buildResponse.

@SneakyThrows
private static AuthzResponse buildResponse(RelyingParty relyingParty, Session session, VerifyResult verifyResult, TokenCache tokenCache, AuthzRequest authzRequest) {
    String redirectUri = authzRequest.getRedirectURI();
    final String targetRedirectURI = createRedirectURI(relyingParty, redirectUri);
    // in case of autCode sent by authProvider
    if (session == null || CollectionUtils.isEmpty(session.getEntries())) {
        AuthzResponse resp = AuthzResponse.builder().location(relyingParty.getAuthorizationRedirectURI()).data(verifyResult.getData()).redirectURI(targetRedirectURI).build();
        return resp;
    }
    AuthEntry entry = session.getEntry(relyingParty.getName()).get();
    AuthzResponse resp = AuthzResponse.builder().location(entry.getRedirectUrl()).sessionToken(session.getSessionToken()).acrValues(verifyResult.getAcrValues()).data(verifyResult.getData()).build();
    final Optional<Token> tokenOptional = entry.getLatestToken();
    // implicit auth
    if (tokenOptional.isPresent()) {
        final Token token = tokenOptional.get();
        resp.setToken(token.getToken());
        if (tokenCache != null)
            resp.setIdToken(tokenCache.getIdToken());
        resp.setTokenType(TokenType.BEARER);
        resp.setRefreshToken(token.getRefreshToken());
        resp.setExpiresIn(token.getExpiresIn().getTime());
    } else {
        generateAuthCode(relyingParty, session, authzRequest, targetRedirectURI, entry, resp);
    }
    return resp;
}
Also used : AuthzResponse(ru.ratauth.interaction.AuthzResponse) Token(ru.ratauth.entities.Token) AuthEntry(ru.ratauth.entities.AuthEntry) SneakyThrows(lombok.SneakyThrows)

Example 47 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramBlockRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    Map<String, Object> likeMap = new LinkedHashMap<>();
    likeMap.put("_uuid", api.getUuid());
    likeMap.put("_uid", api.getUserId());
    likeMap.put("user_id", userId);
    likeMap.put("_csrftoken", api.getOrFetchCsrf());
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(likeMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Example 48 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramCheckUsernameRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> payloadMap = new LinkedHashMap<>();
    payloadMap.put("username", username);
    payloadMap.put("_csrftoken", api.getOrFetchCsrf());
    String payloadJson = mapper.writeValueAsString(payloadMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Example 49 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramUnlikeRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    Map<String, Object> likeMap = new LinkedHashMap<>();
    likeMap.put("_uuid", api.getUuid());
    likeMap.put("_uid", api.getUserId());
    likeMap.put("_csrftoken", api.getOrFetchCsrf());
    likeMap.put("media_id", mediaId);
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(likeMap);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LinkedHashMap(java.util.LinkedHashMap) SneakyThrows(lombok.SneakyThrows)

Example 50 with SneakyThrows

use of lombok.SneakyThrows in project instagram4j by brunocvcunha.

the class InstagramLoginRequest method getPayload.

@Override
@SneakyThrows
public String getPayload() {
    ObjectMapper mapper = new ObjectMapper();
    String payloadJson = mapper.writeValueAsString(payload);
    return payloadJson;
}
Also used : ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)706 lombok.val (lombok.val)314 Test (org.junit.Test)91 ArrayList (java.util.ArrayList)75 HashMap (java.util.HashMap)63 List (java.util.List)53 Cleanup (lombok.Cleanup)38 Map (java.util.Map)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)34 Collectors (java.util.stream.Collectors)34 LinkedHashMap (java.util.LinkedHashMap)30 File (java.io.File)28 Path (java.nio.file.Path)28 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 URL (java.net.URL)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)17