@Override
    public void handle(String chargingStationId, JsonObject commandObject, IdentityContext identityContext) throws UserIdentityUnauthorizedException {
        ChargingStationId csId = new ChargingStationId(chargingStationId);

        if (!commandAuthorizationService.isAuthorized(csId, identityContext.getUserIdentity(), GrantPermissionCommand.class)) {
            throw new UserIdentityUnauthorizedException(chargingStationId, identityContext.getUserIdentity(), GrantPermissionCommand.class);
        }

        try {
            ChargingStation chargingStation = repository.findOne(chargingStationId);

            if (chargingStation != null && chargingStation.isAccepted()) {
                GrantPermissionApiCommand command = gson.fromJson(commandObject, GrantPermissionApiCommand.class);

                Class commandClass = Class.forName(command.getCommandClass());
                UserIdentity userIdentity = new SimpleUserIdentity(command.getUserIdentity());

                commandGateway.send(new GrantPermissionCommand(csId, userIdentity, commandClass, identityContext));
            }
        } catch (JsonSyntaxException ex) {
            throw new IllegalArgumentException("Grant permission command not able to parse the payload, is your json correctly formatted?", ex);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Grant permission command cannot instantiate class object for command class, is the passed command class value a valid class?", e);
        }
    }
@ Override public void handle ( String chargingStationId , JsonObject commandObject , IdentityContext identityContext ) throws UserIdentityUnauthorizedException { ChargingStationId csId = new ChargingStationId ( chargingStationId ) ; if ( ! commandAuthorizationService . isAuthorized ( csId , identityContext . getUserIdentity ( ) , GrantPermissionCommand . class ) ) { throw new UserIdentityUnauthorizedException ( chargingStationId , identityContext . getUserIdentity ( ) , GrantPermissionCommand . class ) ; } try { ChargingStation chargingStation = repository . findOne ( chargingStationId ) ; if ( chargingStation != null && chargingStation . isAccepted ( ) ) { GrantPermissionApiCommand command = gson . fromJson ( commandObject , GrantPermissionApiCommand . class ) ; Class commandClass = Class . forName ( command . getCommandClass ( ) ) ; UserIdentity userIdentity = new SimpleUserIdentity ( command . getUserIdentity ( ) ) ; commandGateway . send ( new GrantPermissionCommand ( csId , userIdentity , commandClass , identityContext ) ) ; } } catch ( JsonSyntaxException ex ) { throw new IllegalArgumentException ( "Grant permission command not able to parse the payload, is your json correctly formatted?" , ex ) ; } catch ( ClassNotFoundException e ) { throw new IllegalArgumentException ( "Grant permission command cannot instantiate class object for command class, is the passed command class value a valid class?" , e ) ; } }
{@inheritDoc}