📄 rainterfacebean.java
字号:
public boolean userExist(String username) throws Exception{ return adminsession.existsUser(administrator, username); } /* Method to retrieve a user from the database without inserting it into users data, used by 'viewuser.jsp' and page*/ public UserView findUser(String username) throws Exception{ log.debug(">findUser(" + username + ")"); UserDataVO user = adminsession.findUser(administrator, username); UserView userview = null; if (user != null) { userview = new UserView(user, informationmemory.getCAIdToNameMap()); } log.debug("<findUser(" + username + "): " + userview); return userview; } /* Method to retrieve a user from the database without inserting it into users data, used by 'edituser.jsp' and page*/ public UserView findUserForEdit(String username) throws Exception{ UserView userview = null; UserDataVO user = adminsession.findUser(administrator, username); if(this.informationmemory.getGlobalConfiguration().getEnableEndEntityProfileLimitations()) if(!endEntityAuthorization(administrator, user.getEndEntityProfileId(),AvailableAccessRules.EDIT_RIGHTS, false)) throw new AuthorizationDeniedException("Not authorized to edit user."); if(user != null) userview = new UserView(user, informationmemory.getCAIdToNameMap()); return userview; } /* Method to find all users in database */ public UserView[] findAllUsers(int index,int size) throws Exception{ users.setUsers(adminsession.findAllUsersWithLimit(administrator), informationmemory.getCAIdToNameMap()); return users.getUsers(index,size); } /* Method to find all users in database */ public UserView[] filterByTokenSN(String tokensn, int index,int size) throws Exception{ UserView[] returnval = null; UserDataVO user = null; ArrayList userlist = new ArrayList(); Collection usernames = hardtokensession.findHardTokenByTokenSerialNumber(administrator, tokensn); Iterator iter = usernames.iterator(); while(iter.hasNext()){ try{ user = adminsession.findUser(administrator, (String) iter.next()); }catch(AuthorizationDeniedException e){} if(user!=null) userlist.add(user); } users.setUsers(userlist, informationmemory.getCAIdToNameMap()); returnval= users.getUsers(index,size); return returnval; } /* Method that checks if a certificate serialnumber is revoked and returns the user(s), else a null value. */ public UserView[] filterByCertificateSerialNumber(String serialnumber, int index, int size) throws RemoteException, FinderException, NamingException, NumberFormatException, CreateException{ serialnumber = StringTools.stripWhitespace(serialnumber); Collection certs =certificatesession.findCertificatesBySerno(administrator, new BigInteger(serialnumber,16)); ArrayList userlist = new ArrayList(); UserView[] returnval = null; if(certs != null){ Iterator iter = certs.iterator(); while(iter.hasNext()){ UserDataVO user = null; try{ X509Certificate next = (X509Certificate) iter.next(); user = adminsession.findUserBySubjectDN(administrator, CertTools.getSubjectDN(next), next.getIssuerDN().toString()); userlist.add(user); }catch(AuthorizationDeniedException e){} } users.setUsers(userlist, informationmemory.getCAIdToNameMap()); returnval= users.getUsers(index,size); } return returnval; } /* Method that lists all users with certificate's that expires within given days. */ public UserView[] filterByExpiringCertificates(String days, int index, int size) throws RemoteException, FinderException, NumberFormatException, NamingException, CreateException{ ArrayList userlist = new ArrayList(); UserView[] returnval = null; long d = Long.parseLong(days); Date finddate = new Date(); long millis = (d * 86400000); // One day in milliseconds. finddate.setTime(finddate.getTime() + millis); Collection usernames =certificatesession.findCertificatesByExpireTimeWithLimit(administrator, finddate); if(!usernames.isEmpty()){ Iterator i = usernames.iterator(); while(i.hasNext() && userlist.size() <= MAXIMUM_QUERY_ROWCOUNT +1 ){ UserDataVO user = null; try{ user = adminsession.findUser(administrator, (String) i.next()); if(user != null) userlist.add(user); }catch(AuthorizationDeniedException e){} } users.setUsers(userlist, informationmemory.getCAIdToNameMap()); returnval= users.getUsers(index,size); } return returnval; } public UserView[] filterByQuery(Query query, int index, int size) throws Exception { Collection userlist = adminsession.query(administrator, query, informationmemory.getUserDataQueryCAAuthoorizationString(), informationmemory.getUserDataQueryEndEntityProfileAuthorizationString()); users.setUsers(userlist, informationmemory.getCAIdToNameMap()); return users.getUsers(index,size); } public int getResultSize(){ return users.size(); } public boolean isAuthorizedToViewUserHistory(String username) throws Exception { UserDataVO user = adminsession.findUser(administrator, username); return endEntityAuthorization(administrator, user.getEndEntityProfileId(),AvailableAccessRules.HISTORY_RIGHTS, false); } public boolean isAuthorizedToEditUser(String username) throws Exception { UserDataVO user = adminsession.findUser(administrator, username); return endEntityAuthorization(administrator, user.getEndEntityProfileId(),AvailableAccessRules.EDIT_RIGHTS, false); } /* Method to resort filtered user data. */ public void sortUserData(int sortby, int sortorder){ users.sortBy(sortby,sortorder); } /* Method to return the users between index and size, if userdata is smaller than size, a smaller array is returned. */ public UserView[] getUsers(int index, int size){ return users.getUsers(index, size); } /* Method that clears the userview memory. */ public void clearUsers(){ users.clear(); } public boolean nextButton(int index, int size){ return index + size < users.size(); } public boolean previousButton(int index){ return index > 0 ; } // Method dealing with added user memory. /** A method to get the last added users in adduser.jsp. * * @see se.anatom.ejbca.webdist.rainterface.AddedUserMemory */ public UserView[] getAddedUsers(int size){ return addedusermemory.getUsers(size); } // Methods dealing with profiles. public TreeMap getAuthorizedEndEntityProfileNames() { return informationmemory.getAuthorizedEndEntityProfileNames(); } /** Returns the profile name from id proxied */ public String getEndEntityProfileName(int profileid) throws RemoteException{ return this.informationmemory.getEndEntityProfileNameProxy().getEndEntityProfileName(profileid); } public int getEndEntityProfileId(String profilename){ return profiles.getEndEntityProfileId(profilename); } public EndEntityProfile getEndEntityProfile(String name) throws Exception{ return profiles.getEndEntityProfile(name); } public EndEntityProfile getEndEntityProfile(int id) throws Exception{ return profiles.getEndEntityProfile(id); } public void addEndEntityProfile(String name) throws Exception{ EndEntityProfile profile = new EndEntityProfile(); Iterator iter = this.informationmemory.getAuthorizedCAIds().iterator(); String availablecas = ""; if(iter.hasNext()) availablecas = ((Integer) iter.next()).toString(); while(iter.hasNext()){ availablecas = availablecas + EndEntityProfile.SPLITCHAR + ((Integer) iter.next()).toString(); } profile.setValue(EndEntityProfile.AVAILCAS, 0,availablecas); profile.setRequired(EndEntityProfile.AVAILCAS, 0,true); profiles.addEndEntityProfile(name, profile); } public void changeEndEntityProfile(String name, EndEntityProfile profile) throws Exception { profiles.changeEndEntityProfile(name, profile); } /* Returns false if profile is used by any user or in authorization rules. */ public boolean removeEndEntityProfile(String name)throws Exception{ boolean profileused = false; int profileid = raadminsession.getEndEntityProfileId(administrator, name); // Check if any users or authorization rule use the profile. profileused = adminsession.checkForEndEntityProfileId(administrator, profileid) || authorizationsession.existsEndEntityProfileInRules(administrator, profileid); if(!profileused){ profiles.removeEndEntityProfile(name); } return !profileused; } public void renameEndEntityProfile(String oldname, String newname) throws Exception{ profiles.renameEndEntityProfile(oldname, newname); } public void cloneEndEntityProfile(String originalname, String newname) throws Exception{ profiles.cloneEndEntityProfile(originalname, newname); } public void loadCertificates(String username) throws Exception{ Collection certs = certificatesession.findCertificatesByUsername(administrator, username); loadCertificateView(certs, username); } public void loadTokenCertificates(String tokensn, String username) throws RemoteException, NamingException, CreateException, AuthorizationDeniedException, FinderException{ Collection certs = hardtokensession.findCertificatesInHardToken(administrator, tokensn); loadCertificateView(certs, username); } /** Helper method loading CertificateView and RevokedInfoView arrays given a collection of certificates. * * @param certs certificates to process
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -