public EntityManager getEntityManager(IdentityStoreInvocationContext invocationContext) { return ((JpaIdentityStoreSessionImpl) invocationContext.getIdentityStoreSession()).getEntityManager(); }
IdentityStoreInvocationContext resolveInvocationContext(String id, IdentityStoreInvocationContext invocationCtx) { RepositoryIdentityStoreSessionImpl repoSession = (RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession(); IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id); return new SimpleIdentityStoreInvocationContext(targetSession, invocationCtx.getRealmId(), String.valueOf(this.hashCode())); }
protected String getCacheNS(IdentityStoreInvocationContext ctx) { if (cacheScope != null && cacheScope.equals("realm")) { return cacheSupport.getNamespace(attributeStore.getId(), ctx.getRealmId()); } if (cacheScope != null && cacheScope.equals("session")) { return cacheSupport.getNamespace(attributeStore.getId(), ctx.getRealmId(), ctx.getSessionId()); } return cacheSupport.getNamespace(attributeStore.getId()); }
private String getRealmName(IdentityStoreInvocationContext ctx) { if (isRealmAware()) { return ctx.getRealmId(); } else { return DEFAULT_REALM_NAME; } }
public void close() throws IdentityException { sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().close(); }
IdentityStoreInvocationContext resolveInvocationContext(String id, IdentityStoreInvocationContext invocationCtx) { RepositoryIdentityStoreSessionImpl repoSession = (RepositoryIdentityStoreSessionImpl)invocationCtx.getIdentityStoreSession(); IdentityStoreSession targetSession = repoSession.getIdentityStoreSession(id); return new SimpleIdentityStoreInvocationContext(targetSession, invocationCtx.getRealmId(), String.valueOf(this.hashCode())); }
public Transaction getTransaction() { return new SimpleTransactionImpl(sessionContext.resolveStoreInvocationContext().getIdentityStoreSession()); }
public void save() throws IdentityException { sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().save(); }
public void clear() throws IdentityException { sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().clear(); }
public boolean isOpen() { return sessionContext.resolveStoreInvocationContext().getIdentityStoreSession().isOpen(); }
private LdapContext getLDAPContext(IdentityStoreInvocationContext ctx) throws IdentityException { LdapContext ldapContext = null; try { ldapContext = (LdapContext)ctx.getIdentityStoreSession().getSessionContext(); } catch (Exception e) { if (log.isLoggable(Level.FINER)) { log.finer("Failed to obtain LDAP connection!"); } throw new IdentityException("Could not obtain LDAP connection: ", e); } if (ldapContext == null) { if (log.isLoggable(Level.FINER)) { log.finer("Failed to obtain LDAP connection!"); } throw new IdentityException("IllegalState: - Could not obtain LDAP connection"); } return ldapContext; }
protected Session getHibernateSession(IdentityStoreInvocationContext ctx) throws IdentityException { try { HibernateIdentityStoreSessionImpl hbIdentityStoreSession = (HibernateIdentityStoreSessionImpl)ctx.getIdentityStoreSession(); if (lazyStartOfHibernateTransaction) { hbIdentityStoreSession.startHibernateTransactionIfNotStartedYet(); } return ((Session)hbIdentityStoreSession.getSessionContext()); } catch (Exception e) { if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, "Exception occurred: ", e); } throw new IdentityException("Cannot obtain Hibernate Session", e); } }
public Transaction beginTransaction() { Transaction transaction = new SimpleTransactionImpl(sessionContext.resolveStoreInvocationContext().getIdentityStoreSession()); transaction.start(); return transaction; }
private String readPasswordFromPicketLink(User user) throws Exception { PicketLinkIDMOrganizationServiceImpl orgService = (PicketLinkIDMOrganizationServiceImpl) organizationService; if (orgService.getConfiguration().isPasswordAsAttribute()) { return user.getPassword(); } else { IdentitySession identitySession = picketLinkIDMService.getIdentitySession(); IdentityStoreInvocationContext identitySessionContext = ((IdentitySessionImpl) identitySession).getSessionContext() .resolveStoreInvocationContext(); Session session = ((Session) ((RepositoryIdentityStoreSessionImpl) identitySessionContext.getIdentityStoreSession()) .getIdentityStoreSession("HibernateStore").getSessionContext()); HibernateIdentityObjectType hibernateIdentityObjectType = (HibernateIdentityObjectType) session .createCriteria(HibernateIdentityObjectType.class).add(Restrictions.eq("name", "USER")).uniqueResult(); HibernateIdentityObject hibernateUserObject = (HibernateIdentityObject) session .createCriteria(HibernateIdentityObject.class).add(Restrictions.eq("name", user.getUserName())) .add(Restrictions.eq("identityType", hibernateIdentityObjectType)).uniqueResult(); HibernateIdentityObjectCredential hibernateCredential = (HibernateIdentityObjectCredential) session .createCriteria(HibernateIdentityObjectCredential.class).createAlias("type", "t") .add(Restrictions.eq("t.name", PasswordCredential.TYPE.getName())) .add(Restrictions.eq("identityObject", hibernateUserObject)).setCacheable(true).uniqueResult(); if (hibernateCredential != null) { return hibernateCredential.getTextValue(); } else { return ""; } } }
Event<IdentityObjectCreatedEvent> event = ((JpaIdentityStoreSessionImpl) ctx.getIdentityStoreSession()).getIdentityObjectCreatedEvent();