コード例 #1
0
  /** Get authenticator provider's configuration description */
  @Path("config-description/{providerId}")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @NoCache
  public AuthenticatorConfigInfoRepresentation getAuthenticatorConfigDescription(
      @PathParam("providerId") String providerId) {
    auth.requireView();

    ConfigurableAuthenticatorFactory factory =
        CredentialHelper.getConfigurableAuthenticatorFactory(session, providerId);
    if (factory == null) {
      throw new NotFoundException("Could not find authenticator provider");
    }
    AuthenticatorConfigInfoRepresentation rep = new AuthenticatorConfigInfoRepresentation();
    rep.setProviderId(providerId);
    rep.setName(factory.getDisplayType());
    rep.setHelpText(factory.getHelpText());
    rep.setProperties(new LinkedList<ConfigPropertyRepresentation>());
    List<ProviderConfigProperty> configProperties = factory.getConfigProperties();
    for (ProviderConfigProperty prop : configProperties) {
      ConfigPropertyRepresentation propRep = getConfigPropertyRep(prop);
      rep.getProperties().add(propRep);
    }
    return rep;
  }
コード例 #2
0
  public List<Map<String, Object>> buildProviderMetadata(List<ProviderFactory> factories) {
    List<Map<String, Object>> providers = new LinkedList<>();
    for (ProviderFactory factory : factories) {
      Map<String, Object> data = new HashMap<>();
      data.put("id", factory.getId());
      ConfigurableAuthenticatorFactory configured = (ConfigurableAuthenticatorFactory) factory;
      data.put("description", configured.getHelpText());
      data.put("displayName", configured.getDisplayType());

      providers.add(data);
    }
    return providers;
  }