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 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; }