public ims.admin.vo.SecurityTokenVoCollection listSecTokens(ims.framework.utils.Date forDate) { DomainFactory factory = getDomainFactory(); String hql; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); if (forDate == null) hql = " from SecurityToken secToken order by expirationTimeStamp"; else { hql = " from SecurityToken secToken where expirationTimeStamp = :forDate"; markers.add("forDate"); values.add(forDate); } return SecurityTokenVoAssembler.createSecurityTokenVoCollectionFromSecurityToken(factory.find(hql, markers, values)); }
public String getParameters(String uuid) { DomainFactory factory = getDomainFactory(); IMSCriteria criteria = new IMSCriteria(ims.core.admin.domain.objects.SecurityToken.class,factory); criteria.equal("this.tokenID", uuid); List list=criteria.find(); if (list.size()==0) return null; SecurityToken domObj=(SecurityToken)list.get(0); SecurityTokenVo vo = SecurityTokenVoAssembler.create(domObj); SecurityParamVoCollection coll = vo.getParams(); for (SecurityParamVo vo2 : coll) { if("parameters".equals(vo2.getName())) { return vo2.getItem(); } } return ""; }
public String getSecurityToken(String username, String password) throws DomainInterfaceException, StaleObjectException, UniqueKeyViolationException { if(username == null || username.length() == 0) throw new DomainInterfaceException("Can not generate security token for empty username."); if(password == null || password.length() == 0) throw new DomainInterfaceException("Can not generate security token for empty password."); DomainFactory factory = getDomainFactory(); SecurityTokenVo st= new SecurityTokenVo(); SecurityParamVoCollection params = new SecurityParamVoCollection(); SecurityParamVo sp1 = new SecurityParamVo(); sp1.setItem("username"); sp1.setValue(username); params.add(sp1); SecurityParamVo sp2 = new SecurityParamVo(); sp2.setItem("password"); sp2.setValue(password); params.add(sp2); st.setParams(params); String securityToken = UUID.randomUUID().toString(); st.setTokenID(securityToken); st.setExpirationTimeStamp(new DateTime().addMinutes(10)); SecurityToken stDom = SecurityTokenVoAssembler.extractSecurityToken(factory, st); factory.save(stDom); return securityToken; }
private String getSecurityToken(java.util.HashMap<String, String> parameters) throws StaleObjectException { SecurityTokenVo securityTokenVo = new SecurityTokenVo(); SecurityParamVoCollection params = new SecurityParamVoCollection(); String securityToken = UUID.randomUUID().toString(); securityTokenVo.setTokenID(securityToken); securityTokenVo.setExpirationTimeStamp(new DateTime().addMinutes(10)); List<Object> listParams = new ArrayList<Object>(parameters.entrySet()); Iterator<Object> iter = listParams.iterator(); while(iter.hasNext()) { Map.Entry<?, ?> entry = (Map.Entry<?, ?>) iter.next(); SecurityParamVo securityTokenParamVo = new SecurityParamVo(); securityTokenParamVo.setItem((String) entry.getKey()); securityTokenParamVo.setValue((String) entry.getValue()); params.add(securityTokenParamVo); } securityTokenVo.setParams(params); DomainFactory factory = getDomainFactory(); SecurityToken securityTokenDom = SecurityTokenVoAssembler.extractSecurityToken(factory, securityTokenVo); factory.save(securityTokenDom); return securityToken; }
public ISecurityToken getToken(String tokenId) { String hql; ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); hql = " from SecurityToken secToken where tokenID = :tokenId"; markers.add("tokenId"); values.add(tokenId); DomainFactory factory = getDomainFactory(); ims.admin.vo.SecurityTokenVoCollection voColl = SecurityTokenVoAssembler.createSecurityTokenVoCollectionFromSecurityToken(factory.find(hql, markers, values)); //delete from db if (voColl.size() > 0) { SecurityToken st = SecurityTokenVoAssembler.extractSecurityToken(factory,voColl.get(0)); try { factory.delete(st); } catch (ForeignKeyViolationException e) { //can't really do anything here. } return voColl.get(0); } return null; }
public String getStartupToken(String serviceName, String parameters) { DomainFactory factory = getDomainFactory(); SecurityTokenVo st= new SecurityTokenVo(); String sessionId = UUID.randomUUID().toString(); st.setTokenID(sessionId); st.setExpirationTimeStamp(new DateTime().addMinutes(10)); SecurityParamVoCollection params = new SecurityParamVoCollection(); SecurityParamVo sp1 = new SecurityParamVo(); sp1.setItem("username"); // sp1.setValue("emisuser"); sp1.setValue(factory.getDomainSession().getUser().getUsername()); params.add(sp1); SecurityParamVo sp2 = new SecurityParamVo(); sp2.setItem("password"); // sp2.setValue("emisuser"); sp2.setValue(factory.getDomainSession().getUser().getClearPassword()); params.add(sp2); SecurityParamVo sp3 = new SecurityParamVo(); sp3.setItem("parameters"); sp3.setValue(parameters); params.add(sp3); SecurityParamVo sp4 = new SecurityParamVo(); sp4.setItem("sourceSystem"); sp4.setValue(serviceName); params.add(sp4); st.setParams(params); SecurityToken stDom = SecurityTokenVoAssembler.extractSecurityToken(factory, st); try{ factory.save(stDom); } catch (StaleObjectException soe) { soe.printStackTrace(); } return sessionId; }