Search in sources :

Example 1 with AcrValues

use of ru.ratauth.entities.AcrValues in project ratauth by alfa-laboratory.

the class AcrValuesTest method testToString.

@Test
public void testToString() throws Exception {
    AcrValues acrValue = AcrValues.builder().acr("card").acr("sms").build();
    assertEquals("card:sms", acrValue.toString());
}
Also used : AcrValues(ru.ratauth.entities.AcrValues) Test(org.junit.Test)

Example 2 with AcrValues

use of ru.ratauth.entities.AcrValues in project ratauth by alfa-laboratory.

the class AuthzResponse method buildURL.

public String buildURL() {
    StringJoiner joiner = new StringJoiner("&");
    if (!StringUtils.isBlank(redirectURI)) {
        joiner.add("redirect_uri=" + getEncodedRedirectURI());
    }
    if (!StringUtils.isBlank(code)) {
        joiner.add("code=" + code);
    }
    if (expiresIn != null) {
        joiner.add("expires_in=" + expiresIn);
    }
    if (!StringUtils.isBlank(token)) {
        joiner.add("token=" + token);
        joiner.add("token_type=" + tokenType);
    }
    if (!StringUtils.isBlank(refreshToken)) {
        joiner.add("refresh_token=" + refreshToken.toString());
    }
    if (!StringUtils.isBlank(idToken)) {
        joiner.add("id_token=" + idToken.toString());
    }
    if (!StringUtils.isBlank(mfaToken)) {
        joiner.add("mfa_token=" + mfaToken.toString());
    }
    if (StringUtils.isBlank(mfaToken) && !StringUtils.isBlank(sessionToken)) {
        joiner.add("session_token=" + sessionToken.toString());
    }
    if (acrValues != null && acrValues.getValues() != null && !acrValues.getValues().isEmpty()) {
        joiner.add("acr_values=" + acrValues.toString());
    }
    if (data != null && !data.isEmpty()) {
        data.entrySet().stream().filter(entry -> entry.getValue() != null).map(entry -> joiner.add(entry.getKey() + "=" + entry.getValue().toString()));
    }
    return createRedirectURI(location, joiner.toString());
}
Also used : URLEncoder(java.net.URLEncoder) Builder(lombok.Builder) AcrValues(ru.ratauth.entities.AcrValues) StringUtils(ru.ratauth.utils.StringUtils) Map(java.util.Map) StringJoiner(java.util.StringJoiner) Data(lombok.Data) AllArgsConstructor(lombok.AllArgsConstructor) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoArgsConstructor(lombok.NoArgsConstructor) StringJoiner(java.util.StringJoiner)

Example 3 with AcrValues

use of ru.ratauth.entities.AcrValues in project ratauth by alfa-laboratory.

the class AuthzRequest method addVerifyResultAcrToRequest.

public VerifyResult addVerifyResultAcrToRequest(VerifyResult verifyResult) {
    AcrValues merged = Optional.ofNullable(verifyResult.getAcrValues()).map(verifyAcrValues -> this.getAcrValues().add(verifyAcrValues.getFirst())).orElseGet(this::getAcrValues);
    this.setAcrValues(merged);
    verifyResult.setAcrValues(merged);
    return verifyResult;
}
Also used : AcrValues(ru.ratauth.entities.AcrValues) VerifyResult(ru.ratauth.providers.auth.dto.VerifyResult) Map(java.util.Map) Optional(java.util.Optional) Set(java.util.Set) lombok(lombok) AcrValues(ru.ratauth.entities.AcrValues)

Example 4 with AcrValues

use of ru.ratauth.entities.AcrValues in project ratauth by alfa-laboratory.

the class AcrValuesTest method testDifferenceRemoveSecondField.

@Test
public void testDifferenceRemoveSecondField() {
    AcrValues requiredAcrValues = AcrValues.valueOf("card:account:sms");
    AcrValues existsAcrValue = AcrValues.valueOf("account");
    AcrValues difference = requiredAcrValues.difference(existsAcrValue);
    assertEquals(AcrValues.valueOf("card:sms"), difference);
}
Also used : AcrValues(ru.ratauth.entities.AcrValues) Test(org.junit.Test)

Example 5 with AcrValues

use of ru.ratauth.entities.AcrValues in project ratauth by alfa-laboratory.

the class AcrValuesTest method testDifferenceRemoveFirstField.

@Test
public void testDifferenceRemoveFirstField() {
    AcrValues requiredAcrValues = AcrValues.valueOf("card:account:sms");
    AcrValues existsAcrValue = AcrValues.valueOf("card");
    AcrValues difference = requiredAcrValues.difference(existsAcrValue);
    assertEquals(AcrValues.valueOf("account:sms"), difference);
}
Also used : AcrValues(ru.ratauth.entities.AcrValues) Test(org.junit.Test)

Aggregations

AcrValues (ru.ratauth.entities.AcrValues)6 Test (org.junit.Test)3 Map (java.util.Map)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URLEncoder (java.net.URLEncoder)1 Optional (java.util.Optional)1 Set (java.util.Set)1 StringJoiner (java.util.StringJoiner)1 lombok (lombok)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Builder (lombok.Builder)1 Data (lombok.Data)1 NoArgsConstructor (lombok.NoArgsConstructor)1 VerifyResult (ru.ratauth.providers.auth.dto.VerifyResult)1 StringUtils (ru.ratauth.utils.StringUtils)1