Example usage for javax.xml.registry LifeCycleManager USER

List of usage examples for javax.xml.registry LifeCycleManager USER

Introduction

In this page you can find the example usage for javax.xml.registry LifeCycleManager USER.

Prototype

String USER

To view the source code for javax.xml.registry LifeCycleManager USER.

Click Source Link

Document

Constant representing the javax.xml.registry.infomodel.User interface.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.RegistryFacadeTest.java

public void testRemoveRegisteredUser() throws Exception {
    facade.logoff();/*w  w w.ja  va  2 s .c  o m*/

    String alias = user.getKey().getId();
    String keypass = alias;
    facade.logon(alias, keypass);

    //Remove the test user
    //Specify user for deletion using query
    it.cnr.icar.eric.client.xml.registry.infomodel.AdhocQueryImpl ahq = (it.cnr.icar.eric.client.xml.registry.infomodel.AdhocQueryImpl) facade
            .getLifeCycleManager().createObject("AdhocQuery");
    ahq.setString("SELECT u.* FROM User_ u WHERE u.id = '" + user.getKey().getId() + "'");

    //Now do the delete
    BulkResponse br = facade.getLifeCycleManager().deleteObjects(new ArrayList<Object>(), ahq,
            forceRemoveRequestSlotsMap, null);
    assertTrue("User removal failed.", br.getStatus() == BulkResponse.STATUS_SUCCESS);

    //Now make sure that user is indeed removed
    User u = (User) facade.getDeclarativeQueryManager().getRegistryObject(user.getKey().getId(),
            LifeCycleManager.USER);
    assertNull("USer removal failed.", u);

    //A bit of a hack that only works in localCall=true mode. Otherwise the following sub-test is skipped safely.
    //If in localCall mode then make sure that deleting the user aslo deleted the alias/cert in keystore
    //Tests Bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1010978&group_id=37074&atid=418900
    if (((ConnectionImpl) facade.getConnection()).isLocalCallMode()) {
        AuthenticationServiceImpl auth = AuthenticationServiceImpl.getInstance();

        try {
            Certificate serverCert = auth.getCertificate(alias);
            assertTrue("Cert was not deleted from keystore when user was deleted from server.",
                    (null == serverCert));
        } catch (RegistryException e) {
            //Good. Expected.
            //Should really throw a new CertificateNotFoundException.
        }
    }
}