Search in sources :

Example 1 with TicketServiceFactoryImpl

use of org.irods.jargon.ticket.TicketServiceFactoryImpl in project metalnx-web by irods-contrib.

the class TicketClientServiceImpl method setUpAccess.

/**
 * Sets up all necessary stuff for an anonymous user to be able to interact with the grid. This interaction means
 * iput & iget.
 */
private void setUpAccess() {
    try {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null || !(authentication.getDetails() instanceof UserTokenDetails)) {
            logger.warn("Accessing files and collections with tickets using anonymous account");
            irodsAccount = IRODSAccount.instanceForAnonymous(host, port, ANONYMOUS_HOME_DIRECTORY, zone, RESOURCE);
        } else {
            logger.warn("Accessing files and collections with tickets as authenticated user");
            irodsAccount = ((UserTokenDetails) authentication.getDetails()).getIrodsAccount();
        }
        TicketServiceFactory ticketServiceFactory = new TicketServiceFactoryImpl(irodsAccessObjectFactory);
        ticketClientOperations = ticketServiceFactory.instanceTicketClientOperations(irodsAccount);
    } catch (JargonException e) {
        logger.error("Could not set up anonymous access");
    }
}
Also used : TicketServiceFactory(org.irods.jargon.ticket.TicketServiceFactory) UserTokenDetails(com.emc.metalnx.services.auth.UserTokenDetails) TicketServiceFactoryImpl(org.irods.jargon.ticket.TicketServiceFactoryImpl) Authentication(org.springframework.security.core.Authentication)

Example 2 with TicketServiceFactoryImpl

use of org.irods.jargon.ticket.TicketServiceFactoryImpl in project metalnx-web by irods-contrib.

the class IRODSServicesImpl method getTicketAdminService.

@Override
public TicketAdminService getTicketAdminService() throws DataGridConnectionRefusedException {
    TicketAdminService tas = null;
    try {
        TicketServiceFactory tsf = new TicketServiceFactoryImpl(irodsAccessObjectFactory);
        tas = tsf.instanceTicketAdminService(irodsAccount);
    } catch (JargonException e) {
        logger.error("Could not instantiate ticket admin service: ", e.getMessage());
        if (e.getCause() instanceof ConnectException) {
            throw new DataGridConnectionRefusedException(e.getMessage());
        }
    }
    return tas;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) TicketServiceFactory(org.irods.jargon.ticket.TicketServiceFactory) TicketServiceFactoryImpl(org.irods.jargon.ticket.TicketServiceFactoryImpl) JargonException(org.irods.jargon.core.exception.JargonException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService) ConnectException(java.net.ConnectException)

Aggregations

TicketServiceFactory (org.irods.jargon.ticket.TicketServiceFactory)2 TicketServiceFactoryImpl (org.irods.jargon.ticket.TicketServiceFactoryImpl)2 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)1 UserTokenDetails (com.emc.metalnx.services.auth.UserTokenDetails)1 ConnectException (java.net.ConnectException)1 JargonException (org.irods.jargon.core.exception.JargonException)1 TicketAdminService (org.irods.jargon.ticket.TicketAdminService)1 Authentication (org.springframework.security.core.Authentication)1