use of org.eclipse.kapua.service.authorization.shiro.KapuaAuthorizationException in project kapua by eclipse.
the class PermissionFactoryImpl method parseString.
@Override
public Permission parseString(String stringPermission) throws KapuaException {
StringTokenizer st = new StringTokenizer(stringPermission, ":");
int iTokensCount = st.countTokens();
if (iTokensCount < 1 || iTokensCount > 3) {
throw new KapuaAuthorizationException(KapuaAuthorizationErrorCodes.INVALID_STRING_PERMISSION, null, stringPermission);
}
//
// Build the new Permission
String domain = st.nextToken();
Actions action = null;
if (iTokensCount > 1) {
action = Actions.valueOf(st.nextToken());
}
KapuaId scopeTargetId = null;
if (iTokensCount > 2) {
try {
BigInteger kapuaId = new BigInteger(st.nextToken());
scopeTargetId = new KapuaEid(kapuaId);
} catch (IllegalArgumentException iae) {
throw new KapuaAuthorizationException(KapuaAuthorizationErrorCodes.INVALID_STRING_PERMISSION, iae, stringPermission);
}
}
return new PermissionImpl(domain, action, scopeTargetId);
}
Aggregations