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

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

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

origin: spring-projects/spring-security

  private static <T> T getFieldValue(Object bean, String fieldName) throws IllegalAccessException {
    return (T) FieldUtils.getFieldValue(bean, fieldName);
  }
}
origin: spring-projects/spring-security

private <T> T getFieldValue(Object target, String fieldName) {
  try {
    return (T) FieldUtils.getFieldValue(target, fieldName);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-projects/spring-security

@Test
public void groupQueryIsParsedCorrectly() throws Exception {
  setContext("<jdbc-user-service id='myUserService' "
      + "data-source-ref='dataSource' "
      + "group-authorities-by-username-query='blah blah'/>" + DATA_SOURCE);
  JdbcUserDetailsManager mgr = (JdbcUserDetailsManager) appContext
      .getBean("myUserService");
  assertThat(FieldUtils.getFieldValue(mgr, "groupAuthoritiesByUsernameQuery")).isEqualTo("blah blah");
  assertThat((Boolean) FieldUtils.getFieldValue(mgr, "enableGroups")).isTrue();
}
origin: spring-projects/spring-security

@Test
public void usernameAndAuthorityQueriesAreParsedCorrectly() throws Exception {
  String userQuery = "select username, password, true from users where username = ?";
  String authoritiesQuery = "select username, authority from authorities where username = ? and 1 = 1";
  setContext("<jdbc-user-service id='myUserService' "
      + "data-source-ref='dataSource' " + "users-by-username-query='"
      + userQuery + "' " + "authorities-by-username-query='" + authoritiesQuery
      + "'/>" + DATA_SOURCE);
  JdbcUserDetailsManager mgr = (JdbcUserDetailsManager) appContext
      .getBean("myUserService");
  assertThat(FieldUtils.getFieldValue(mgr, "usersByUsernameQuery")).isEqualTo(userQuery);
  assertThat(FieldUtils.getFieldValue(mgr, "authoritiesByUsernameQuery")).isEqualTo(authoritiesQuery);
  assertThat(mgr.loadUserByUsername("rod") != null).isTrue();
}
origin: spring-projects/spring-security

@Test
public void eventsArePublishedByDefault() throws Exception {
  ConfigurableApplicationContext appContext = this.spring.context(CONTEXT)
    .getContext();
  AuthListener listener = new AuthListener();
  appContext.addApplicationListener(listener);
  ProviderManager pm = (ProviderManager) appContext
      .getBeansOfType(ProviderManager.class).values().toArray()[0];
  Object eventPublisher = FieldUtils.getFieldValue(pm, "eventPublisher");
  assertThat(eventPublisher).isNotNull();
  assertThat(eventPublisher instanceof DefaultAuthenticationEventPublisher).isTrue();
  pm.authenticate(new UsernamePasswordAuthenticationToken("bob", "bobspassword"));
  assertThat(listener.events).hasSize(1);
}
origin: spring-projects/spring-security

@SuppressWarnings("unchecked")
@Test
public void expressionVoterAndAfterInvocationProviderUseSameExpressionHandlerInstance()
    throws Exception {
  setContext("<global-method-security pre-post-annotations='enabled'/>"
      + AUTH_PROVIDER_XML);
  AffirmativeBased adm = (AffirmativeBased) appContext
      .getBeansOfType(AffirmativeBased.class).values().toArray()[0];
  List voters = (List) FieldUtils.getFieldValue(adm, "decisionVoters");
  PreInvocationAuthorizationAdviceVoter mev = (PreInvocationAuthorizationAdviceVoter) voters
      .get(0);
  MethodSecurityMetadataSourceAdvisor msi = (MethodSecurityMetadataSourceAdvisor) appContext
      .getBeansOfType(MethodSecurityMetadataSourceAdvisor.class).values()
      .toArray()[0];
  AfterInvocationProviderManager pm = (AfterInvocationProviderManager) ((MethodSecurityInterceptor) msi
      .getAdvice()).getAfterInvocationManager();
  PostInvocationAdviceProvider aip = (PostInvocationAdviceProvider) pm
      .getProviders().get(0);
  assertThat(FieldUtils.getFieldValue(mev, "preAdvice.expressionHandler")).isSameAs(FieldUtils
      .getFieldValue(aip, "postAdvice.expressionHandler"));
}
origin: spring-projects/spring-security

  @Test
  public void gettingAndSettingProtectedFieldIsSuccessful() throws Exception {
    new FieldUtils();

    Object tc = new TestClass();

    assertThat(FieldUtils.getProtectedFieldValue("protectedField", tc)).isEqualTo("x");
    assertThat(FieldUtils.getFieldValue(tc, "nested.protectedField")).isEqualTo("z");
    FieldUtils.setProtectedFieldValue("protectedField", tc, "y");
    assertThat(FieldUtils.getProtectedFieldValue("protectedField", tc)).isEqualTo("y");

    try {
      FieldUtils.getProtectedFieldValue("nonExistentField", tc);
    }
    catch (IllegalStateException expected) {
    }
  }
}
origin: spring-projects/spring-security

assertThat(aclFromCache).isEqualTo(acl);
assertThat(FieldUtils.getFieldValue(aclFromCache.getParentAcl(),
    "aclAuthorizationStrategy")).isNotNull();
assertThat(FieldUtils.getFieldValue(aclFromCache.getParentAcl(),
    "permissionGrantingStrategy")).isNotNull();
assertThat(myCache.getFromCache(identity)).isEqualTo(acl);
assertThat(FieldUtils.getFieldValue(aclFromCache, "aclAuthorizationStrategy")).isNotNull();
AclImpl parentAclFromCache = (AclImpl) myCache.getFromCache(Long.valueOf(2));
assertThat(parentAclFromCache).isEqualTo(parentAcl);
assertThat(FieldUtils.getFieldValue(parentAclFromCache,
    "aclAuthorizationStrategy")).isNotNull();
assertThat(myCache.getFromCache(identityParent)).isEqualTo(parentAcl);
origin: spring-projects/spring-security

@Test
public void runAsManagerIsSetCorrectly() throws Exception {
  StaticApplicationContext parent = new StaticApplicationContext();
  MutablePropertyValues props = new MutablePropertyValues();
  props.addPropertyValue("key", "blah");
  parent.registerSingleton("runAsMgr", RunAsManagerImpl.class, props);
  parent.refresh();
  setContext("<global-method-security run-as-manager-ref='runAsMgr'/>"
      + AUTH_PROVIDER_XML, parent);
  RunAsManagerImpl ram = (RunAsManagerImpl) appContext.getBean("runAsMgr");
  MethodSecurityMetadataSourceAdvisor msi = (MethodSecurityMetadataSourceAdvisor) appContext
      .getBeansOfType(MethodSecurityMetadataSourceAdvisor.class).values()
      .toArray()[0];
  assertThat(ram).isSameAs(FieldUtils.getFieldValue(msi.getAdvice(), "runAsManager"));
}
org.springframework.security.utilFieldUtilsgetFieldValue

Javadoc

Returns the value of a (nested) field on a bean. Intended for testing.

Popular methods of FieldUtils

  • getProtectedFieldValue
  • getField
    Attempts to locate the specified field on the class.
  • setProtectedFieldValue
  • <init>

Popular in Java

  • Reactive rest calls using spring rest template
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSystemService (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • CodeWhisperer alternatives
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