Menu

Remotely call EJBCA EJB API

Help
Roman
2016-01-25
2016-01-25
  • Roman

    Roman - 2016-01-25

    This is my configuration:
    EJBCA 6.3.1.1 running on JBoss 7.1.1.Final and Java 7

    I am trying to build remote client (not on EJBCA server) which will use remote EJB to access logic on EJBCA.
    So for the basic I tried to do the following call, inspired by EJCBA CLI module:

    Set<Principal> principals = new HashSet<Principal>();
            principals.add(new UsernamePrincipal("ejbca"));
    
            AuthenticationSubject subject = new AuthenticationSubject(principals, null);
    
            CliAuthenticationToken authenticationToken = (CliAuthenticationToken) EjbRemoteHelper.INSTANCE.getRemoteSession(CliAuthenticationProviderSessionRemote.class).authenticate(subject);
            if (authenticationToken == null) {
                System.out.println("AuthenticationToken : null");
            } else {
                // Set hashed value anew in order to send back
                authenticationToken.setSha1HashFromCleartextPassword("ejbca");
            }
    

    I have also set in my class path the following files:
    jndi.properties:

    # JBoss 7
    java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
    # To run remote EJB you also need jboss-ejb-client.properties in your classpath
    

    jboss-ejb-client.properties:

    remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
    remote.connections=default
    remote.connection.default.host=IPaddress of my server
    remote.connection.default.port = 4447
    remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
    

    When I try to run the client code, I get the following exception:

    Exception in thread "main" java.lang.IllegalStateException: No EJB receiver available for handling [appName:ejbca,modulename:ejbca-ejb,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@64423419
        at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
        at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
        at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
        at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
        at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
        at com.sun.proxy.$Proxy0.authenticate(Unknown Source)
        at TestRemoteEJBCA.main(TestRemoteEJBCA.java:28)
    

    I checked that on the server side that it is listening on port 4447 for remote clients and from server log I see that EJB was correctly deployed.

    How to call it? Is there anything else that should be configured to call EJBCA EJB?

     
  • Tomas Gustavsson

    If the EJBCA CLI works, EJBCA runs correctly.

     

Log in to post a comment.