List of usage examples for java.lang SecurityException getCause
public synchronized Throwable getCause()
From source file:com.crazy.pss.common.utils.Reflections.java
public static boolean hasAttribute(final String attrName, final Class clazz) { Field f = null;//from w w w.j a v a 2 s .com try { f = clazz.getField(attrName); } catch (SecurityException e) { if (logger.isErrorEnabled()) { logger.error("?Class=" + clazz + "" + attrName + "", e.getCause()); } return false; } catch (NoSuchFieldException e) { if (logger.isErrorEnabled()) { logger.error("?Class=" + clazz + "" + attrName + "", e.getCause()); } return false; } return f == null ? false : true; }
From source file:com.baidu.terminator.manager.service.LinkControlServiceImpl.java
private <T> T getPluginInstance(Link link, Class<T> clazz) { try {//from w w w .ja v a2 s. c o m Constructor<T> constructor = clazz.getConstructor(Link.class); T plugin = constructor.newInstance(link); return plugin; } catch (SecurityException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } catch (IllegalArgumentException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } catch (NoSuchMethodException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } catch (InstantiationException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } catch (IllegalAccessException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } catch (InvocationTargetException e) { throw new SignerInitializationException("InitializationFail", e.getCause()); } }
From source file:com.amazonaws.metrics.internal.cloudwatch.provider.transform.DynamoDBRequestMetricTransformer.java
@Override public List<MetricDatum> toMetricData(MetricType metricType, Request<?> request, Response<?> response) { try {/* w w w. j a v a 2 s. c o m*/ return toMetricData0(metricType, request, response); } catch (SecurityException e) { } catch (NoSuchMethodException e) { } catch (IllegalAccessException e) { } catch (InvocationTargetException e) { LogFactory.getLog(getClass()).debug("", e.getCause()); } catch (Exception e) { LogFactory.getLog(getClass()).debug("", e); } return null; }
From source file:it.greenvulcano.gvesb.iam.service.internal.GVUsersManager.java
@Override public void revokeRole(String username, String role) throws UserNotFoundException { try {/*from w ww. ja va2s.c om*/ User user = userRepository.get(username) .orElseThrow(() -> new SecurityException(new UserNotFoundException(username))); user.removeRole(role); userRepository.add(user); } catch (SecurityException e) { if (e.getCause() instanceof UserNotFoundException) { throw (UserNotFoundException) e.getCause(); } else { throw e; } } }
From source file:org.siyapath.gossip.GossipImpl.java
/** * Initiates gossiping of member set. Select a random member form the known member * list and gossip current member list by calling memberDiscovery service & * update the current list with the response *//*from w w w .j av a2s . c om*/ public void memberGossiper() { NodeInfo randomMember = nodeContext.getRandomMember(); log.info("Getting a random member to gossip:" + randomMember); if (randomMember != null) { TTransport transport = new TSocket(randomMember.getIp(), randomMember.getPort()); //TTransport transport = new TFramedTransport(new TSocket("localhost", randomMember.getPort())); try { transport.open(); TProtocol protocol = new TBinaryProtocol(transport); Siyapath.Client client = new Siyapath.Client(protocol); Set<NodeInfo> nodesToGossip = getDiff(randomMember); Set<NodeInfo> discoveredNodes = CommonUtils.deSerialize(client.memberDiscovery( CommonUtils.serialize(nodeContext.getNodeInfo()), CommonUtils.serialize(nodesToGossip))); Set<NodeInfo> newSet = mergeSets(nodeContext.getMemberSet(), discoveredNodes); nodeContext.updateMemberSet(newSet); nodeContext.addMemNodeSet(randomMember, discoveredNodes); log.info("Members fetched " + discoveredNodes.size()); } catch (SecurityException e) { log.error("Could not member gossip due to Security Exception"); } catch (TTransportException e) { if (e.getCause() instanceof ConnectException) { log.error("Could not connect to the member node for member gossiping"); nodeContext.removeMember(randomMember); nodeContext.removeMemNodeSet(randomMember); } else { log.error("Member Gossip failed :" + randomMember.getNodeId() + e.getMessage()); } } catch (TException e) { log.error("Member Gossip failed :" + randomMember.getNodeId() + e.getMessage()); } finally { transport.close(); } } }
From source file:org.siyapath.gossip.GossipImpl.java
/** * Initiates gossiping of node resource. Select a random member form the known member * list and gossip current statistics of node resource list by calling resourcesGossip service & * update the current list of node with resource with the response *///from www .j av a 2s .co m public void resourceGossiper() { NodeInfo randomMember = nodeContext.getRandomMember(); log.info("Getting a random member to gossip resources:" + randomMember); if (randomMember != null) { TTransport transport = new TSocket(randomMember.getIp(), randomMember.getPort()); //TTransport transport = new TFramedTransport(new TSocket("localhost", randomMember.getPort())); try { transport.open(); TProtocol protocol = new TBinaryProtocol(transport); Siyapath.Client client = new Siyapath.Client(protocol); Map<Integer, NodeResource> discoveredNodesResource = CommonUtils.deSerialize( client.resourceGossip(CommonUtils.serialize(nodeContext.getPartialResourceNodes()))); Map<Integer, NodeResource> newSet = mergeNewNodeResource(nodeContext.getMemberResourceMap(), discoveredNodesResource); nodeContext.updateMemberResourceSet(newSet); log.info("Node Resource Fetched:" + discoveredNodesResource.size()); } catch (SecurityException e) { log.error("Could not resource gossip due to Security Exception"); } catch (TTransportException e) { if (e.getCause() instanceof ConnectException) { log.error("Could not connect to the member node for resource gossiping"); nodeContext.removeMember(randomMember); nodeContext.removeFromMemResourceMap(randomMember.getNodeId()); } else { log.error("Resource Gossip failed with :" + randomMember.getNodeId() + e.getMessage()); } } catch (TException e) { log.error("Resource Gossip failed with :" + randomMember.getNodeId() + e.getMessage()); } finally { transport.close(); } } }
From source file:com.rapidminer.operator.ScriptingOperator.java
@Override public void doWork() throws OperatorException { String script = getParameterAsString(PARAMETER_SCRIPT); if (getParameterAsBoolean(PARAMETER_STANDARD_IMPORTS)) { StringBuffer imports = new StringBuffer(); imports.append("import com.rapidminer.example.*;\n"); imports.append("import com.rapidminer.example.set.*;\n"); imports.append("import com.rapidminer.example.table.*;\n"); imports.append("import com.rapidminer.operator.*;\n"); imports.append("import com.rapidminer.tools.Tools;\n"); imports.append("import java.util.*;\n"); script = imports.toString() + script; }/*from ww w .j a v a 2 s. c o m*/ List<IOObject> input = inExtender.getData(IOObject.class, false); Object result; try { // cache access is synchronized on a per-script basis to prevent Execute Script // inside a loop to start many parsings at the same time Object lock; synchronized (LOCK_MAP) { lock = LOCK_MAP.get(script); if (lock == null) { lock = new Object(); LOCK_MAP.put(script, lock); } } Script cachedScript; synchronized (lock) { cachedScript = SCRIPT_CACHE.get(script); if (cachedScript == null) { // use the delegator which is capable of handling multi-threaded access as // binding GroovyShell shell = new GroovyShell(Plugin.getMajorClassLoader(), new ConcurrentBindingDelegator()); GroovyCodeSource codeSource = new GroovyCodeSource(script, "customScript", GROOVY_DOMAIN); codeSource.setCachable(false); cachedScript = shell.parse(codeSource); SCRIPT_CACHE.put(script, cachedScript); } } // even though we cache the script, we need to use a new binding for each execution to // avoid multiple concurrent scripts running on the same/editing the same binding cachedScript.getBinding().setVariable("input", input); cachedScript.getBinding().setVariable("operator", this); // run the script via the delegator result = cachedScript.run(); } catch (SecurityException e) { throw new UserError(this, e, "scriptingOperator_security", e.getMessage()); } catch (GroovyBugError e) { if (e.getCause() instanceof SecurityException) { throw new UserError(this, e.getCause(), "scriptingOperator_security", e.getCause().getMessage()); } else { throw new UserError(this, e, 945, "Groovy", e); } } catch (Throwable e) { throw new UserError(this, e, 945, "Groovy", e, ExceptionUtils.getStackTrace(e)); } if (result instanceof Object[]) { outExtender.deliver(Arrays.asList((IOObject[]) result)); } else if (result instanceof List) { List<IOObject> results = new LinkedList<IOObject>(); for (Object single : (List<?>) result) { if (single instanceof IOObject) { results.add((IOObject) single); } else { getLogger().warning("Unknown result type: " + single); } } outExtender.deliver(results); } else { if (result != null) { if (result instanceof IOObject) { outExtender.deliver(Collections.singletonList((IOObject) result)); } else { getLogger().warning("Unknown result: " + result.getClass() + ": " + result); } } } }
From source file:org.getobjects.foundation.NSJavaRuntime.java
@SuppressWarnings("unchecked") public static Object NSAllocateObject(final Class _cls, Class[] _argTypes, Object[] _args) { // TBD: document if (_cls == null) return null; /* prepare arguments */ if (_argTypes == EmptyClassArray) _argTypes = null; /* will get recreated when appropriate */ if (_args == null && _argTypes == null) { _args = EmptyObjectArray;//from w ww .ja v a 2s . com _argTypes = EmptyClassArray; } else if (_argTypes == null) { /* derive argument types from arguments */ _argTypes = new Class[_args.length]; for (int i = 0; i < _args.length; i++) { if (_args[i] == null) { /* can't properly derive class from null */ _argTypes[i] = Object.class; } else _argTypes[i] = _args[i].getClass(); } } else if (_args == null) { /* creating an object already clears the values to 'null'? */ _args = new Object[_argTypes.length]; } /* find constructor */ Constructor ctor = null; try { /* TODO: this only does an EXACT match. Eg you can't pass in subclasses * of arguments (eg won't find a constructor taking a WOApplication * if the argument type is a WOApplication subclass). */ ctor = _cls.getConstructor(_argTypes); } catch (SecurityException e) { log.warn("cannot access constructor of object: " + _cls); return null; } catch (NoSuchMethodException e) { log.warn("did not find a proper constructor for object: " + _cls + "\n signature: " + UString.componentsJoinedByString(_argTypes, ", ")); return null; } if (ctor == null) { /* can't happen? */ log.error("got no constructor"); return null; } /* instantiate object */ Object result = null; try { result = ctor.newInstance(_args); } catch (IllegalArgumentException e) { log.error("illegal argument for constructor", e); return null; } catch (InstantiationException e) { log.error("could not instantiate object", e); return null; } catch (IllegalAccessException e) { log.error("illegal access", e); return null; } catch (InvocationTargetException e) { log.error("constructor failed with an exception", e.getCause()); return null; } return result; }
From source file:org.siyapath.task.TaskProcessor.java
/** * Process the task using instantiated java class generated through reflection *///from w w w .ja v a 2s. com private void processTask() { try { log.info("Starting the task: " + task.getTaskID()); taskInstance.setData(task.getTaskData()); taskInstance.process(); // taskInstance.setMetaData(String.valueOf(context.getNodeResource().getNodeInfo().getNodeId())); byte[] finalResult = taskInstance.getResults(); taskResult.setResults(finalResult); taskResult.setStatus(TaskStatus.COMPLETED); log.debug("Task processing is successful. ID: " + task.getTaskID()); } catch (SecurityException e) { siyapathSecurityManager.disable("secpass"); log.error("Task Processing aborted due to an attempt of illegal operation: " + e.getMessage()); taskResult.setStatus(TaskStatus.ABORTED_SECURITY); taskResult.setResults("<aborted_security_error>".getBytes()); } catch (ExceptionInInitializerError e) { siyapathSecurityManager.disable("secpass"); if (e.getCause() instanceof SecurityException) { log.error("Task Processing aborted due to an attempt of illegal operation: " + e.getMessage()); taskResult.setStatus(TaskStatus.ABORTED_SECURITY); taskResult.setResults("<aborted_security_error>".getBytes()); } log.error("Task Processing aborted due to an error: " + e.getMessage()); taskResult.setStatus(TaskStatus.ABORTED_SECURITY); taskResult.setResults("<aborted_error>".getBytes()); } catch (Exception e) { siyapathSecurityManager.disable("secpass"); log.error("Task Processing aborted due to an error: " + e.getMessage()); taskResult.setStatus(TaskStatus.ABORTED_SECURITY); taskResult.setResults("<aborted_error>".getBytes()); } }
From source file:de.micromata.genome.gwiki.page.impl.actionbean.ActionBeanUtils.java
public static Object dispatchToMethodImpl(ActionBean bean, String methodName, GWikiContext ctx) { if (methodName.startsWith("on") == false) { throw new IllegalArgumentException("Invalid method specified " + methodName); }// w w w.jav a 2 s. c om Method method; try { method = findMethod(bean, methodName); if (method == null) { method = findMethod(bean, "onUnbound"); } if (method == null) { throw new RuntimeException( "Cannot find method " + methodName + " in class " + bean.getClass().getName()); } } catch (SecurityException ex) { throw new RuntimeException( "Cannot find accessable method " + methodName + " in class " + bean.getClass().getName(), ex); } /* * if (method == null) throw new RuntimeException("Cannot find method " + methodName + " in class " + getClass().getName()); */ Object args[] = {}; Object o; try { o = method.invoke(bean, args); } catch (IllegalArgumentException ex) { // /** // * @logging // * @reason Allgemeiner Fehler bei der Verarbeitung // * @action Entwickler kontaktieren // */ // throw new LoggedRuntimeException(ex, LogLevel.Error, Category.RequestProcessing, "Unbehandelte IllegalArgumentException", // new LogExceptionAttribute(ex)); throw new RuntimeException(ex); } catch (IllegalAccessException ex) { // /** // * @logging // * @reason Allgemeiner Fehler bei der Verarbeitung // * @action Entwickler kontaktieren // */ // throw new LoggedRuntimeException(ex, LogLevel.Error, Category.RequestProcessing, "Unbehandelte IllegalAccessException in GAction", // new LogExceptionAttribute(ex)); throw new RuntimeException(ex); } catch (InvocationTargetException ex) { Throwable ca = ex.getCause(); if (ca == null) { throw new RuntimeException(ex); } if (ca instanceof RuntimeException) { throw (RuntimeException) ca; } throw new RuntimeException(ca); // Throwable thrEx = ex.getTargetException(); // if (thrEx instanceof LoggedRuntimeException) { // LoggedRuntimeException rtex = (LoggedRuntimeException) thrEx; // throw rtex; // } // if (thrEx instanceof SessionLostException) // throw (SessionLostException) thrEx; // // /** // * @logging // * @reason Allgemeiner Fehler bei der Verarbeitung // * @action Entwickler kontaktieren // */ // throw new LoggedRuntimeException(thrEx, LogLevel.Error, Category.RequestProcessing, "Unbehandelte Exception in GAction 1"); // throw new RuntimeException(ex); } return o; // if (checkErrors(ctx) == true) // return createForward(null, ctx); // return createForward(o, ctx); }