All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nitorcreations.willow.auth.GitHubOAuthAccounts Maven / Gradle / Ivy

The newest version!
package com.nitorcreations.willow.auth;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.inject.Named;
import javax.inject.Singleton;

import org.apache.shiro.authc.SimpleAccount;


@Singleton
@Named
public class GitHubOAuthAccounts {
  private final Map accounts = new ConcurrentHashMap<>();
  public GitHubOAuthAccounts() {}
  public void add(SimpleAccount account) {
    Object principal = account.getPrincipals().getPrimaryPrincipal();
    if (principal != null) {
      accounts.put(principal.toString(), account);
    }
  }
  public SimpleAccount get(String principal) {
    return accounts.get(principal);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy