Example usage for org.apache.shiro.session.mgt SessionContext getHost

List of usage examples for org.apache.shiro.session.mgt SessionContext getHost

Introduction

In this page you can find the example usage for org.apache.shiro.session.mgt SessionContext getHost.

Prototype

String getHost();

Source Link

Document

Returns the originating host name or IP address (as a String) from where the Subject is initiating the Session .

Usage

From source file:com.caricah.iotracah.bootstrap.security.IOTSessionFactory.java

License:Apache License

/**
 * Creates a new {@link IOTClient} instance retaining the context's
 * {@link SessionContext#getHost() host} if one can be found.
 *
 * @param initData the initialization data to be used during {@link Session} creation.
 * @return a new {@link IOTClient} instance
 *//*from   w w w . ja va  2  s.  c o m*/
public Session createSession(SessionContext initData) {
    if (initData != null) {
        IOTClient iotClient = new IOTClient(initData.getHost());
        iotClient.setPartitionId((String) initData.get(IOTClient.CONTEXT_PARTITION_KEY));
        iotClient.setUsername((String) initData.get(IOTClient.CONTEXT_USERNAME_KEY));
        iotClient.setClientIdentification((String) initData.get(IOTClient.CONTEXT_CLIENT_ID_KEY));

        String sessionId = IOTClient
                .keyFromStrings(iotClient.getPartitionId(), iotClient.getClientIdentification()).getSessionId();
        iotClient.setSessionId(sessionId);
        iotClient.setIsActive(true);
        iotClient.setIsExpired(false);

        return iotClient;
    }
    return null;
}

From source file:com.sonicle.webtop.core.app.shiro.WTContainerSessionManager.java

License:Open Source License

private String getHost(SessionContext context) {
    String host = context.getHost();
    if (host == null) {
        ServletRequest request = WebUtils.getRequest(context);
        if (request != null) {
            host = request.getRemoteHost();
        }//w w  w  .j av  a2 s.com
    }
    return host;
}

From source file:org.usergrid.rest.security.shiro.session.HttpRequestSessionManager.java

License:Apache License

private String getHost(SessionContext context) {
    String host = context.getHost();
    if (host == null) {
        ServletRequest request = WebUtils.getRequest(context);
        if (request != null) {
            host = request.getRemoteHost();
        }//from  w w  w  .j  a va2  s.  c om
    }
    return host;

}