use of org.owasp.esapi.errors.ValidationException in project Asqatasun by Asqatasun.
the class TokenManager method getTokenUser.
/**
*
* @param userAccountName
* @param additionalParameters
* @return
*/
public String getTokenUser(String userAccountName, Map<String, String> additionalParameters) {
try {
CryptoToken cryptoToken = new CryptoToken();
cryptoToken.setUserAccountName(userAccountName);
cryptoToken.setExpiration(tokenDurationValidity);
cryptoToken.addAttributes(additionalParameters);
String token = cryptoToken.getToken();
tokenUsage.put(token, Boolean.FALSE);
return token;
} catch (EncryptionException ex) {
Logger.getLogger(this.getClass()).warn(ex);
return "";
} catch (ValidationException ex) {
Logger.getLogger(this.getClass()).warn(ex);
return "";
}
}
use of org.owasp.esapi.errors.ValidationException in project simba-os by cegeka.
the class PolicyServiceImpl method createPolicy.
@Override
public TPolicy createPolicy(String policyName) throws TException {
return simbaExceptionHandlingCaller.call(() -> {
try {
DTOValidator.assertValidString("createRole", policyName);
if (roleRepository.findByName(policyName) != null) {
throw new IllegalArgumentException("Policy with name " + policyName + " already exists");
}
Policy newPolicy = new PolicyEntity(policyName);
policyRepository.persist(newPolicy);
audit.log("Policy ''{0}'' created", policyName);
return assembler.assemble(newPolicy);
} catch (ValidationException e) {
throw new IllegalArgumentException(e);
}
});
}
use of org.owasp.esapi.errors.ValidationException in project simba-os by cegeka.
the class RoleServiceImpl method createRole.
public TRole createRole(String roleName) throws TException {
return simbaExceptionHandlingCaller.call(() -> {
try {
DTOValidator.assertValidString("createRole", roleName);
if (roleRepository.findByName(roleName) != null) {
throw new IllegalArgumentException("Role with name " + roleName + " already exists");
}
Role newRole = new RoleEntity(roleName);
roleRepository.persist(newRole);
managementAudit.log("Role ''{0}'' created", roleName);
return assembler.assemble(newRole);
} catch (ValidationException e) {
throw new IllegalArgumentException(e);
}
});
}
use of org.owasp.esapi.errors.ValidationException in project Asqatasun by Asqatasun.
the class TokenManager method getTokenUser.
/**
*
* @param userAccountName
* @return
*/
public String getTokenUser(String userAccountName) {
try {
CryptoToken cryptoToken = new CryptoToken();
cryptoToken.setUserAccountName(userAccountName);
cryptoToken.setExpiration(tokenDurationValidity);
String token = cryptoToken.getToken();
tokenUsage.put(token, Boolean.FALSE);
return token;
} catch (EncryptionException ex) {
Logger.getLogger(this.getClass()).warn(ex);
return "";
} catch (ValidationException ex) {
Logger.getLogger(this.getClass()).warn(ex);
return "";
}
}
use of org.owasp.esapi.errors.ValidationException in project Asqatasun by Asqatasun.
the class TokenManager method getTokenUser.
/**
* @param userAccountName
* @param additionalParameters
* @return
*/
public String getTokenUser(String userAccountName, Map<String, String> additionalParameters) {
try {
CryptoToken cryptoToken = new CryptoToken();
cryptoToken.setUserAccountName(userAccountName);
cryptoToken.setExpiration(tokenDurationValidity);
cryptoToken.addAttributes(additionalParameters);
String token = cryptoToken.getToken();
tokenUsage.put(token, Boolean.FALSE);
return token;
} catch (EncryptionException | ValidationException ex) {
LOGGER.warn(ex.getMessage());
return "";
}
}
Aggregations