/** * Generic helper: Use JBoss SecurityActions to load a class, then create a new instance. * * @param <T> generic return type * @param name FQCN of the class to instantiate. * @param clazz Expected type, used for PicketBox logging. * @return Insance. On error/exception, this method registers the * exception via {{@link #setValidateError(Throwable)} and returns * <code>null</code>. */ @SuppressWarnings("unchecked") protected <T> T newInstance(final String name, final Class<T> clazz) { T r = null; try { Class<?> loadedClass = getClass().getClassLoader().loadClass(name); r = (T) loadedClass.newInstance(); } catch(Exception e) { LoginException le = new LoginException(PicketBoxMessages.MESSAGES.failedToInstantiateClassMessage(clazz)); le.initCause(e); setValidateError(le); } return r; } }
/** * Generic helper: Use JBoss SecurityActions to load a class, then create a new instance. * * @param <T> generic return type * @param name FQCN of the class to instantiate. * @param clazz Expected type, used for PicketBox logging. * @return Insance. On error/exception, this method registers the * exception via {{@link #setValidateError(Throwable)} and returns * <code>null</code>. */ @SuppressWarnings("unchecked") protected <T> T newInstance(final String name, final Class<T> clazz) { T r = null; try { Class<?> loadedClass = getClass().getClassLoader().loadClass(name); r = (T) loadedClass.newInstance(); } catch(Exception e) { LoginException le = new LoginException(PicketBoxMessages.MESSAGES.failedToInstantiateClassMessage(clazz)); le.initCause(e); setValidateError(le); } return r; } }
throw new IllegalStateException(PicketBoxMessages.MESSAGES.failedToInstantiateClassMessage(AuthorizationModule.class)); am.initialize(this.authenticatedSubject, this.callbackHandler, this.sharedState, map, subjectRoles); return am;
@SuppressWarnings({"unchecked", "rawtypes"}) private IdentityTrustModule instantiateModule(ClassLoader cl, String name, Map map) throws Exception { IdentityTrustModule im = null; try { Class clazz = SecurityActions.loadClass(cl, name); im = (IdentityTrustModule)clazz.newInstance(); } catch ( Exception e) { PicketBoxLogger.LOGGER.debugIgnoredException(e); } if(im == null) throw new LoginException(PicketBoxMessages.MESSAGES.failedToInstantiateClassMessage(IdentityTrustModule.class)); im.initialize(this.securityContext, this.callbackHandler, this.sharedState,map); return im; }
LoginException le = new LoginException(PicketBoxMessages.MESSAGES.failedToInstantiateClassMessage(Callback.class)); le.initCause(e); throw le;