InfoCenter Home > 5.2.2.2.6: The getUserSecurityName and getGroupSecurityName methodsThe getUserSecurityName and getGroupSecurityName methods allow the retrieval of the name of a user or group from a unique identifier. WebSphere Application Server expects the methods to throw the EntryNotFoundException exception if the unique identifier does not exist in the registry and to throw the CustomRegistryException exception for any other conditions. Figure 11 shows the implementation of the getUserSecurityName method for the example registry. The method iterates through the user-information file and attempts to locate an entry with the specified UID. If the UID is located, the corresponding name field is extracted and returned. If the UID is not found, the EntryNotFoundException exception is thrown. The getGroupSecurityName method does the same work on the group-information file. public String getUserSecurityName(String uniqueId) throws CustomRegistryException, EntryNotFoundException { String s, usrSecName = null; BufferedReader in = null; try { in = fileOpen(USERFILENAME); while ((s=in.readLine())!=null) { if (!s.startsWith("#")) { int index = s.indexOf(":"); int index1 = s.indexOf(":", index+1); int index2 = s.indexOf(":", index1+1); if ((s.substring(index1+1,index2)).equals(uniqueId)) { usrSecName = s.substring(0,index); break; } } } } catch (Exception ex) { throw new CustomRegistryException(ex.getMessage()); } finally { fileClose(in); } if (usrSecName == null) { EntryNotFoundException ex = new EntryNotFoundException(uniqueId); } return usrSecName; } public String getGroupSecurityName(String uniqueId) throws CustomRegistryException, EntryNotFoundException { String s, grpSecName = null; BufferedReader in = null; try { in = fileOpen(GROUPFILENAME); ... } catch (Exception ex) { ... } finally { ... } if (grpSecName == null) { ... } return grpSecName; } |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|