Example usage for java.lang IllegalAccessException IllegalAccessException

List of usage examples for java.lang IllegalAccessException IllegalAccessException

Introduction

In this page you can find the example usage for java.lang IllegalAccessException IllegalAccessException.

Prototype

public IllegalAccessException(String s) 

Source Link

Document

Constructs an IllegalAccessException with a detail message.

Usage

From source file:ru.org.linux.auth.BanIPController.java

@RequestMapping(value = "/banip.jsp", method = RequestMethod.POST)
public ModelAndView banIP(HttpServletRequest request, @RequestParam("ip") String ip,
        @RequestParam("reason") String reason, @RequestParam("time") String time,
        @RequestParam(value = "allow_posting", required = false, defaultValue = "false") boolean allowPosting,
        @RequestParam(value = "captcha_required", required = false, defaultValue = "false") boolean captchaRequired)
        throws Exception {
    Template tmpl = Template.getTemplate(request);

    if (!tmpl.isModeratorSession()) {
        throw new IllegalAccessException("Not authorized");
    }//from   w  w w  .j av a2 s  . co  m

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    if ("hour".equals(time)) {
        calendar.add(Calendar.HOUR_OF_DAY, 1);
    } else if ("day".equals(time)) {
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    } else if ("month".equals(time)) {
        calendar.add(Calendar.MONTH, 1);
    } else if ("3month".equals(time)) {
        calendar.add(Calendar.MONTH, 3);
    } else if ("6month".equals(time)) {
        calendar.add(Calendar.MONTH, 6);
    } else if ("remove".equals(time)) {
    } else if ("custom".equals(time)) {
        int days = ServletRequestUtils.getRequiredIntParameter(request, "ban_days");

        if (days <= 0 || days > 180) {
            throw new UserErrorException("Invalid days count");
        }

        calendar.add(Calendar.DAY_OF_MONTH, days);
    }

    Timestamp ts;
    if ("unlim".equals(time)) {
        ts = null;
    } else {
        ts = new Timestamp(calendar.getTimeInMillis());
    }

    User user = tmpl.getCurrentUser();

    user.checkCommit();

    ipBlockDao.blockIP(ip, user, reason, ts, allowPosting, captchaRequired);

    return new ModelAndView(new RedirectView("sameip.jsp?ip=" + URLEncoder.encode(ip, "UTF-8")));
}

From source file:org.slc.sli.api.migration.strategy.impl.AddFieldStrategy.java

@Override
public EntityBody migrate(EntityBody entity) throws MigrationException {
    // This strategy should always expect a list
    throw new MigrationException(new IllegalAccessException("This method is not yet implemented"));
}

From source file:com.reactive.hzdfs.utils.GsonWrapper.java

/**
 * Register another type adaptor for Json serialization
 * @param adaptor/* ww w  .  j a va 2s .co m*/
 * @throws IllegalAccessException if already initialized
 */
public void registerTypeAdapter(AbstractJsonSerializer<?> adaptor) throws IllegalAccessException {
    if (alreadyBuilt)
        throw new IllegalAccessException("Gson already initialized");
    typeAdapters.add(adaptor);
}

From source file:org.apache.syncope.client.cli.commands.install.InstallSetup.java

public void setup() throws FileNotFoundException, IllegalAccessException {
    installResultManager.printWelcome();

    System.out.println(/*  www .  java 2 s .c o  m*/
            "Path to config files of Syncope CLI client will be: " + InstallConfigFileTemplate.dirPath());

    if (!FileSystemUtils.exists(InstallConfigFileTemplate.dirPath())) {
        throw new FileNotFoundException(
                "Directory: " + InstallConfigFileTemplate.dirPath() + " does not exists!");
    }

    if (!FileSystemUtils.canWrite(InstallConfigFileTemplate.dirPath())) {
        throw new IllegalAccessException("Permission denied on " + InstallConfigFileTemplate.dirPath());
    }
    System.out.println("- File system permission checked");
    System.out.println("");

    try (Scanner scanIn = new Scanner(System.in)) {
        System.out.print("Syncope server schema [http/https]: ");
        String syncopeServerSchemaFromSystemIn = scanIn.nextLine();
        boolean schemaFound = false;
        while (!schemaFound) {
            if (("http".equalsIgnoreCase(syncopeServerSchemaFromSystemIn))
                    || ("https".equalsIgnoreCase(syncopeServerSchemaFromSystemIn))) {
                syncopeServerSchema = syncopeServerSchemaFromSystemIn;
                schemaFound = true;
            } else {
                System.out.println("Please use one of below values: ");
                System.out.println("   - http");
                System.out.println("   - https");
                syncopeServerSchemaFromSystemIn = scanIn.nextLine();
            }
        }

        System.out.print("Syncope server hostname [e.g. " + syncopeServerHostname + "]: ");
        String syncopeServerHostnameFromSystemIn = scanIn.nextLine();
        boolean syncopeServerHostnameFound = false;
        while (!syncopeServerHostnameFound) {
            if (StringUtils.isNotBlank(syncopeServerHostnameFromSystemIn)) {
                syncopeServerHostname = syncopeServerHostnameFromSystemIn;
                syncopeServerHostnameFound = true;
            } else {
                System.out.print("Syncope server hostname [e.g. " + syncopeServerHostname + "]: ");
                syncopeServerHostnameFromSystemIn = scanIn.nextLine();
            }
        }

        System.out.print("Syncope server port [e.g. " + syncopeServerPort + "]: ");
        String syncopeServerPortFromSystemIn = scanIn.nextLine();
        boolean syncopeServerPortFound = false;
        while (!syncopeServerPortFound) {
            if (StringUtils.isNotBlank(syncopeServerPortFromSystemIn)) {
                syncopeServerPort = syncopeServerPortFromSystemIn;
                syncopeServerPortFound = true;
            } else if (!StringUtils.isNumeric(syncopeServerPortFromSystemIn)) {
                System.err.println(syncopeServerPortFromSystemIn + " is not a numeric string, try again");
                syncopeServerPortFromSystemIn = scanIn.nextLine();
            } else {
                System.out.print("Syncope server port [e.g. " + syncopeServerPort + "]: ");
                syncopeServerPortFromSystemIn = scanIn.nextLine();
            }
        }

        System.out.print("Syncope server rest context [e.g. " + syncopeServerRestContext + "]: ");
        String syncopeServerRestContextFromSystemIn = scanIn.nextLine();
        boolean syncopeServerRestContextFound = false;
        while (!syncopeServerRestContextFound) {
            if (StringUtils.isNotBlank(syncopeServerRestContextFromSystemIn)) {
                syncopeServerRestContext = syncopeServerRestContextFromSystemIn;
                syncopeServerRestContextFound = true;
            } else {
                System.out.print("Syncope server port [e.g. " + syncopeServerRestContext + "]: ");
                syncopeServerRestContextFromSystemIn = scanIn.nextLine();
            }
        }

        System.out.print("Syncope admin user: ");
        String syncopeAdminUserFromSystemIn = scanIn.nextLine();
        boolean syncopeAdminUserFound = false;
        while (!syncopeAdminUserFound) {
            if (StringUtils.isNotBlank(syncopeAdminUserFromSystemIn)) {
                syncopeAdminUser = syncopeAdminUserFromSystemIn;
                syncopeAdminUserFound = true;
            } else {
                System.out.print("Syncope admin user: ");
                syncopeAdminUserFromSystemIn = scanIn.nextLine();
            }
        }

        char[] syncopeAdminPasswordFromSystemConsole = System.console()
                .readPassword("Syncope admin password: ");
        boolean syncopeAdminPasswordFound = false;
        while (!syncopeAdminPasswordFound) {
            if (syncopeAdminPasswordFromSystemConsole != null
                    && syncopeAdminPasswordFromSystemConsole.length > 0) {
                syncopeAdminPassword = new String(syncopeAdminPasswordFromSystemConsole);
                syncopeAdminPasswordFound = true;
            } else {
                syncopeAdminPasswordFromSystemConsole = System.console()
                        .readPassword("Syncope admin password: ");
            }
        }
    }

    final JasyptUtils jasyptUtils = JasyptUtils.get();
    try {

        final String contentCliPropertiesFile = InstallConfigFileTemplate.cliPropertiesFile(syncopeServerSchema,
                syncopeServerHostname, syncopeServerPort, syncopeServerRestContext, syncopeAdminUser,
                jasyptUtils.encrypt(syncopeAdminPassword));
        FileSystemUtils.createFileWith(InstallConfigFileTemplate.configurationFilePath(),
                contentCliPropertiesFile);
    } catch (final IOException ex) {
        System.out.println(ex.getMessage());
    }

    try {
        final SyncopeService syncopeService = SyncopeServices.get(SyncopeService.class);
        final String syncopeVersion = syncopeService.platform().getVersion();
        installResultManager.installationSuccessful(syncopeVersion);
    } catch (final ProcessingException ex) {
        LOG.error("Error installing CLI", ex);
        installResultManager.manageProcessingException(ex);
    } catch (final Exception e) {
        LOG.error("Error installing CLI", e);
        installResultManager.manageException(e);
    }
}

From source file:org.slc.sli.dal.migration.strategy.impl.AddStrategy.java

@Override
public List<Entity> migrate(List<Entity> entityList) throws MigrationException {
    // This strategy should always expect a single entity
    throw new MigrationException(new IllegalAccessException("This method is not yet implemented"));
}

From source file:org.apache.hadoop.chukwa.datastore.WidgetStore.java

public void set(WidgetBean widget) throws IllegalAccessException {
    try {//  www  .  java  2  s  . c  o m
        StringBuilder widgetPath = new StringBuilder();
        widgetPath.append(hiccPath);
        widgetPath.append(File.separator);
        widgetPath.append(widget.getId());
        widgetPath.append(".descriptor");
        Path widgetFile = new Path(widgetPath.toString());
        FileSystem fs;
        try {
            fs = FileSystem.get(config);
            FSDataOutputStream out = fs.create(widgetFile, true);
            out.writeUTF(widget.deserialize().toString());
            out.close();
        } catch (IOException ex) {
            log.error(ExceptionUtil.getStackTrace(ex));
        }
        cacheWidgets();
    } catch (Exception e) {
        log.error(ExceptionUtil.getStackTrace(e));
        throw new IllegalAccessException("Unable to access user view database.");
    }
}

From source file:madkitgroupextension.export.Export.java

public Export(boolean _export_source, boolean _include_madkit, boolean _export_only_jar_file)
        throws IllegalAccessException, NumberFormatException, IOException {
    m_export_source = _export_source;//from  ww  w  . j  av a 2s  .  c  o  m
    m_include_madkit = _include_madkit;
    m_export_only_jar_file = _export_only_jar_file;

    File current_directory = new File(MadKitPath);
    if (!current_directory.exists())
        throw new IllegalAccessException("The Madkit path is invalid: " + MadKitPath);
    Pattern pattern = Pattern.compile("^madkit-.*\\.jar$");
    for (File f : current_directory.listFiles()) {

        if (f.isFile() && pattern.matcher(f.getName()).matches()) {
            m_madkit_jar_file = f;
            m_madkit_version = f.getName().substring(7, f.getName().lastIndexOf("."));
            break;
        }
    }
    if (m_madkit_jar_file == null)
        throw new IllegalAccessException("Impossible to found the MadKit jar file !");

    File f = new File("build.txt");
    if (f.exists()) {
        FileReader fr = new FileReader(f);
        BufferedReader bf = new BufferedReader(fr);
        MadKitGroupExtension.VERSION.setBuildNumber(Integer.parseInt(bf.readLine()));
        bf.close();
        fr.close();
    }
}

From source file:no.abmu.abmstatistikk.annualstatistic.util.DataLoaderH2.java

public DataLoaderH2(String[] args) {
    parseOpts(args);//w  w w.  ja  v  a2s .  c om

    Properties properties = new Properties();
    String hibFile = System.getProperty(HIB_FILE_KEY, "conf/hibernate/hibernate.properties");
    try {
        properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream(hibFile));
        dialect = (String) properties.get(HIB_DIALECT_KEY);
        if (dialect == null) {
            throw new IllegalAccessException("The file " + hibFile + " had no key " + HIB_DIALECT_KEY);
        }

    } catch (Exception e) {
        initException = e;
    }

    System.getProperties().setProperty("applicationContextConfig", "conf/spring/application-context.xml");
    System.getProperties().setProperty("config_locs_cp",
            "conf/spring/appContext-util.xml," + "conf/spring/appContext-configuration.xml,"
                    + "conf/spring/appContext-db-dataLayer.xml,"
                    + "conf/spring/appContext-service-orgRegister.xml,"
                    + "conf/spring/appContext-service-annualStatistic.xml,"
                    + "conf/spring/appContext-service-user.xml");
    /*
    +
        "conf/spring/appContext-security.xml"
        */
    System.getProperties().setProperty("config_locs", "");
    ApplicationContextLoaderH2.getInstance().init();

    context = ApplicationContextLoaderH2.getInstance().getApplicationContext();
    asService = (AnnualStatisticService) ApplicationContextLoaderH2.getInstance().getApplicationContext()
            .getBean("AnnualStatisticService");
    organisationUnitService = (OrganisationUnitService) ApplicationContextLoaderH2.getInstance()
            .getApplicationContext().getBean("organisationUnitService");
    if (organisationUnitService == null) {
        log.error("Couldn't find organisationUnitService bean");
    }
    loadData();
}

From source file:org.rhq.enterprise.server.rest.ReportsInterceptor.java

@AroundInvoke
public Object setCaller(final InvocationContext ctx) throws Exception {
    AbstractRestBean target = (AbstractRestBean) ctx.getTarget();

    boolean fromRest = false;
    // If we are "forwarded" from the "normal" rest-api, we have a principal, that we can use
    java.security.Principal p = ejbContext.getCallerPrincipal();
    if (p != null) {
        target.caller = subjectManager.getSubjectByName(p.getName());
        fromRest = true;/* ww w  .j  av  a  2  s.c  o  m*/
    }

    // If no caller was set from the "normal" api, we need to check if it is
    // available in cookies, as in this case we were invoked
    // from the Coregui reports function
    if (target.caller == null) {
        HttpServletRequest request = getRequest(ctx.getParameters());
        if (request == null) {
            // TODO should we throw a different exception?
            String msg = "No " + HttpServletRequest.class.getName() + " parameter was found for "
                    + getMethodName(ctx) + ". An " + HttpServletRequest.class.getName()
                    + " parameter must be specified in order to support authentication";
            log.error(msg);
            throw new OperationNotSupportedException(msg);
        }

        Subject subject = getSubject(request);
        if (subject == null) {
            throw new IllegalAccessException(
                    "Failed to validate request: could not access subject for request URL "
                            + request.getRequestURL());
        }

        target.caller = subject;
    }

    // Invoke the target method
    Object result = ctx.proceed();

    if (result instanceof StreamingOutput) {
        return new LoggingStreamingOutput((StreamingOutput) result, getMethodName(ctx));
    }

    // TODO invalidate session?

    return result;
}

From source file:org.apache.hadoop.chukwa.datastore.UserStore.java

public void init(String uid) throws IllegalAccessException {
    StringBuilder profilePath = new StringBuilder();
    profilePath.append(hiccPath);// w ww .j ava  2s . co  m
    profilePath.append(File.separator);
    profilePath.append(uid);
    profilePath.append(".profile");
    Path profileFile = new Path(profilePath.toString());
    FileSystem fs;
    try {
        fs = FileSystem.get(config);
        if (fs.exists(profileFile)) {
            FileStatus[] fstatus = fs.listStatus(profileFile);
            long size = fstatus[0].getLen();
            FSDataInputStream viewStream = fs.open(profileFile);
            byte[] buffer = new byte[(int) size];
            viewStream.readFully(buffer);
            viewStream.close();
            try {
                JSONObject json = new JSONObject(new String(buffer));
                profile = new UserBean(json);
            } catch (Exception e) {
                log.error(ExceptionUtil.getStackTrace(e));
                throw new IllegalAccessException("Unable to access user profile database.");
            }
        } else {
            profile = new UserBean();
            profile.setId(uid);
            JSONArray ja = new JSONArray();
            profile.setViews(ja);
            JSONObject json = new JSONObject();
            profile.setProperties(json.toString());
        }
    } catch (IOException ex) {
        log.error(ExceptionUtil.getStackTrace(ex));
    }
}