Tabnine Logo
FieldUtils.getField
Code IndexAdd Tabnine to your IDE (free)

How to use
getField
method
in
org.springframework.security.util.FieldUtils

Best Java code snippets using org.springframework.security.util.FieldUtils.getField (Showing top 18 results out of 315)

origin: spring-projects/spring-security

public static Object getProtectedFieldValue(String protectedField, Object object) {
  Field field = FieldUtils.getField(object.getClass(), protectedField);
  try {
    field.setAccessible(true);
    return field.get(object);
  }
  catch (Exception ex) {
    ReflectionUtils.handleReflectionException(ex);
    return null; // unreachable - previous line throws exception
  }
}
origin: spring-projects/spring-security

  public static void setProtectedFieldValue(String protectedField, Object object,
      Object newValue) {
    Field field = FieldUtils.getField(object.getClass(), protectedField);

    try {
      field.setAccessible(true);
      field.set(object, newValue);
    }
    catch (Exception ex) {
      ReflectionUtils.handleReflectionException(ex);
    }
  }
}
origin: org.springframework.security/spring-security-core

public static Object getProtectedFieldValue(String protectedField, Object object) {
  Field field = FieldUtils.getField(object.getClass(), protectedField);
  try {
    field.setAccessible(true);
    return field.get(object);
  }
  catch (Exception ex) {
    ReflectionUtils.handleReflectionException(ex);
    return null; // unreachable - previous line throws exception
  }
}
origin: org.springframework.security/spring-security-core

  public static void setProtectedFieldValue(String protectedField, Object object,
      Object newValue) {
    Field field = FieldUtils.getField(object.getClass(), protectedField);

    try {
      field.setAccessible(true);
      field.set(object, newValue);
    }
    catch (Exception ex) {
      ReflectionUtils.handleReflectionException(ex);
    }
  }
}
origin: spring-projects/spring-security

/**
 * Returns the value of a (nested) field on a bean. Intended for testing.
 * @param bean the object
 * @param fieldName the field name, with "." separating nested properties
 * @return the value of the nested field
 */
public static Object getFieldValue(Object bean, String fieldName)
    throws IllegalAccessException {
  Assert.notNull(bean, "Bean cannot be null");
  Assert.hasText(fieldName, "Field name required");
  String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
  Class<?> componentClass = bean.getClass();
  Object value = bean;
  for (String nestedField : nestedFields) {
    Field field = getField(componentClass, nestedField);
    field.setAccessible(true);
    value = field.get(value);
    if (value != null) {
      componentClass = value.getClass();
    }
  }
  return value;
}
origin: spring-projects/spring-security

/**
 * Attempts to locate the specified field on the class.
 *
 * @param clazz the class definition containing the field
 * @param fieldName the name of the field to locate
 *
 * @return the Field (never null)
 *
 * @throws IllegalStateException if field could not be found
 */
public static Field getField(Class<?> clazz, String fieldName)
    throws IllegalStateException {
  Assert.notNull(clazz, "Class required");
  Assert.hasText(fieldName, "Field name required");
  try {
    return clazz.getDeclaredField(fieldName);
  }
  catch (NoSuchFieldException nsf) {
    // Try superclass
    if (clazz.getSuperclass() != null) {
      return getField(clazz.getSuperclass(), fieldName);
    }
    throw new IllegalStateException("Could not locate field '" + fieldName
        + "' on class " + clazz);
  }
}
origin: org.springframework.security/spring-security-core

/**
 * Returns the value of a (nested) field on a bean. Intended for testing.
 * @param bean the object
 * @param fieldName the field name, with "." separating nested properties
 * @return the value of the nested field
 */
public static Object getFieldValue(Object bean, String fieldName)
    throws IllegalAccessException {
  Assert.notNull(bean, "Bean cannot be null");
  Assert.hasText(fieldName, "Field name required");
  String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
  Class<?> componentClass = bean.getClass();
  Object value = bean;
  for (String nestedField : nestedFields) {
    Field field = getField(componentClass, nestedField);
    field.setAccessible(true);
    value = field.get(value);
    if (value != null) {
      componentClass = value.getClass();
    }
  }
  return value;
}
origin: org.springframework.security/spring-security-core

/**
 * Attempts to locate the specified field on the class.
 *
 * @param clazz the class definition containing the field
 * @param fieldName the name of the field to locate
 *
 * @return the Field (never null)
 *
 * @throws IllegalStateException if field could not be found
 */
public static Field getField(Class<?> clazz, String fieldName)
    throws IllegalStateException {
  Assert.notNull(clazz, "Class required");
  Assert.hasText(fieldName, "Field name required");
  try {
    return clazz.getDeclaredField(fieldName);
  }
  catch (NoSuchFieldException nsf) {
    // Try superclass
    if (clazz.getSuperclass() != null) {
      return getField(clazz.getSuperclass(), fieldName);
    }
    throw new IllegalStateException("Could not locate field '" + fieldName
        + "' on class " + clazz);
  }
}
origin: spring-projects/spring-security

@SuppressWarnings("unchecked")
public MutableAcl updateAcl(MutableAcl acl) throws NotFoundException {
  List<AccessControlEntry> oldAces = acl.getEntries();
  Field acesField = FieldUtils.getField(AclImpl.class, "aces");
  acesField.setAccessible(true);
  List newAces;
  try {
    newAces = (List) acesField.get(acl);
    newAces.clear();
    for (int i = 0; i < oldAces.size(); i++) {
      AccessControlEntry ac = oldAces.get(i);
      // Just give an ID to all this acl's aces, rest of the fields are just
      // copied
      newAces.add(new AccessControlEntryImpl((i + 1), ac.getAcl(), ac
          .getSid(), ac.getPermission(), ac.isGranting(),
          ((AuditableAccessControlEntry) ac).isAuditSuccess(),
          ((AuditableAccessControlEntry) ac).isAuditFailure()));
    }
  }
  catch (IllegalAccessException e) {
    e.printStackTrace();
  }
  return acl;
}
origin: apache/servicemix-bundles

public static Object getProtectedFieldValue(String protectedField, Object object) {
  Field field = FieldUtils.getField(object.getClass(), protectedField);
  try {
    field.setAccessible(true);
    return field.get(object);
  }
  catch (Exception ex) {
    ReflectionUtils.handleReflectionException(ex);
    return null; // unreachable - previous line throws exception
  }
}
origin: apache/servicemix-bundles

  public static void setProtectedFieldValue(String protectedField, Object object,
      Object newValue) {
    Field field = FieldUtils.getField(object.getClass(), protectedField);

    try {
      field.setAccessible(true);
      field.set(object, newValue);
    }
    catch (Exception ex) {
      ReflectionUtils.handleReflectionException(ex);
    }
  }
}
origin: org.springframework.security/org.springframework.security.core

public static Object getProtectedFieldValue(String protectedField, Object object) {
  Field field = FieldUtils.getField(object.getClass(), protectedField);
  try {
    field.setAccessible(true);
    return field.get(object);
  } catch (Exception ex) {
    ReflectionUtils.handleReflectionException(ex);
    return null; // unreachable - previous line throws exception
  }
}
origin: org.springframework.security/org.springframework.security.core

  public static void setProtectedFieldValue(String protectedField, Object object, Object newValue) {
    Field field = FieldUtils.getField(object.getClass(), protectedField);

    try {
      field.setAccessible(true);
      field.set(object, newValue);
    } catch (Exception ex) {
      ReflectionUtils.handleReflectionException(ex);
    }
  }
}
origin: org.springframework.security/org.springframework.security.core

/**
 * Returns the value of a (nested) field on a bean. Intended for testing.
 * @param bean the object
 * @param fieldName the field name, with "." separating nested properties
 * @return the value of the nested field
 */
public static Object getFieldValue(Object bean, String fieldName) throws IllegalAccessException {
  Assert.notNull(bean, "Bean cannot be null");
  Assert.hasText(fieldName, "Field name required");
  String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
  Class<?> componentClass = bean.getClass();
  Object value = bean;
  for (String nestedField : nestedFields) {
    Field field = getField(componentClass, nestedField);
    field.setAccessible(true);
    value = field.get(value);
    if (value != null) {
      componentClass = value.getClass();
    }
  }
  return value;
}
origin: org.springframework.security/org.springframework.security.core

/**
 * Attempts to locate the specified field on the class.
 *
 * @param clazz the class definition containing the field
 * @param fieldName the name of the field to locate
 *
 * @return the Field (never null)
 *
 * @throws IllegalStateException if field could not be found
 */
public static Field getField(Class<?> clazz, String fieldName) throws IllegalStateException {
  Assert.notNull(clazz, "Class required");
  Assert.hasText(fieldName, "Field name required");
  try {
    return clazz.getDeclaredField(fieldName);
  } catch (NoSuchFieldException nsf) {
    // Try superclass
    if (clazz.getSuperclass() != null) {
      return getField(clazz.getSuperclass(), fieldName);
    }
    throw new IllegalStateException("Could not locate field '" + fieldName + "' on class " + clazz);
  }
}
origin: apache/servicemix-bundles

/**
 * Returns the value of a (nested) field on a bean. Intended for testing.
 * @param bean the object
 * @param fieldName the field name, with "." separating nested properties
 * @return the value of the nested field
 */
public static Object getFieldValue(Object bean, String fieldName)
    throws IllegalAccessException {
  Assert.notNull(bean, "Bean cannot be null");
  Assert.hasText(fieldName, "Field name required");
  String[] nestedFields = StringUtils.tokenizeToStringArray(fieldName, ".");
  Class<?> componentClass = bean.getClass();
  Object value = bean;
  for (String nestedField : nestedFields) {
    Field field = getField(componentClass, nestedField);
    field.setAccessible(true);
    value = field.get(value);
    if (value != null) {
      componentClass = value.getClass();
    }
  }
  return value;
}
origin: apache/servicemix-bundles

/**
 * Attempts to locate the specified field on the class.
 *
 * @param clazz the class definition containing the field
 * @param fieldName the name of the field to locate
 *
 * @return the Field (never null)
 *
 * @throws IllegalStateException if field could not be found
 */
public static Field getField(Class<?> clazz, String fieldName)
    throws IllegalStateException {
  Assert.notNull(clazz, "Class required");
  Assert.hasText(fieldName, "Field name required");
  try {
    return clazz.getDeclaredField(fieldName);
  }
  catch (NoSuchFieldException nsf) {
    // Try superclass
    if (clazz.getSuperclass() != null) {
      return getField(clazz.getSuperclass(), fieldName);
    }
    throw new IllegalStateException("Could not locate field '" + fieldName
        + "' on class " + clazz);
  }
}
origin: sk.seges.acris/acris-security-spring

Field acesField = FieldUtils.getField(AclImpl.class, "aces");
List<AccessControlEntry> aces;
org.springframework.security.utilFieldUtilsgetField

Javadoc

Attempts to locate the specified field on the class.

Popular methods of FieldUtils

  • getProtectedFieldValue
  • getFieldValue
    Returns the value of a (nested) field on a bean. Intended for testing.
  • setProtectedFieldValue
  • <init>

Popular in Java

  • Creating JSON documents from java classes using gson
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • setRequestProperty (URLConnection)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • LinkedHashMap (java.util)
    LinkedHashMap is an implementation of Map that guarantees iteration order. All optional operations a
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JCheckBox (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now