congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.apache.shiro.util
Code IndexAdd Tabnine to your IDE (free)

How to use org.apache.shiro.util

Best Java code snippets using org.apache.shiro.util (Showing top 20 results out of 441)

origin: Graylog2/graylog2-server

  public static void requestSessionCreation(boolean createSessionRequest) {
    ThreadContext.put(AUTO_CREATE_SESSION_KEY, createSessionRequest);
  }
}
origin: apache/shiro

/**
 * {@link ThreadContext#remove Remove}s all thread-state that was bound by this instance.  If any previous
 * thread-bound resources existed prior to the {@link #bind bind} call, they are restored back to the
 * {@code ThreadContext} to ensure the thread state is exactly as it was before binding.
 */
public void restore() {
  ThreadContext.remove();
  if (!CollectionUtils.isEmpty(this.originalResources)) {
    ThreadContext.setResources(this.originalResources);
  }
}
origin: apache/shiro

/**
 * Creates an instance using the sources bytes directly - it does not create a copy of the
 * argument's byte array.
 *
 * @param source the source to use to populate the underlying byte array.
 * @since 1.1
 */
public SimpleByteSource(ByteSource source) {
  this.bytes = source.getBytes();
}
origin: apache/shiro

public static void destroy(Object o) {
  if (o instanceof Destroyable) {
    destroy((Destroyable) o);
  } else if (o instanceof Collection) {
    destroy((Collection)o);
  }
}
origin: apache/shiro

public static void init(Object o) throws ShiroException {
  if (o instanceof Initializable) {
    init((Initializable) o);
  }
}
origin: apache/shiro

  /**
   * Completely {@link ThreadContext#remove removes} the {@code ThreadContext} state.  Typically this method should
   * only be called in special cases - it is more 'correct' to {@link #restore restore} a thread to its previous
   * state than to clear it entirely.
   */
  public void clear() {
    ThreadContext.remove();
  }
}
origin: apache/shiro

protected Class lookupHashFormatClass(String name) {
  try {
    return ClassUtils.forName(name);
  } catch (UnknownClassException ignored) {
  }
  return null;
}
origin: apache/shiro

/**
 * Returns a new {@code ByteSource} instance representing the specified character array's bytes.  The byte
 * array is obtained assuming {@code UTF-8} encoding.
 *
 * @param chars the character array to represent as a {@code ByteSource} instance.
 * @return a new {@code ByteSource} instance representing the specified character array's bytes.
 */
public static ByteSource bytes(char[] chars) {
  return new SimpleByteSource(chars);
}
origin: apache/shiro

/**
 * Creates an instance by converting the file to a byte array.
 *
 * @param file the file from which to acquire bytes.
 * @since 1.1
 */
public SimpleByteSource(File file) {
  this.bytes = new BytesHelper().getBytes(file);
}
origin: apache/shiro

/**
 * Assert that the provided object is an instance of the provided class.
 * <pre class="code">Assert.instanceOf(Foo.class, foo);</pre>
 * @param clazz the required class
 * @param obj the object to check
 * @throws IllegalArgumentException if the object is not an instance of clazz
 * @see Class#isInstance
 */
public static void isInstanceOf(Class clazz, Object obj) {
  isInstanceOf(clazz, obj, "");
}
origin: apache/shiro

/**
 * Assert that <code>superType.isAssignableFrom(subType)</code> is <code>true</code>.
 * <pre class="code">Assert.isAssignable(Number.class, myClass);</pre>
 * @param superType the super type to check
 * @param subType the sub type to check
 * @throws IllegalArgumentException if the classes are not assignable
 */
public static void isAssignable(Class superType, Class subType) {
  isAssignable(superType, subType, "");
}
origin: apache/shiro

/**
 * Creates a {@code SoftHashMap} backed by the specified {@code source}, with a default retention
 * size of {@link #DEFAULT_RETENTION_SIZE DEFAULT_RETENTION_SIZE} (100 entries).
 *
 * @param source the backing map to populate this {@code SoftHashMap}
 * @see #SoftHashMap(Map,int)
 */
public SoftHashMap(Map<K, V> source) {
  this(DEFAULT_RETENTION_SIZE);
  putAll(source);
}
origin: apache/shiro

/**
 * Assert that an array has elements; that is, it must not be
 * <code>null</code> and must have at least one element.
 * <pre class="code">Assert.notEmpty(array);</pre>
 * @param array the array to check
 * @throws IllegalArgumentException if the object array is <code>null</code> or has no elements
 */
public static void notEmpty(Object[] array) {
  notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element");
}
origin: apache/shiro

/**
 * Assert that the given String has valid text content; that is, it must not
 * be <code>null</code> and must contain at least one non-whitespace character.
 * <pre class="code">Assert.hasText(name, "'name' must not be empty");</pre>
 * @param text the String to check
 * @see StringUtils#hasText
 */
public static void hasText(String text) {
  hasText(text,
      "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
}
origin: apache/shiro

/**
 * Assert that an array has no null elements.
 * Note: Does not complain if the array is empty!
 * <pre class="code">Assert.noNullElements(array);</pre>
 * @param array the array to check
 * @throws IllegalArgumentException if the object array contains a <code>null</code> element
 */
public static void noNullElements(Object[] array) {
  noNullElements(array, "[Assertion failed] - this array must not contain any null elements");
}
origin: apache/shiro

public static boolean isAvailable(String fullyQualifiedClassName) {
  try {
    forName(fullyQualifiedClassName);
    return true;
  } catch (UnknownClassException e) {
    return false;
  }
}
origin: apache/shiro

/**
 * Returns a new {@code ByteSource} instance representing the specified ByteSource.
 *
 * @param source the ByteSource to represent as a new {@code ByteSource} instance.
 * @return a new {@code ByteSource} instance representing the specified ByteSource.
 */
public static ByteSource bytes(ByteSource source) {
  return new SimpleByteSource(source);
}
origin: apache/shiro

/**
 * Creates an instance by converting the stream to a byte array.
 *
 * @param stream the stream from which to acquire bytes.
 * @since 1.1
 */
public SimpleByteSource(InputStream stream) {
  this.bytes = new BytesHelper().getBytes(stream);
}
origin: apache/shiro

/**
 * Assert that a collection has elements; that is, it must not be
 * <code>null</code> and must have at least one element.
 * <pre class="code">Assert.notEmpty(collection, "Collection must have elements");</pre>
 * @param collection the collection to check
 * @throws IllegalArgumentException if the collection is <code>null</code> or has no elements
 */
public static void notEmpty(Collection collection) {
  notEmpty(collection,
      "[Assertion failed] - this collection must not be empty: it must contain at least 1 element");
}
origin: apache/shiro

/**
 * Assert that a Map has entries; that is, it must not be <code>null</code>
 * and must have at least one entry.
 * <pre class="code">Assert.notEmpty(map);</pre>
 * @param map the map to check
 * @throws IllegalArgumentException if the map is <code>null</code> or has no entries
 */
public static void notEmpty(Map map) {
  notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry");
}
org.apache.shiro.util

Most used classes

  • ByteSource$Util
    Utility class that can construct ByteSource instances. This is slightly nicer than needing to know t
  • ThreadContext
    A ThreadContext provides a means of binding and unbinding objects to the current thread based on key
  • ByteSource
    A ByteSource wraps a byte array and provides additional encoding operations. Most users will find th
  • StringUtils
    Simple utility class for String operations useful across the framework. Some methods in this clas
  • CollectionUtils
    Static helper class for use dealing with Collections.
  • LifecycleUtils,
  • Assert,
  • ClassUtils,
  • ThreadState,
  • Initializable,
  • PermissionUtils,
  • AntPathMatcher,
  • Nameable,
  • PatternMatcher,
  • SimpleByteSource,
  • Destroyable,
  • JdbcUtils,
  • JavaEnvironment,
  • SoftHashMap
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