Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:it.geosolutions.geofence.gui.server.service.impl.LoginService.java

public User authenticate(String userName, String password, HttpSession session) throws ApplicationException {
    logger.info("Authenticating '" + userName + "'");

    GrantedAuths grantedAuths = null;//from  ww w  .  j ava  2s.  c o  m
    String token = null;

    try {
        URL url = Class.forName("it.geosolutions.geofence.gui.client.UserUI").getResource("client.keystore");
        String path = url.getPath();
        if (logger.isDebugEnabled()) {
            logger.debug(path);
        }
        System.setProperty("javax.net.ssl.trustStore", path);
        System.setProperty("javax.net.ssl.trustStorePassword", "geosolutions");

        GFUser matchingUser = null;

        // a backdoor!?! :o
        if (userName.equals("1nt3rnAL-G30r3p0-admin")) {
            matchingUser = new GFUser();
            matchingUser.setName(userName);
            matchingUser.setPassword("2c6fe6e260312c5aa94ef0ca42b0af");
        } else {
            try {
                matchingUser = geofenceRemoteService.getGfUserAdminService().get(userName);
            } catch (NotFoundServiceEx ex) {
                logger.warn("User not found");
                throw new ApplicationException("Login failed");
            }
            //                // grantedAuthorities =
            //                List<GFUser> matchingUsers = geofenceRemoteService.getGfUserAdminService().getFullList(userName, null,
            //                        null);
            //                logger.info(matchingUsers);
            //                logger.info(matchingUsers.size());
            //
            //                if ((matchingUsers == null) || matchingUsers.isEmpty() || (matchingUsers.size() != 1))
            //                {
            //                    logger.error("Error :********** " + "Invalid username specified!");
            //                    throw new ApplicationException("Error :********** " + "Invalid username specified!");
            //                }
            //
            //                logger.info(matchingUsers.get(0).getName());
            //                logger.info(matchingUsers.get(0).getPassword());
            //                logger.info(matchingUsers.get(0).getEnabled());
            //
            //                if (!matchingUsers.get(0).getName().equals(userName) || !matchingUsers.get(0).getEnabled())
            //                {
            //                    logger.error("Error :********** " + "The specified user does not exist!");
            //                    throw new ApplicationException("Error :********** " + "The specified user does not exist!");
            //                }
            //
            //                matchingUser = matchingUsers.get(0);
        }

        token = geofenceRemoteService.getLoginService().login(userName, password, matchingUser.getPassword());
        grantedAuths = geofenceRemoteService.getLoginService().getGrantedAuthorities(token);

    } catch (ClassNotFoundException e) {
        logger.error("Error :********** " + e.getMessage());
        throw new ApplicationException(e);
    } catch (AuthException e) {
        logger.error("Login failed");
        throw new ApplicationException(e.getMessage(), e);
    }

    User user = new User();
    user.setName(userName);
    user.setPassword(password);

    // convert the server-side auths to client-side auths
    List<Authorization> guiAuths = new ArrayList<Authorization>();
    for (Authority auth : grantedAuths.getAuthorities()) {
        guiAuths.add(Authorization.valueOf(auth.name()));
    }
    user.setGrantedAuthorizations(guiAuths);

    if ((grantedAuths != null) && !grantedAuths.getAuthorities().isEmpty()) {
    }

    session.setMaxInactiveInterval(7200);

    session.setAttribute(GeofenceKeySessionValues.USER_LOGGED_TOKEN.getValue(), token);
    /* session.setAttribute(GeofenceKeySessionValues.USER_LOGGED_TOKEN.getValue(),
        grantedAuthorities_NOTUSEDANYMORE.getToken()); */

    return user;
}

From source file:com.bitplan.vzjava.TestVZJPA.java

@Test
public void testDBConfig() throws Exception {
    VZDB vzdb = new VZDB("demo");
    debug = false;/*from w ww. j  av  a2s  .c  om*/
    // set to true if you'd like to see unencrypted passwords in debug mode
    boolean showPasswords = true;
    /*
     * EntityManager em = vzdb.getEntityManager();
     * Map<String, Object> emprops = em.getProperties();
     * if (debug) {
     * for (String key : emprops.keySet()) {
     * String value = (String) emprops.get(key);
     * if (!key.contains("password") || showPasswords)
     * LOGGER.log(Level.INFO, "entity manager property "+key + "=" + value);
     * }
     * }
     */
    DBConfig dbConfig = vzdb.getDbConfig();
    Map<String, String> fields = dbConfig.asMap();
    if (debug) {
        for (String key : fields.keySet()) {
            String value = fields.get(key);
            if (!key.contains("password") || showPasswords)
                LOGGER.log(Level.INFO, "dbConfig " + key + "=" + value);
        }
    }
    dbConfig = new DBConfigImpl();
    dbConfig.setName("xyzNeverUsed4711-z");
    dbConfig.setDriver("invalid Driver");
    try {
        dbConfig.testConnection();
        fail("invalid Driver should throw an exception");
    } catch (ClassNotFoundException cfe) {
        assertEquals("invalid Driver", cfe.getMessage());
    }
}

From source file:com.sun.faces.renderkit.ResponseStateManagerImpl.java

public Object getTreeStructureToRestore(FacesContext context, String treeId) {
    StateManager stateManager = Util.getStateManager(context);

    Object structure = null;//w w w . j  a v a2s  .  c om
    Object state = null;
    ByteArrayInputStream bis = null;
    GZIPInputStream gis = null;
    ObjectInputStream ois = null;
    boolean compress = isCompressStateSet(context);

    Map requestParamMap = context.getExternalContext().getRequestParameterMap();

    String viewString = (String) requestParamMap.get(RIConstants.FACES_VIEW);
    if (viewString == null) {
        return null;
    }
    if (stateManager.isSavingStateInClient(context)) {
        byte[] bytes = Base64.decode(viewString.getBytes());
        try {
            bis = new ByteArrayInputStream(bytes);
            if (isCompressStateSet(context)) {
                if (log.isDebugEnabled()) {
                    log.debug("Deflating state before restoring..");
                }
                gis = new GZIPInputStream(bis);
                ois = new ApplicationObjectInputStream(gis);
            } else {
                ois = new ApplicationObjectInputStream(bis);
            }
            structure = ois.readObject();
            state = ois.readObject();
            Map requestMap = context.getExternalContext().getRequestMap();
            // store the state object temporarily in request scope until it is
            // processed by getComponentStateToRestore which resets it.
            requestMap.put(FACES_VIEW_STATE, state);
            bis.close();
            if (compress) {
                gis.close();
            }
            ois.close();
        } catch (java.io.OptionalDataException ode) {
            log.error(ode.getMessage(), ode);
            throw new FacesException(ode);
        } catch (java.lang.ClassNotFoundException cnfe) {
            log.error(cnfe.getMessage(), cnfe);
            throw new FacesException(cnfe);
        } catch (java.io.IOException iox) {
            log.error(iox.getMessage(), iox);
            throw new FacesException(iox);
        }
    } else {
        structure = viewString;
    }
    return structure;
}

From source file:cn.vlabs.duckling.vwb.service.auth.policy.AuthorizationFileParser.java

private Principal parsePrincipal() throws AuthorizationSyntaxParseException, IOException {
    String principal = ats.nextUsefulToken();
    String className = ats.nextUsefulToken();
    String roleName = ats.nextUsefulToken();
    if (principal == null || !principal.toLowerCase().equals("principal")) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", principal syntax error");
    }/*  w  ww .  j  ava 2s  . co m*/
    if (className == null) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", className is null");
    }
    if (roleName == null) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", roleName is null");
    } else {
        roleName = StringUtils.strip(roleName, "\"");
        roleName = roleName.replace("*", "All");
    }

    try {
        Class<?> clazz = Class.forName(className);
        return ((Principal) clazz.getDeclaredConstructor(String.class).newInstance(roleName));
    } catch (ClassNotFoundException e) {
        throw new AuthorizationSyntaxParseException(
                "Line " + ats.getLineNum() + ", ClassNotFoundException, " + e.getMessage());
    } catch (Exception e) {
        throw new AuthorizationSyntaxParseException(
                "Line " + ats.getLineNum() + ", Exception happens, " + e.getMessage());
    }

}

From source file:com.mapd.bench.Benchmark.java

void doWork(String[] args, int query) {

    //Grab parameters from args
    // parm0 number of iterations per query
    // parm1 file containing sql queries {contains quoted query, expected result count]
    // parm2 optional JDBC Driver class name
    // parm3 optional DB URL
    // parm4 optionsl user
    // parm5 optional passwd
    int iterations = Integer.valueOf(args[0]);
    logger.debug("Iterations per query is " + iterations);

    String queryFile = args[1];/* ww w .j a  v  a 2s .com*/

    //int expectedResults = Integer.valueOf(args[2]);
    driver = (args.length > 2) ? args[2] : JDBC_DRIVER;
    url = (args.length > 3) ? args[3] : DB_URL;
    iUser = (args.length > 4) ? args[4] : USER;
    iPasswd = (args.length > 5) ? args[5] : PASS;

    //register the driver
    try {
        //Register JDBC driver
        Class.forName(driver);
    } catch (ClassNotFoundException ex) {
        logger.error("Could not load class " + driver + " " + ex.getMessage());
        System.exit(1);
    }

    // read from query file and execute queries
    String sCurrentLine;
    List<String> resultArray = new ArrayList();
    BufferedReader br;
    try {
        br = new BufferedReader(new FileReader(queryFile));
        int qCount = 1;

        while ((sCurrentLine = br.readLine()) != null) {

            int expected = 0;
            String sqlQuery = null;
            // find the last comma and then grab the rest as sql
            for (int i = sCurrentLine.length(); i > 0; i--) {
                if (sCurrentLine.charAt(i - 1) == ',') {
                    // found the comma
                    expected = Integer.valueOf(sCurrentLine.substring(i).trim());
                    sqlQuery = sCurrentLine.substring(0, i - 1).trim().substring(1);
                    break;
                }
            }
            // remove final "
            sqlQuery = sqlQuery.substring(0, sqlQuery.length() - 1);

            System.out.println(String.format("Q%02d %s", qCount, sqlQuery));

            resultArray.add(executeQuery(sqlQuery, expected, iterations, qCount));

            qCount++;
        }
    } catch (FileNotFoundException ex) {
        logger.error("Could not find file " + queryFile + " " + ex.getMessage());
        System.exit(2);
    } catch (IOException ex) {
        logger.error("IO Exeception " + ex.getMessage());
        System.exit(3);
    }

    // All done dump out results
    System.out.println(header2);
    for (String s : resultArray) {
        System.out.println(s);
    }

}

From source file:com.workingmouse.webservice.axis.SpringAxisServlet.java

/**
 * Set a custom context class by name. This class must be of type WebApplicationContext,
 * when using the default SpringAxisServlet implementation, the context class
 * must also implement ConfigurableWebApplicationContext.
 *
 * @see #createWebApplicationContext//from   w  w w . j  a  v  a2 s .c  o m
 */
public void setContextClassName(String contextClassName) throws IllegalArgumentException {
    if (contextClassName != null) {
        try {
            ClassLoader loader = Thread.currentThread().getContextClassLoader();
            this.contextClass = Class.forName(contextClassName, true, loader);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }
}

From source file:com.quancheng.saluki.core.config.RpcReferenceConfig.java

private void addMethods(Map<String, String> params) {
    Set<String> retryMethods = getRetryMethods();
    Boolean isNotGeneric = !isGeneric();
    Boolean isNotStub = !isGrpcStub();
    if (isNotGeneric && isNotStub && CollectionUtils.isNotEmpty(retryMethods)) {
        try {//from w ww.  j av  a2s.  c om
            String serviceName = getServiceName();
            Class<?> serviceClzz = ReflectUtils.name2class(serviceName);
            setServiceClass(serviceClzz);
            for (String methodName : retryMethods) {
                Method hasMethod = null;
                for (Method method : serviceClzz.getMethods()) {
                    if (method.getName().equals(methodName)) {
                        hasMethod = method;
                    }
                }
                if (hasMethod == null) {
                    throw new IllegalArgumentException(
                            "The interface " + serviceName + " not found method " + methodName);
                }
            }
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(e.getMessage(), e);
        }
    }
    params.put(Constants.METHODS_KEY, StringUtils.join(retryMethods, ","));
}

From source file:SAMLIssuerImpl.java

/**
 * Creates a new AssertionWrapper.//ww w.  jav  a 2s .c o  m
 *
 * @return a new AssertionWrapper.
 */
public AssertionWrapper newAssertion() throws WSSecurityException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Entering AssertionWrapper.newAssertion() ... creating SAML token");
    }

    if (callbackHandler == null && properties != null) {
        try {
            String samlCallbackClassname = properties.getProperty("org.apache.ws.security.saml.callback");
            Class<? extends CallbackHandler> callbackClass = null;
            try {
                callbackClass = Loader.loadClass(samlCallbackClassname, CallbackHandler.class);
            } catch (ClassNotFoundException ex) {
                throw new WSSecurityException(ex.getMessage(), ex);
            }
            callbackHandler = callbackClass.newInstance();
        } catch (InstantiationException ex) {
            throw new WSSecurityException(ex.getMessage(), ex);
        } catch (IllegalAccessException ex) {
            throw new WSSecurityException(ex.getMessage(), ex);
        }
    }

    // Create a new SAMLParms with all of the information from the properties file.
    SAMLParms samlParms = new SAMLParms();
    samlParms.setIssuer(issuer);
    samlParms.setCallbackHandler(callbackHandler);

    AssertionWrapper sa = new AssertionWrapper(samlParms);
    if (signAssertion) {
        sa.signAssertion(issuerKeyName, issuerKeyPassword, issuerCrypto, sendKeyValue);
    }

    return sa;
}

From source file:se.vgregion.delegation.server.Server.java

public void startServer(ClassPathXmlApplicationContext ctx, String hostname, String port) {

    Server.setEndpoints(new ArrayList<Endpoint>());

    try {//ww w .  j  a  va  2 s . c om
        Class.forName("org.postgresql.Driver");
    } catch (ClassNotFoundException e) {
        LOGGER.error("ClassNotFoundException for: org.postgresql.Driver " + e.getMessage());
    }

    DelegationService delegationService = (DelegationService) ctx.getBean("delegationService");
    propertiesBean = (PropertiesBean) ctx.getBean("propertiesBean");

    // Make CXF use log4j (instead of JDK-logging), currently can't use slf4j.
    //        System.setProperty("org.apache.cxf.Logger", "org.apache.cxf.common.logging.Log4jLogger");

    https = (propertiesBean.getCertPass() != null && !propertiesBean.getCertPass().equals(""));

    String http = "http";

    // Setups SSL and Certificates.
    if (https) {
        try {
            http = "https";
            setupServerEngineFactory(Integer.parseInt(port));
        } catch (IOException e) {
            e.printStackTrace();
        } catch (GeneralSecurityException e) {
            e.printStackTrace();
        }
    }

    String address2 = http + "://" + hostname + ":" + port + "/getactivedelegations";
    String address3 = http + "://" + hostname + ":" + port + "/getdelegation";
    String address4 = http + "://" + hostname + ":" + port + "/getinactivedelegations";
    String address5 = http + "://" + hostname + ":" + port + "/getdelegationsbyunitandrole";
    String address6 = http + "://" + hostname + ":" + port + "/getdelegations";
    String address7 = http + "://" + hostname + ":" + port + "/hasdelegation";
    String address8 = http + "://" + hostname + ":" + port + "/savedelegations";
    String address9 = http + "://" + hostname + ":" + port + "/removedelegation";
    String address10 = http + "://" + hostname + ":" + port + "/finddelegations";
    String address11 = http + "://" + hostname + ":" + port + "/pingforconfiguration";

    LOGGER.info(
            "RIV TA Basic Profile v2.1 - Delegation Service , Apache CXF Producer running on Java version {}",
            System.getProperty("java.version"));
    LOGGER.info("Starting server...");

    startService(new GetActiveDelegationsResponderInterfaceImpl(delegationService), address2);
    startService(new GetDelegationResponderInterfaceImpl(delegationService), address3);
    startService(new GetInactiveDelegationsResponderInterfaceImpl(delegationService), address4);
    startService(new GetDelegationsbyUnitAndRoleResponderInterfaceImpl(delegationService), address5);
    startService(new GetDelegationsResponderInterfaceImpl(delegationService), address6);
    startService(new HasDelegationResponderInterfaceImpl(delegationService), address7);
    startService(new SaveDelegationsResponderInterfaceImpl(delegationService), address8);
    startService(new RemoveDelegationResponderInterfaceImpl(delegationService), address9);
    startService(new FindDelegationsResponderInterfaceImpl(delegationService), address10);
    startService(new PingForConfigurationResponderInterfaceImpl(delegationService), address11);

    LOGGER.info("Server ready!");
}

From source file:architecture.ee.spring.jdbc.support.SqlQueryDaoSupport.java

/**
 * //from w  ww . jav  a 2 s.c o m
 * @param scriptName
 *             ?
 * @param methodName
 *            ?? 
 * @param parameters
 *            ?
 * @return
 */
protected Object execute(String scriptName, String methodName, Object... parameters) {
    if (StringUtils.isEmpty(scriptName))
        throw new NullPointerException(L10NUtils.getMessage("003081"));
    try {
        Class groovyClass = ApplicationHelper.loadClass(scriptName, true, false);
        GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
        if (groovyObject instanceof UnitOfWork && !StringUtils.isEmpty(methodName)) {
            if (groovyObject instanceof UnitOfWorkForSqlQuery) {
                ((UnitOfWorkForSqlQuery) groovyObject).setSqlQuery(getSqlQuery());
            }
            return groovyObject.invokeMethod(methodName, parameters);
        } else if (groovyObject instanceof SqlQueryCallback) {
            return groovyObject.invokeMethod("doInSqlQuery", getSqlQuery());
        }

    } catch (ClassNotFoundException e) {
        throw new IllegalStateException(L10NUtils.format("003082", scriptName));
    } catch (InstantiationException e) {
        throw new IllegalStateException(e.getMessage());
    } catch (IllegalAccessException e) {
        throw new IllegalStateException(e.getMessage());
    }
    return null;
}