Пример #1
0
  private static String tokenizeCodeGrant(ServerAuthorizationCodeGrant grant) {
    StringBuilder state = new StringBuilder();
    // 0: client id
    state.append(grant.getClient().getClientId());
    state.append(SEP);
    // 1: code
    state.append(tokenizeString(grant.getCode()));
    state.append(SEP);
    // 2: expiresIn
    state.append(grant.getExpiresIn());
    state.append(SEP);
    // 3: issuedAt
    state.append(grant.getIssuedAt());
    state.append(SEP);
    // 4: redirect URI
    state.append(tokenizeString(grant.getRedirectUri()));
    state.append(SEP);
    // 5: audience
    state.append(tokenizeString(grant.getAudience()));
    state.append(SEP);
    // 6: code verifier
    state.append(tokenizeString(grant.getClientCodeVerifier()));
    state.append(SEP);
    // 7: approved scopes
    state.append(grant.getApprovedScopes().toString());
    state.append(SEP);
    // 8: subject
    tokenizeUserSubject(state, grant.getSubject());

    return state.toString();
  }
Пример #2
0
  @Override
  public ServerAuthorizationCodeGrant createCodeGrant(final AuthorizationCodeRegistration acr)
      throws OAuthServiceException {

    grant = new ServerAuthorizationCodeGrant(client, 3600L);
    grant.setRedirectUri(acr.getRedirectUri());
    grant.setSubject(acr.getSubject());
    final List<String> scope =
        acr.getApprovedScope().isEmpty() ? acr.getRequestedScope() : acr.getApprovedScope();
    grant.setApprovedScopes(scope);

    return grant;
  }
Пример #3
0
 private static ServerAuthorizationCodeGrant recreateCodeGrantInternal(
     OAuthDataProvider provider, String sequence) {
   String[] parts = getParts(sequence);
   ServerAuthorizationCodeGrant grant =
       new ServerAuthorizationCodeGrant(
           provider.getClient(parts[0]), parts[1], Long.valueOf(parts[2]), Long.valueOf(parts[3]));
   grant.setRedirectUri(getStringPart(parts[4]));
   grant.setAudience(getStringPart(parts[5]));
   grant.setClientCodeVerifier(getStringPart(parts[6]));
   grant.setApprovedScopes(parseSimpleList(parts[7]));
   grant.setSubject(recreateUserSubject(parts[8]));
   return grant;
 }
Пример #4
0
 @Override
 public ServerAuthorizationCodeGrant removeCodeGrant(final String code)
     throws OAuthServiceException {
   return grant == null || !grant.getCode().equals(code) ? null : grant;
 }