List of usage examples for org.apache.shiro.session.mgt SimpleSession SimpleSession
public SimpleSession(String host)
From source file:ddf.security.service.impl.SecurityManagerImpl.java
License:Open Source License
public Subject getSubject(Object token) throws SecurityServiceException { AuthenticationToken authenticationToken = null; if (token instanceof SessionToken) { return new SubjectImpl(((PrincipalCollection) ((SessionToken) token).getCredentials()), true, new SimpleSession(UUID.randomUUID().toString()), internalManager); } else if (token instanceof AuthenticationToken) { authenticationToken = (AuthenticationToken) token; }/*from w w w . j a v a2 s . co m*/ if (authenticationToken != null) { return getSubject(authenticationToken); } else { throw new SecurityServiceException( "Incoming token object NOT supported by security manager implementation. Currently supported types are AuthenticationToken and SecurityToken"); } }
From source file:ddf.security.service.impl.SecurityManagerImpl.java
License:Open Source License
/** * Creates a new subject based on an incoming AuthenticationToken * * @param token AuthenticationToken that should be used to authenticate the user and use as the * basis for the new subject./* ww w.j a va 2 s .c o m*/ * @return new subject * @throws SecurityServiceException */ private Subject getSubject(AuthenticationToken token) throws SecurityServiceException { if (token.getCredentials() == null) { throw new SecurityServiceException( "CANNOT AUTHENTICATE USER: Authentication token did not contain any credentials. " + "This is generally due to an error on the authentication server."); } AuthenticationInfo info = internalManager.authenticate(token); Collection<SecurityAssertion> securityAssertions = info.getPrincipals().byType(SecurityAssertion.class); Iterator<SecurityAssertion> iterator = securityAssertions.iterator(); boolean userAuth = false; while (iterator.hasNext()) { SecurityAssertion assertion = iterator.next(); if (SecurityAssertion.IDP_AUTH_WEIGHT == assertion.getWeight() || SecurityAssertion.LOCAL_AUTH_WEIGHT == assertion.getWeight()) { userAuth = true; } } try { return new SubjectImpl(info.getPrincipals(), userAuth, new SimpleSession(UUID.randomUUID().toString()), internalManager); } catch (Exception e) { throw new SecurityServiceException("Could not create a new subject", e); } }
From source file:org.maodian.flyingcat.im.entity.Session.java
License:Apache License
public static org.apache.shiro.session.Session to(Session session) { SimpleSession ss = new SimpleSession(session.getHost()); ss.setId(session.getId());/*w w w.j a va2 s .c o m*/ ss.setLastAccessTime(session.getLastAccessTime()); ss.setStartTimestamp(session.getStartTimestamp()); return ss; }