congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Session.getAttribute
Code IndexAdd Tabnine to your IDE (free)

How to use
getAttribute
method
in
org.apache.shiro.session.Session

Best Java code snippets using org.apache.shiro.session.Session.getAttribute (Showing top 20 results out of 657)

origin: apache/shiro

/**
 * Immediately delegates to the underlying proxied session.
 */
public Object getAttribute(Object key) throws InvalidSessionException {
  return delegate.getAttribute(key);
}
origin: killbill/killbill

  private byte[] serializeSessionData(final Session session) throws IOException {
    final Map<Object, Object> sessionAttributes = new HashMap<Object, Object>();
    for (final Object key : session.getAttributeKeys()) {
      sessionAttributes.put(key, session.getAttribute(key));
    }

    return serializer.serialize(sessionAttributes);
  }
}
origin: apache/shiro

@SuppressWarnings({"unchecked"})
private T castSessionAttribute(Session session) {
  return (T) session.getAttribute(key);
}
origin: Graylog2/graylog2-server

@Override
protected Serializable doCreate(Session session) {
  final Serializable id = generateSessionId(session);
  assignSessionId(session, id);
  Map<String, Object> fields = Maps.newHashMap();
  fields.put("session_id", id);
  fields.put("host", session.getHost());
  fields.put("start_timestamp", session.getStartTimestamp());
  fields.put("last_access_time", session.getLastAccessTime());
  fields.put("timeout", session.getTimeout());
  Map<String, Object> attributes = Maps.newHashMap();
  for (Object key : session.getAttributeKeys()) {
    attributes.put(key.toString(), session.getAttribute(key));
  }
  fields.put("attributes", attributes);
  final MongoDbSession dbSession = new MongoDbSession(fields);
  final String objectId = mongoDBSessionService.saveWithoutValidation(dbSession);
  LOG.debug("Created session {}", objectId);
  return id;
}
origin: apache/shiro

  public void onStop(Session session) {
    stopped[0] = true;
    value[0] = (String)session.getAttribute("foo");
  }
};
origin: apache/shiro

public Object getAttribute(String s) {
  try {
    return getSession().getAttribute(s);
  } catch (InvalidSessionException e) {
    throw new IllegalStateException(e);
  }
}
origin: apache/shiro

public static SavedRequest getSavedRequest(ServletRequest request) {
  SavedRequest savedRequest = null;
  Subject subject = SecurityUtils.getSubject();
  Session session = subject.getSession(false);
  if (session != null) {
    savedRequest = (SavedRequest) session.getAttribute(SAVED_REQUEST_KEY);
  }
  return savedRequest;
}
origin: apache/shiro

@SuppressWarnings("unchecked")
private List<PrincipalCollection> getRunAsPrincipalsStack() {
  Session session = getSession(false);
  if (session != null) {
    return (List<PrincipalCollection>) session.getAttribute(RUN_AS_PRINCIPALS_SESSION_KEY);
  }
  return null;
}
origin: stylefeng/Guns

/**
 * 获取shiro指定的sessionKey
 */
@SuppressWarnings("unchecked")
public static <T> T getSessionAttr(String key) {
  Session session = getSession();
  return session != null ? (T) session.getAttribute(key) : null;
}
origin: shuzheng/zheng

@Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) throws Exception {
  Session session = getSubject(request, response).getSession(false);
  if(session == null) {
    return true;
  }
  boolean forceout = session.getAttribute("FORCE_LOGOUT") == null;
  return  forceout;
}
origin: apache/shiro

public Object getAttribute(SessionKey sessionKey, Object attributeKey) throws InvalidSessionException {
  return lookupRequiredSession(sessionKey).getAttribute(attributeKey);
}
origin: apache/usergrid

public static BiMap<UUID, String> getOrganizations() {
  Subject currentUser = getSubject();
  if ( !isOrganizationAdmin() ) {
    return null;
  }
  Session session = currentUser.getSession();
  BiMap<UUID, String> organizations = HashBiMap.create();
  Map map = (Map)session.getAttribute( "organizations" );
  organizations.putAll(map);
  return organizations;
}
origin: apache/usergrid

public static OrganizationInfo getOrganization() {
  Subject currentUser = getSubject();
  if ( currentUser == null ) {
    return null;
  }
  if ( !currentUser.hasRole( ROLE_ORGANIZATION_ADMIN ) ) {
    return null;
  }
  Session session = currentUser.getSession();
  OrganizationInfo organization = ( OrganizationInfo ) session.getAttribute( "organization" );
  return organization;
}
origin: apache/shiro

public boolean resolveAuthenticated() {
  Boolean authc = getTypedValue(AUTHENTICATED, Boolean.class);
  if (authc == null) {
    //see if there is an AuthenticationInfo object.  If so, the very presence of one indicates a successful
    //authentication attempt:
    AuthenticationInfo info = getAuthenticationInfo();
    authc = info != null;
  }
  if (!authc) {
    //fall back to a session check:
    Session session = resolveSession();
    if (session != null) {
      Boolean sessionAuthc = (Boolean) session.getAttribute(AUTHENTICATED_SESSION_KEY);
      authc = sessionAuthc != null && sessionAuthc;
    }
  }
  return authc;
}
origin: apache/usergrid

@SuppressWarnings( "unchecked" )
public static BiMap<UUID, String> getApplications() {
  Subject currentUser = getSubject();
  if ( currentUser == null ) {
    return null;
  }
  if ( !currentUser.hasRole( ROLE_APPLICATION_ADMIN ) && !currentUser.hasRole( ROLE_APPLICATION_USER ) ) {
    return null;
  }
  Session session = currentUser.getSession();
  BiMap<UUID, String> applications = HashBiMap.create();
  Map map = (Map)session.getAttribute( "applications" );
  applications.putAll(map);
  return applications;
}
origin: shuzheng/zheng

@Override
protected void doDelete(Session session) {
  String sessionId = session.getId().toString();
  String upmsType = ObjectUtils.toString(session.getAttribute(UpmsConstant.UPMS_TYPE));
  if ("client".equals(upmsType)) {
origin: apache/usergrid

public static String getOrganizationName() {
  Subject currentUser = getSubject();
  if ( currentUser == null ) {
    return null;
  }
  if ( !currentUser.hasRole( ROLE_ORGANIZATION_ADMIN ) ) {
    return null;
  }
  Session session = currentUser.getSession();
  OrganizationInfo organization = ( OrganizationInfo ) session.getAttribute( "organization" );
  if ( organization == null ) {
    return null;
  }
  return organization.getName();
}
origin: apache/usergrid

public static UUID getOrganizationId() {
  Subject currentUser = getSubject();
  if ( currentUser == null ) {
    return null;
  }
  if ( !currentUser.hasRole( ROLE_ORGANIZATION_ADMIN ) ) {
    return null;
  }
  Session session = currentUser.getSession();
  OrganizationInfo organization = ( OrganizationInfo ) session.getAttribute( "organization" );
  if ( organization == null ) {
    return null;
  }
  return organization.getUuid();
}
origin: apache/shiro

@Test
public void testSessionStopThenStart() {
  String key = "testKey";
  String value = "testValue";
  DefaultSecurityManager sm = new DefaultSecurityManager();
  DelegatingSubject subject = new DelegatingSubject(sm);
  Session session = subject.getSession();
  session.setAttribute(key, value);
  assertTrue(session.getAttribute(key).equals(value));
  Serializable firstSessionId = session.getId();
  assertNotNull(firstSessionId);
  session.stop();
  session = subject.getSession();
  assertNotNull(session);
  assertNull(session.getAttribute(key));
  Serializable secondSessionId = session.getId();
  assertNotNull(secondSessionId);
  assertFalse(firstSessionId.equals(secondSessionId));
  subject.logout();
  sm.destroy();
}
origin: apache/shiro

@Test
public void testDefaultConfig() {
  Subject subject = SecurityUtils.getSubject();
  AuthenticationToken token = new UsernamePasswordToken("guest", "guest");
  subject.login(token);
  assertTrue(subject.isAuthenticated());
  assertTrue("guest".equals(subject.getPrincipal()));
  assertTrue(subject.hasRole("guest"));
  Session session = subject.getSession();
  session.setAttribute("key", "value");
  assertEquals(session.getAttribute("key"), "value");
  subject.logout();
  assertNull(subject.getSession(false));
  assertNull(subject.getPrincipal());
  assertNull(subject.getPrincipals());
}
org.apache.shiro.sessionSessiongetAttribute

Javadoc

Returns the object bound to this session identified by the specified key. If there is no object bound under the key, null is returned.

Popular methods of Session

  • setAttribute
    Binds the specified value to this session, uniquely identified by the specifed key name. If there is
  • getId
    Returns the unique identifier assigned by the system upon session creation. All return values from t
  • removeAttribute
    Removes (unbinds) the object bound to this session under the specified key name.
  • getHost
    Returns the host name or IP string of the host that originated this session, or nullif the host is u
  • getTimeout
    Returns the time in milliseconds that the session session may remain idle before expiring. * A negat
  • getLastAccessTime
    Returns the last time the application received a request or method invocation from the user associat
  • getStartTimestamp
    Returns the time the session was started; that is, the time the system created the instance.
  • setTimeout
    Sets the time in milliseconds that the session may remain idle before expiring. * A negative val
  • getAttributeKeys
    Returns the keys of all the attributes stored under this session. If there are no attributes, this r
  • stop
    Explicitly stops (invalidates) this session and releases all associated resources. If this session h
  • touch
    Explicitly updates the #getLastAccessTime() of this session to the current time when this method is
  • touch

Popular in Java

  • Running tasks concurrently on multiple threads
  • getResourceAsStream (ClassLoader)
  • compareTo (BigDecimal)
  • onCreateOptionsMenu (Activity)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Locale (java.util)
    Locale represents a language/country/variant combination. Locales are used to alter the presentatio
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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