use of com.emc.metalnx.core.domain.exceptions.DataGridServerException in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method getDataGridResource.
private DataGridResource getDataGridResource(Resource irodsResource) {
logger.info("getDataGridResource()");
try {
long irodsResourceId = Long.valueOf(irodsResource.getId());
String irodsResourceName = irodsResource.getName();
String irodsResourceZone = irodsResource.getZone().getZoneName();
String irodsResourceType = irodsResource.getType();
String irodsResourcePath = irodsResource.getVaultPath();
long irodsResourceFreeSpace = irodsResource.getFreeSpace();
Date irodsResourceFreeSpaceTimeStamp = irodsResource.getFreeSpaceTime();
List<String> irodsResourceChildren = irodsResource.getImmediateChildren();
String irodsResourceParent = irodsResource.getParentName();
String irodsResourceStatus = irodsResource.getStatus();
String irodsResourceHost = irodsResource.getLocation();
Date irodsResourceCreateTime = irodsResource.getCreateTime();
Date irodsResourceModifyTime = irodsResource.getModifyTime();
String irodsResourceInfo = irodsResource.getInfo();
String irodsContextString = irodsResource.getContextString();
int irodsResourceTotalRecords = irodsResource.getTotalRecords();
if (irodsResourceParent == null || irodsResourceParent.isEmpty()) {
irodsResourceParent = irodsServices.getCurrentUserZone();
}
if (irodsResourceType == null || irodsResourceType.isEmpty()) {
irodsResourceType = irodsContextString;
}
DataGridResource newDataGridResource = new DataGridResource(irodsResourceId, irodsResourceName, irodsResourceZone, irodsResourceType, irodsResourcePath, irodsResourceFreeSpace, irodsResourceFreeSpaceTimeStamp, irodsResourceChildren, irodsResourceParent, irodsResourceStatus, irodsResourceHost, irodsResourceCreateTime, irodsResourceModifyTime, irodsResourceInfo, irodsResourceTotalRecords, irodsContextString);
logger.debug("got dataGridResource:{}", newDataGridResource);
return newDataGridResource;
} catch (Throwable t) {
logger.error("intercepted exception getting data grid resource", t);
throw new DataGridServerException(t.getMessage());
}
}
use of com.emc.metalnx.core.domain.exceptions.DataGridServerException in project metalnx-web by irods-contrib.
the class IRODSAuthenticationProvider method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = authentication.getCredentials().toString();
AuthResponse authResponse;
UsernamePasswordAuthenticationToken authObject;
logger.debug("Setting username {}", username);
try {
authResponse = this.authenticateAgainstIRODS(username, password);
// Settings iRODS account
this.irodsAccount = authResponse.getAuthenticatedIRODSAccount();
// Retrieving logging user
User irodsUser = new User();
try {
irodsUser = this.irodsAccessObjectFactory.getUserAO(this.irodsAccount).findByName(username);
} catch (JargonException e) {
logger.error("Could not find user: " + e.getMessage());
}
GrantedAuthority grantedAuth;
if (irodsUser.getUserType().equals(UserTypeEnum.RODS_ADMIN)) {
grantedAuth = new IRODSAdminGrantedAuthority();
} else {
grantedAuth = new IRODSUserGrantedAuthority();
}
// Settings granted authorities
List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>();
grantedAuths.add(grantedAuth);
// Returning authentication token with the access object factory injected
authObject = new UsernamePasswordAuthenticationToken(username, password, grantedAuths);
// Creating UserTokenDetails instance for the current authenticated user
UserTokenDetails userDetails = new UserTokenDetails();
userDetails.setIrodsAccount(this.irodsAccount);
userDetails.setUser(this.user);
// Settings the user details object into the authentication object
authObject.setDetails(userDetails);
} catch (TransactionException e) {
logger.error("Database not responding");
throw new DataGridDatabaseException(e.getMessage());
} catch (InvalidUserException | org.irods.jargon.core.exception.AuthenticationException e) {
logger.error("Could not authenticate user: ", username);
throw new DataGridAuthenticationException(e.getMessage());
} catch (JargonException e) {
logger.error("Server not responding");
throw new DataGridServerException(e.getMessage());
}
return authObject;
}
Aggregations