Beispiel #1
0
 /**
  * Get the {@link Authorization} by its code (the authorization_code in the OAuth context).
  *
  * @param code
  * @return
  * @throws NoSuchAuthorizationException
  */
 public Authorization getByCode(@NotNull String code) {
   Optional<Authorization> authorization =
       authorizationRepository.findByCode(code).stream().findFirst();
   if (!authorization.isPresent()) throw NoSuchAuthorizationException.withCode(code);
   return authorization.get();
 }
Beispiel #2
0
 /**
  * Get the unique {@link Authorization} for the user name and application.
  *
  * @param username
  * @param application
  * @return
  * @throws NoSuchAuthorizationException
  */
 public Authorization get(@NotNull String username, @NotNull String application) {
   Authorization authorization = find(username, application);
   if (authorization == null)
     throw NoSuchAuthorizationException.withUsernameAndApplication(username, application);
   return authorization;
 }
Beispiel #3
0
 /**
  * Get the {@link Authorization} by its ID.
  *
  * @param id
  * @return
  * @throws NoSuchAuthorizationException
  */
 public Authorization get(@NotNull String id) {
   Authorization authorization = authorizationRepository.findOne(id);
   if (authorization == null) throw NoSuchAuthorizationException.withId(id);
   return authorization;
 }