public <T> Constructor<T> getNoArgConstructor(Class<T> clazz) { return webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructor(clazz); }
/** * TODO: only migrated this over from a static method to SecurityService. * TODO: we should finally get rid of this property! * @Deprecated */ private boolean isInTest() { if (pluginInTest == null) { pluginInTest = Boolean.valueOf(WebBeansContext.currentInstance().getSecurityService().doPrivilegedGetSystemProperty("EjbPlugin.test", "false")); } return pluginInTest.booleanValue(); }
private void checkQualifierConditions(Annotation ann) { if (ann == DefaultLiteral.INSTANCE || ann == AnyLiteral.INSTANCE || ann.annotationType().equals(Default.class) || ann.annotationType().equals(Any.class) || ann.annotationType().equals(Named.class)) { // special performance boost for some known Qualifiers return; } Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(ann.annotationType()); for (Method method : methods) { Class<?> clazz = method.getReturnType(); if (clazz.isArray() || clazz.isAnnotation()) { if (!AnnotationUtil.hasAnnotation(method.getDeclaredAnnotations(), Nonbinding.class)) { throw new WebBeansConfigurationException("@Qualifier : " + ann.annotationType().getName() + " must have @NonBinding valued members for its array-valued and annotation valued members"); } } } if (!isQualifierAnnotation(ann.annotationType())) { throw new IllegalArgumentException("Qualifier annotations must be annotated with @Qualifier"); } }
private void close() { try { if(this.jmsObject != null) { Method method = this.jmsObject.getClass().getMethod("close"); if(!method.isAccessible()) { jmsComponent.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(method, true); } method.invoke(this.jmsObject); } } catch (Exception e) { throw new WebBeansException("Unable to close JMS resources"); } }
Constructor<?> c = webBeansContext.getSecurityService().doPrivilegedGetConstructor(clazz, WebBeansContext.class); if (c == null) return webBeansContext.getSecurityService().doPrivilegedObjectCreate(clazz);
Method overloadedMethod = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod( creatorMethod.getDeclaringClass().getSuperclass(), creatorMethod.getName(),
public void injectJavaEEResources(Object managedBeanInstance) Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(managedBeanInstance.getClass()); for(Field field : fields) webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
@Override public void injectJavaEEResources(Object managedBeanInstance) { Class<?> currentClass = managedBeanInstance.getClass(); SecurityService securityService = webBeansContext.getSecurityService(); while (currentClass != null && Object.class != currentClass) { Field[] fields = securityService.doPrivilegedGetDeclaredFields(currentClass); for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; Annotation ann = AnnotationUtil.hasOwbInjectableResource(field.getDeclaredAnnotations()); if (ann == null) continue; @SuppressWarnings("unchecked") ResourceReference<Object, ?> resourceRef = new ResourceReference(field.getDeclaringClass(), field.getName(), field.getType(), ann); boolean acess = field.isAccessible(); try { securityService.doPrivilegedSetAccessible(field, true); field.set(managedBeanInstance, getResourceReference(resourceRef)); } catch (Exception e) { throw new WebBeansException("Unable to inject field" + field, e); } finally { securityService.doPrivilegedSetAccessible(field, acess); } } currentClass = currentClass.getSuperclass(); } }
@Override protected AnnotatedConstructor<T> createConstructor() { // create proxy subclass Class<T> classToProxy = annotatedType.getJavaClass(); ClassLoader classLoader = webBeansContext.getApplicationBoundaryService().getBoundaryClassLoader(classToProxy); if (classLoader == null) { classLoader = Thread.currentThread().getContextClassLoader(); } proxySubClass = webBeansContext.getSubclassProxyFactory().createImplementedSubclass(classLoader, annotatedType); Constructor<T> ct = (Constructor<T>) webBeansContext.getSecurityService().doPrivilegedGetDeclaredConstructors(proxySubClass)[0]; Constructor<T> parentCtor; try { parentCtor = classToProxy.getConstructor(ct.getParameterTypes()); } catch (NoSuchMethodException e) { throw new IllegalStateException(e); } return new SubClassAnnotatedConstructorImpl<T>(webBeansContext, parentCtor, ct, annotatedType); }
Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(currentClass); webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(type);
/** * JavaEE components can not inject {@link javax.enterprise.inject.spi.InjectionPoint}. * @param clazz javaee component class info * @throws WebBeansConfigurationException exception if condition is not applied */ public void checkInjectionPointForInjectInjectionPoint(Class<?> clazz) { Asserts.nullCheckForClass(clazz); Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(clazz); for(Field field : fields) { if(field.getAnnotation(Inject.class) != null) { if(field.getType() == InjectionPoint.class) { Annotation[] anns = getQualifierAnnotations(field.getDeclaredAnnotations()); if (AnnotationUtil.hasAnnotation(anns, Default.class)) { throw new WebBeansConfigurationException("Java EE Component class : " + clazz + " can not inject InjectionPoint"); } } } } }
Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
/** * Creates the instance from the constructor. Each constructor parameter * instance is resolved using the resolution algorithm. */ public T doInjection() { try { if(!con.isAccessible()) { getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(con, true); } instance = con.newInstance(createParameters()); transientCreationalContext.release(); return instance; } catch (Exception e) { throw new WebBeansException(e); } }
if (!field.isAccessible()) webBeansContext.getSecurityService().doPrivilegedSetAccessible(field, true);
getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(field, true);
Field field = webBeansContext.getSecurityService().doPrivilegedGetDeclaredField(ownerBeanClass, fieldName); Class<?>[] parameters = (Class<?>[])in.readObject(); Method method = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethod(ownerBeanClass, methodName, parameters); injectionMember = method;
Method classMethod = bean.getWebBeansContext().getSecurityService(). doPrivilegedGetDeclaredMethod(clazz, method.getJavaMember().getName(), method.getJavaMember().getParameterTypes()); if(classMethod == null)
getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(method, true);
ownerBean.getWebBeansContext().getSecurityService().doPrivilegedSetAccessible(view, true);