コード例 #1
0
 private static synchronized void checkClientExceptionMapper() {
   if (ResteasyProviderFactory.getInstance().getClientExceptionMapper(Exception.class) == null) {
     Type exceptionType =
         Types.getActualTypeArgumentsOfAnInterface(
             ApacheHttpClient4ExceptionMapper.class, ClientExceptionMapper.class)[0];
     ResteasyProviderFactory.getInstance()
         .addClientExceptionMapper(new ApacheHttpClient4ExceptionMapper(), exceptionType);
   }
 }
コード例 #2
0
 @Path("applications")
 public ApplicationsResource getApplications() {
   ApplicationsResource applicationsResource = new ApplicationsResource(realm, auth);
   ResteasyProviderFactory.getInstance().injectProperties(applicationsResource);
   // resourceContext.initResource(applicationsResource);
   return applicationsResource;
 }
コード例 #3
0
 /**
  * Base path for managing users in this realm.
  *
  * @return
  */
 @Path("users")
 public UsersResource users() {
   UsersResource users = new UsersResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(users);
   // resourceContext.initResource(users);
   return users;
 }
コード例 #4
0
  @Override
  public void contextInitialized(ServletContextEvent contextEvent) {
    // Load configuration
    InputStream is =
        contextEvent.getServletContext().getResourceAsStream("/WEB-INF/configuration.properties");

    if (is != null) {
      Configuration.loadProperties(is);
      try {
        is.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      throw new Error("Missing configuration file '/WEB-INF/configuration.properties'");
    }

    // Register RESTEasy client provider factory
    RegisterBuiltin.register(ResteasyProviderFactory.getInstance());

    // start polling for MachineStatus changes
    polling = new Timer();
    polling.scheduleAtFixedRate(
        new PollNodeController(),
        0,
        Integer.parseInt(Configuration.getProperty("polling.interval")));
  }
コード例 #5
0
 /**
  * Path for managing all realm-level or client-level roles defined in this realm by its id.
  *
  * @return
  */
 @Path("roles-by-id")
 public RoleByIdResource rolesById() {
   RoleByIdResource resource = new RoleByIdResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   // resourceContext.initResource(resource);
   return resource;
 }
コード例 #6
0
 @Path("user-storage")
 public UserStorageProviderResource userStorage() {
   UserStorageProviderResource fed = new UserStorageProviderResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(fed);
   // resourceContext.initResource(fed);
   return fed;
 }
コード例 #7
0
 @Path("client-registration-policy")
 public ClientRegistrationPolicyResource getClientRegistrationPolicy() {
   ClientRegistrationPolicyResource resource =
       new ClientRegistrationPolicyResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   return resource;
 }
コード例 #8
0
  /**
   * Base path for the admin REST API for one particular realm.
   *
   * @param headers
   * @param name realm name (not id!)
   * @return
   */
  @Path("{realm}")
  public RealmAdminResource getRealmAdmin(
      @Context final HttpHeaders headers, @PathParam("realm") final String name) {
    RealmManager realmManager = new RealmManager(session);
    RealmModel realm = realmManager.getRealmByName(name);
    if (realm == null) throw new NotFoundException("Realm not found.");

    if (!auth.getRealm().equals(realmManager.getKeycloakAdminstrationRealm())
        && !auth.getRealm().equals(realm)) {
      throw new ForbiddenException();
    }
    RealmAuth realmAuth;

    if (auth.getRealm().equals(realmManager.getKeycloakAdminstrationRealm())) {
      realmAuth = new RealmAuth(auth, realm.getMasterAdminClient());
    } else {
      realmAuth =
          new RealmAuth(
              auth, realm.getClientByClientId(realmManager.getRealmAdminClientId(auth.getRealm())));
    }

    AdminEventBuilder adminEvent = new AdminEventBuilder(realm, auth, session, clientConnection);
    session.getContext().setRealm(realm);

    RealmAdminResource adminResource =
        new RealmAdminResource(realmAuth, realm, tokenManager, adminEvent);
    ResteasyProviderFactory.getInstance().injectProperties(adminResource);
    // resourceContext.initResource(adminResource);
    return adminResource;
  }
コード例 #9
0
  private void initializeProviderFactory() {
    if (providerFactory == null) {
      providerFactory = ResteasyProviderFactory.getInstance();
      RegisterBuiltin.register(providerFactory);

      // String converters
      providerFactory.addStringConverter(BusinessArchiveStringConverter.class);
      providerFactory.addStringConverter(HashMapStringConverter.class);
      providerFactory.addStringConverter(MapStringConverter.class);
      providerFactory.addStringConverter(AttachementInstanceStringConverter.class);
      providerFactory.addStringConverter(ActivityInstanceStringConverter.class);
      providerFactory.addStringConverter(ActivityInstanceImplStringConverter.class);
      providerFactory.addStringConverter(GenericObjectStringConverter.class);
      providerFactory.addStringConverter(RuleStringConverter.class);
      providerFactory.addStringConverter(DateStringConverter.class);

      // providers
      providerFactory.registerProvider(GenericObjectProvider.class);
      providerFactory.registerProvider(OctectStreamProvider.class);

      // interceptors
      providerFactory.registerProvider(RESTClientExecutionInterceptor.class);

      // client errorInterceptor
      providerFactory.addClientErrorInterceptor(new BonitaClientErrorInterceptor());
    }
  }
コード例 #10
0
 @Path("oauth-clients")
 public OAuthClientsResource getOAuthClients() {
   OAuthClientsResource oauth = new OAuthClientsResource(realm, auth, session);
   ResteasyProviderFactory.getInstance().injectProperties(oauth);
   // resourceContext.initResource(oauth);
   return oauth;
 }
コード例 #11
0
 /**
  * Base path for managing client initial access tokens
  *
  * @return
  */
 @Path("clients-trusted-hosts")
 public ClientRegistrationTrustedHostResource getClientRegistrationTrustedHost() {
   ClientRegistrationTrustedHostResource resource =
       new ClientRegistrationTrustedHostResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   return resource;
 }
コード例 #12
0
  @Test
  public void testCacheControl() {
    MyProviderReader reader = new MyProviderReader();
    ResteasyProviderFactory.getInstance().registerProviderInstance(reader);

    Assert.assertNotNull(reader.headers);
    Assert.assertNotNull(reader.workers);
  }
コード例 #13
0
ファイル: AdminRoot.java プロジェクト: appcube/keycloak
 /**
  * path to realm admin console ui
  *
  * @param name Realm name (not id!)
  * @return
  */
 @Path("{realm}/console")
 public AdminConsole getAdminConsole(final @PathParam("realm") String name) {
   RealmManager realmManager = new RealmManager(session);
   RealmModel realm = locateRealm(name, realmManager);
   AdminConsole service = new AdminConsole(realm);
   ResteasyProviderFactory.getInstance().injectProperties(service);
   return service;
 }
コード例 #14
0
 @Path("authentication")
 public AuthenticationManagementResource flows() {
   AuthenticationManagementResource resource =
       new AuthenticationManagementResource(realm, session, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   // resourceContext.initResource(resource);
   return resource;
 }
コード例 #15
0
ファイル: SamlService.java プロジェクト: gautric/keycloak
  @POST
  @NoCache
  @Consumes({"application/soap+xml", MediaType.TEXT_XML})
  public Response soapBinding(InputStream inputStream) {
    SamlEcpProfileService bindingService = new SamlEcpProfileService(realm, event);

    ResteasyProviderFactory.getInstance().injectProperties(bindingService);

    return bindingService.authenticate(inputStream);
  }
コード例 #16
0
ファイル: ClientResource.java プロジェクト: stianst/keycloak
  @Path("/authz")
  public AuthorizationService authorization() {
    ProfileHelper.requireFeature(Profile.Feature.AUTHORIZATION);

    AuthorizationService resource = new AuthorizationService(this.session, this.client, this.auth);

    ResteasyProviderFactory.getInstance().injectProperties(resource);

    return resource;
  }
コード例 #17
0
  @BeforeTest
  public void beforeTest() throws URISyntaxException {
    RegisterBuiltin.register(ResteasyProviderFactory.getInstance());

    final ClientRequestFactory clientRequestFactory =
        new ClientRequestFactory(
            new ApacheHttpClientExecutor(new HttpClient(new MultiThreadedHttpConnectionManager())),
            new URI("http://localhost:9095/api")
            //                new URI("http://localhost:8080/device/api")
            );
    api = clientRequestFactory.createProxy(Api.class);
  }
コード例 #18
0
  @Path("{id}/role-mappings")
  public RoleMapperResource getRoleMappings(@PathParam("id") String id) {

    UserModel user = session.users().getUserById(id, realm);
    if (user == null) {
      throw new NotFoundException("User not found");
    }
    auth.init(RealmAuth.Resource.USER);

    RoleMapperResource resource = new RoleMapperResource(realm, auth, user, adminEvent);
    ResteasyProviderFactory.getInstance().injectProperties(resource);
    return resource;
  }
コード例 #19
0
  public void service(
      ChannelHandlerContext ctx, HttpRequest request, HttpResponse response, boolean handleNotFound)
      throws IOException {

    try {
      ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
      if (defaultInstance instanceof ThreadLocalResteasyProviderFactory) {
        ThreadLocalResteasyProviderFactory.push(providerFactory);
      }

      SecurityContext securityContext;
      if (domain != null) {
        securityContext = basicAuthentication(request, response);
        if (securityContext == null) // not authenticated
        {
          return;
        }
      } else {
        securityContext = new NettySecurityContext();
      }
      try {

        ResteasyProviderFactory.pushContext(ChannelHandlerContext.class, ctx);
        ResteasyProviderFactory.pushContext(SecurityContext.class, securityContext);
        if (handleNotFound) {
          dispatcher.invoke(request, response);
        } else {
          dispatcher.invokePropagateNotFound(request, response);
        }
      } finally {
        ResteasyProviderFactory.clearContextData();
      }
    } finally {
      ResteasyProviderFactory defaultInstance = ResteasyProviderFactory.getInstance();
      if (defaultInstance instanceof ThreadLocalResteasyProviderFactory) {
        ThreadLocalResteasyProviderFactory.pop();
      }
    }
  }
コード例 #20
0
 @BeforeTest
 public void beforeTest() {
   RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
   try {
     properties.load(
         Thread.currentThread().getContextClassLoader().getResourceAsStream(PROPERTIES_FILENAME));
     client =
         ProxyFactory.create(
             CKANClientAction.class, (String) properties.get(PROPERTY_NAME_CKAN_URL));
   } catch (IOException e) {
     log.error("loading properties file", e);
     client = ProxyFactory.create(CKANClientAction.class, "http://localhost:5000");
   }
 }
コード例 #21
0
  /**
   * Helps initialize a new abstract service client impl instance.
   *
   * @throws Exception
   */
  private void init() throws Exception {
    if (properties.isEmpty() == true) {
      throw new Exception("Client connection properties are empty.  Cannot proceed.");
    }

    try {
      setupHttpClient();
      setupHttpClient4(); // temp fix for CSPACE-6281
    } catch (Exception e) {
      throw new RuntimeException(e.getMessage());
    }

    ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
    RegisterBuiltin.register(factory);
    setProxy();
  }
コード例 #22
0
ファイル: AdminRoot.java プロジェクト: appcube/keycloak
  /**
   * General information about the server
   *
   * @param headers
   * @return
   */
  @Path("serverinfo")
  public ServerInfoAdminResource getServerInfo(@Context final HttpHeaders headers) {
    handlePreflightRequest();

    AdminAuth auth = authenticateRealmAdminRequest(headers);
    if (auth != null) {
      logger.debug("authenticated admin access for: " + auth.getUser().getUsername());
    }
    Cors.add(request)
        .allowedOrigins(auth.getToken())
        .allowedMethods("GET", "PUT", "POST", "DELETE")
        .auth()
        .build(response);

    ServerInfoAdminResource adminResource = new ServerInfoAdminResource();
    ResteasyProviderFactory.getInstance().injectProperties(adminResource);
    // resourceContext.initResource(adminResource);
    return adminResource;
  }
コード例 #23
0
  private void init(String url, String login, String password, boolean insecure) throws Exception {
    HttpClient client = HttpUtility.threadSafeClient();
    if (insecure) {
      HttpUtility.setInsecureAccess(client);
    }
    SchedulerRestClient restApiClient =
        new SchedulerRestClient(url, new ApacheHttpClient4Engine(client));

    ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
    factory.register(new WildCardTypeReader());
    factory.register(new OctetStreamReader());
    factory.register(new TaskResultReader());

    setApiClient(restApiClient);

    this.url = url;
    this.login = login;
    this.password = password;

    renewSession();
  }
コード例 #24
0
ファイル: ServiceFactory.java プロジェクト: nirvanarico/pics
 static {
   RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
 }
コード例 #25
0
ファイル: ContextTest.java プロジェクト: psakar/Resteasy
 @Test
 public void testEcho() {
   RegisterBuiltin.register(ResteasyProviderFactory.getInstance());
   ResourceInterface client = ProxyFactory.create(ResourceInterface.class, generateBaseUrl());
   Assert.assertEquals("content", client.echo(null));
 }
コード例 #26
0
 /**
  * Base path for managing client initial access tokens
  *
  * @return
  */
 @Path("clients-initial-access")
 public ClientInitialAccessResource getClientInitialAccess() {
   ClientInitialAccessResource resource = new ClientInitialAccessResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   return resource;
 }
コード例 #27
0
 @Path("groups")
 public GroupsResource getGroups() {
   GroupsResource resource = new GroupsResource(realm, session, this.auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   return resource;
 }
コード例 #28
0
 /**
  * Base path for managing components under this realm.
  *
  * @return
  */
 @Path("components")
 public ComponentResource getComponents() {
   ComponentResource resource = new ComponentResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(resource);
   return resource;
 }
コード例 #29
0
ファイル: Hornetq.java プロジェクト: igorhvr/hornetq
 /**
  * Extract an object using a built-in RESTEasy JAX-RS MessageBodyReader
  *
  * @param message
  * @param type
  * @param <T>
  * @return
  */
 public static <T> T getEntity(ClientMessage message, Class<T> type) {
   return getEntity(message, type, null, ResteasyProviderFactory.getInstance());
 }
コード例 #30
0
 /**
  * Base path for managing client templates under this realm.
  *
  * @return
  */
 @Path("client-templates")
 public ClientTemplatesResource getClientTemplates() {
   ClientTemplatesResource clientsResource = new ClientTemplatesResource(realm, auth, adminEvent);
   ResteasyProviderFactory.getInstance().injectProperties(clientsResource);
   return clientsResource;
 }