List of usage examples for java.lang SecurityException getMessage
public String getMessage()
From source file:org.apache.directory.fortress.core.GroupMgrConsole.java
void readGroup() { try {//from w ww. j av a 2 s.c o m ReaderUtil.clearScreen(); System.out.println("Enter group name:"); Group inGroup = new Group(ReaderUtil.readLn()); Group outGroup = groupMgr.read(inGroup); System.out.println("GROUP"); System.out.println(" name [" + outGroup.getName() + "]"); System.out.println(" desc [" + outGroup.getDescription() + "]"); System.out.println(" protocol [" + outGroup.getProtocol() + "]"); if (CollectionUtils.isNotEmpty(outGroup.getMembers())) { int ctr = 0; for (String member : outGroup.getMembers()) { System.out.println(" member[" + ctr++ + "]=" + member); } } if (PropUtil.isNotEmpty(outGroup.getProperties())) { int ctr = 0; for (Enumeration e = outGroup.getProperties().propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String val = outGroup.getProperty(key); System.out.println(" prop key[" + ctr + "]=" + key); System.out.println(" prop val[" + ctr++ + "]=" + val); } } System.out.println("Group node successfully read"); System.out.println("ENTER to continue"); } catch (SecurityException e) { LOG.error("readGroup caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e); } ReaderUtil.readChar(); }
From source file:org.apache.directory.fortress.core.GroupMgrConsole.java
void findGroups() { try {//from www .ja v a 2 s. c om ReaderUtil.clearScreen(); System.out.println("Enter group search name:"); Group inGroup = new Group(ReaderUtil.readLn()); List<Group> outGroups = groupMgr.find(inGroup); if (CollectionUtils.isNotEmpty(outGroups)) { int grpctr = 0; for (Group outGroup : outGroups) { System.out.println("GROUP[" + grpctr++ + "]"); System.out.println(" name [" + outGroup.getName() + "]"); System.out.println(" desc [" + outGroup.getDescription() + "]"); System.out.println(" protocol [" + outGroup.getProtocol() + "]"); if (CollectionUtils.isNotEmpty(outGroup.getMembers())) { int memberctr = 0; for (String member : outGroup.getMembers()) { System.out.println(" member[" + memberctr++ + "]=" + member); } } if (PropUtil.isNotEmpty(outGroup.getProperties())) { int propctr = 0; for (Enumeration e = outGroup.getProperties().propertyNames(); e.hasMoreElements();) { String key = (String) e.nextElement(); String val = outGroup.getProperty(key); System.out.println(" prop key[" + propctr + "]=" + key); System.out.println(" prop val[" + propctr++ + "]=" + val); } } } System.out.println("Group nodes successfully searched"); } else { System.out.println("No Group nodes found"); } System.out.println("ENTER to continue"); } catch (SecurityException e) { LOG.error("readGroup caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e); } ReaderUtil.readChar(); }
From source file:org.xchain.namespaces.hibernate.test.TestHqlEntityPermission.java
@Test public void testIdParameter() throws Exception { HibernateLifecycle.getCurrentSession().beginTransaction(); final String hql = String.format("select count(id) from %s where id = :id group by id", UserNote.class.getName()); Permission p = new HqlEntityPermission(EntityOperation.ALL, UserNote.class, hql); UserNote instance = (UserNote) userList.get(0).getUserNoteSet().toArray()[0]; IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername())); Permission entityPermission = new EntityPermission<UserNote>(EntityOperation.LOAD, instance.getId(), instance);//from w w w. j a va 2 s. c om try { SecurityManager.instance().checkPermission(entityPermission); fail(); } catch (SecurityException e) { } try { IdentityManager.instance().getIdentity().getPermissions().add(p); SecurityManager.instance().checkPermission(entityPermission); } catch (Exception e) { fail(e.getMessage()); } HibernateLifecycle.getCurrentSession().getTransaction().rollback(); }
From source file:org.xchain.namespaces.hibernate.test.TestHqlEntityPermission.java
@Test public void testPrincipalParameter() throws Exception { HibernateLifecycle.getCurrentSession().beginTransaction(); final String hql = String.format( "select count(user.username) from %s entity join entity.user user where user.username = :principal group by user.username", UserNote.class.getName()); Permission p = new HqlEntityPermission(EntityOperation.ALL, UserNote.class, hql); UserNote instance = (UserNote) userList.get(0).getUserNoteSet().toArray()[0]; IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername())); Permission entityPermission = new EntityPermission<UserNote>(EntityOperation.LOAD, instance.getId(), instance);//w w w. j a v a 2 s . com try { SecurityManager.instance().checkPermission(entityPermission); fail(); } catch (SecurityException e) { } try { IdentityManager.instance().getIdentity().getPermissions().add(p); SecurityManager.instance().checkPermission(entityPermission); } catch (Exception e) { fail(e.getMessage()); } HibernateLifecycle.getCurrentSession().getTransaction().rollback(); }
From source file:org.apache.directory.fortress.core.GroupMgrConsole.java
/** * put your documentation comment here/*from ww w. ja v a2s. c o m*/ */ public GroupMgrConsole() { try { groupMgr = GroupMgrFactory.createInstance(); } catch (org.apache.directory.fortress.core.SecurityException e) { LOG.error(" constructor caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e); } }
From source file:org.sakaiproject.qna.logic.impl.OptionsLogicImpl.java
/** * @see OptionsLogic#getNotificationSet(String) *//*from w ww . java 2 s . co m*/ public Set<String> getNotificationSet(String locationId) { QnaOptions options = getOptionsForLocation(locationId); Set<String> notificationSet = new HashSet<String>(); try { if (options.getEmailNotification()) { if (options.getEmailNotificationType().equals(QnaConstants.SITE_CONTACT)) { notificationSet.add(externalLogic.getSiteContactEmail(locationId)); } else if (options.getEmailNotificationType().equals(QnaConstants.UPDATE_RIGHTS)) { Set<String> users = externalLogic.getSiteUsersWithPermission(locationId, ExternalLogic.QNA_UPDATE); for (String userId : users) { notificationSet.add(externalLogic.getUserEmail(userId)); } } else if (options.getEmailNotificationType().equals(QnaConstants.CUSTOM_LIST)) { Set<QnaCustomEmail> customMails = options.getCustomEmails(); for (QnaCustomEmail qnaCustomEmail : customMails) { notificationSet.add(qnaCustomEmail.getEmail()); } } } } catch (SecurityException se) { // This might happen if anon does not have access to site or site isn't public, log it for now log.error(se.getMessage(), se); } return notificationSet; }
From source file:com.altoukhov.svsync.fileviews.LocalFileSpace.java
@Override protected Snapshot scan(List<Pattern> filters) { try {// w w w.ja v a 2 s . c o m Map<String, FileSnapshot> files = new LinkedHashMap<>(); Set<String> dirs = new HashSet<>(); File root = new File(rootPath); if (root.exists()) { Stack<File> stack = new Stack<>(); stack.push(root); dirs.add(""); while (!stack.isEmpty()) { File currentFolder = stack.pop(); for (final File file : currentFolder.listFiles(filter)) { if (file.isFile() && !isExcluded(trimFilePath(file.getAbsolutePath())) && !isFiltered(toRelativePath(file.getAbsolutePath()), filters)) { FileSnapshot fileSnapshot = new FileSnapshot(file.getName(), file.length(), new DateTime(new Date(file.lastModified())), toRelativePath(file.getAbsolutePath())); files.put(fileSnapshot.getRelativePath(), fileSnapshot); } else if (file.isDirectory() && !isExcluded(trimFilePath(file.getAbsolutePath())) && !isFiltered(toRelativePath(file.getAbsolutePath(), true), filters)) { stack.push(file); dirs.add(toRelativePath(file.getAbsolutePath())); System.out.println("Scanning " + file.getAbsolutePath()); } } } } Snapshot snapshot = new Snapshot(files, dirs); return snapshot; } catch (SecurityException ex) { System.out.println("Failed to scan file space"); System.out.println(ex.getMessage()); } return null; }
From source file:org.cloudifysource.shell.validators.LusConnectionValidator.java
void validateConnection(final String hostAddress, final int port) throws CLIValidationException { try {// w ww. j a va 2 s .c o m IPUtils.validateConnection(hostAddress, port); return; } catch (UnknownHostException uhe) { // thrown if the IP address of the host could not be determined. throw new CLIValidationException(uhe, 127, CloudifyErrorMessages.LUS_CONNECTION_VALIDATION_ABORTED_UNKNOWN_HOST.getName(), hostAddress); } catch (IOException ioe) { // thrown if an I/O error occurs when creating the socket or connecting. throw new CLIValidationException(ioe, 128, CloudifyErrorMessages.LUS_CONNECTION_VALIDATION_ABORTED_IO_ERROR.getName(), hostAddress, port, ioe.getMessage()); } catch (SecurityException se) { // thrown if a security manager exists and permission to resolve the host name is denied. throw new CLIValidationException(se, 129, CloudifyErrorMessages.LUS_CONNECTION_VALIDATION_ABORTED_NO_PERMISSION.getName(), hostAddress, port, se.getMessage()); } }
From source file:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java
private void unregisterTracingReceiver() { try {/* w w w . ja va 2 s . c om*/ getTracingController().unregisterReceiver(this); } catch (SecurityException e) { Log.w(TAG, "failed to unregister tracing receiver: " + e.getMessage()); } catch (IllegalArgumentException e) { Log.w(TAG, "failed to unregister tracing receiver: " + e.getMessage()); } }
From source file:org.xchain.namespaces.hibernate.test.TestQualifiedEntityPermission.java
@Test public void testProcessResult() throws Exception { HibernateLifecycle.getCurrentSession().beginTransaction(); final String noResultHql = String.format( "select count(entity) from %s entity where entity.id = :id and 0=1", UserNote.class.getName()); final String arrayResultHql = String.format( "select entity.id, entity.text from %s entity where entity.id = :id", UserNote.class.getName()); final String booleanResultHql = String.format( "select new java.lang.Boolean('false') from %s entity where entity.id = :id", UserNote.class.getName()); final String booleanResultHql2 = String.format( "select new java.lang.Boolean('true') from %s entity where entity.id = :id", UserNote.class.getName()); final String integerResultHql = String.format("select count(entity) from %s entity where entity.id = :id", UserNote.class.getName()); final String longResultHql = String.format("select entity.id from %s entity where entity.id = :id", UserNote.class.getName()); final String objectResultHql = String.format("select entity from %s entity where entity.id = :id", UserNote.class.getName()); final String[] hqlArray = new String[] { noResultHql, arrayResultHql, booleanResultHql, booleanResultHql2, integerResultHql, longResultHql, objectResultHql }; IdentityManager.instance().loggedIn(new UsernamePrincipal(userList.get(0).getUsername())); UserNote instance = (UserNote) userList.get(0).getUserNoteSet().toArray()[0]; Permission entityPermission = new EntityPermission<UserNote>(EntityOperation.LOAD, instance.getId(), instance);/*from ww w. j a v a 2 s . c o m*/ for (String hql : hqlArray) { try { Set<Permission> permissions = IdentityManager.instance().getIdentity().getPermissions(); permissions.clear(); Permission p = new HqlEntityPermission(EntityOperation.ALL, UserNote.class, hql); permissions.add(p); SecurityManager.instance().checkPermission(entityPermission); } catch (SecurityException e) { } catch (IllegalArgumentException e) { } catch (Exception e) { fail(e.getMessage()); } } HibernateLifecycle.getCurrentSession().getTransaction().rollback(); }