Example usage for java.lang SecurityException getMessage

List of usage examples for java.lang SecurityException getMessage

Introduction

In this page you can find the example usage for java.lang SecurityException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.thinkbiganalytics.nifi.v2.thrift.ThriftConnectionPool.java

/**
 * Validates that one or more files exist, as specified in a single property.
 *
 * @return a validator which describes the result of the validation
 *//*from  ww  w  . java  2  s  .c o m*/
public static final Validator createMultipleFilesExistValidator() {
    return new Validator() {
        @Override
        public ValidationResult validate(String subject, String input, ValidationContext context) {
            final String[] files = input.split(",");
            for (String filename : files) {
                try {
                    final File file = new File(filename.trim());
                    final boolean valid = file.exists() && file.isFile();
                    if (!valid) {
                        final String message = "File " + file + " does not exist or is not a file";
                        return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                                .explanation(message).build();
                    }
                } catch (SecurityException e) {
                    final String message = "Unable to access " + filename + " due to " + e.getMessage();
                    return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                            .explanation(message).build();
                }
            }
            return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
        }

    };
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Sets the window shape if possible./*from  w  ww  . j  ava  2s  . co m*/
 * 
 * @param window
 *            A mindow
 * @param mask
 *            A mask
 */
public static void setWindowShape(Window window, Shape mask) {
    if (setWindowShapeMethod != null) {
        try {
            setWindowShapeMethod.invoke(null, window, mask);
        } catch (SecurityException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalArgumentException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalAccessException e) {
            log.error(e.getMessage(), e);
        } catch (InvocationTargetException e) {
            log.error(e.getMessage(), e);
        } catch (UnsupportedOperationException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:com.thinkbiganalytics.nifi.v2.hdfs.AbstractHadoopProcessor.java

/**
 * Validates that one or more files exist, as specified in a single property.
 *
 * @return a validator instance that validates the files given
 *//*  w ww . j  av a 2 s  . co m*/
public static Validator createMultipleFilesExistValidator() {
    return new Validator() {
        @Override
        public ValidationResult validate(String subject, String input, ValidationContext context) {
            final String[] files = input.split(",");
            for (String filename : files) {
                try {
                    final File file = new File(filename.trim());
                    final boolean valid = file.exists() && file.isFile();
                    if (!valid) {
                        final String message = "File " + file + " does not exist or is not a file";
                        return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                                .explanation(message).build();
                    }
                } catch (SecurityException e) {
                    final String message = "Unable to access " + filename + " due to " + e.getMessage();
                    return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                            .explanation(message).build();
                }
            }
            return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
        }

    };
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Sets the window opacity if possible.//  ww  w  .ja  v a 2 s.c o m
 * 
 * @param window
 *            A window
 * @param opacity
 *            Opacity from 0 to 1
 */

public static void setWindowOpacity(Window window, float opacity) {
    if (setWindowOpacityMethod != null) {
        try {
            setWindowOpacityMethod.invoke(null, window, opacity);
        } catch (SecurityException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalArgumentException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalAccessException e) {
            log.error(e.getMessage(), e);
        } catch (InvocationTargetException e) {
            log.error(e.getMessage(), e);
            // In some systems where window opacity is not supported
            // This method launches InvocationTargetException continuosly
            // So the first time exception is thrown, we disable 
            // call to setWindowOpacityMethod
            setWindowOpacityMethod = null;
        } catch (UnsupportedOperationException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Sets the window opaque if possible.//w  w  w .  j a v a 2 s  . c om
 * 
 * @param window
 *            A window
 * @param opaque
 *            If the window should be opaque
 */

public static void setWindowOpaque(Window window, boolean opaque) {
    if (setWindowOpaqueMethod != null) {
        try {
            setWindowOpaqueMethod.invoke(null, window, opaque);
        } catch (SecurityException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalArgumentException e) {
            log.error(e.getMessage(), e);
        } catch (IllegalAccessException e) {
            log.error(e.getMessage(), e);
        } catch (InvocationTargetException e) {
            log.error(e.getMessage(), e);
            // In some systems where window opacity is not supported
            // This method launches InvocationTargetException continuosly
            // So the first time exception is thrown, we disable 
            // call to setWindowOpaqueMethod
            setWindowOpaqueMethod = null;
        } catch (UnsupportedOperationException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:Main.java

/**
 * Method called to check if we can use the passed method or constructor
 * (wrt access restriction -- public methods can be called, others
 * usually not); and if not, if there is a work-around for
 * the problem.//from w  w  w .j  a v  a2  s. c o  m
 */
public static void checkAndFixAccess(Member member) {
    // We know all members are also accessible objects...
    AccessibleObject ao = (AccessibleObject) member;

    /* 14-Jan-2009, tatu: It seems safe and potentially beneficial to
     *   always to make it accessible (latter because it will force
     *   skipping checks we have no use for...), so let's always call it.
     */
    //if (!ao.isAccessible()) {
    try {
        ao.setAccessible(true);
    } catch (SecurityException se) {
        /* 17-Apr-2009, tatu: Related to [JACKSON-101]: this can fail on
         *    platforms like EJB and Google App Engine); so let's
         *    only fail if we really needed it...
         */
        if (!ao.isAccessible()) {
            Class<?> declClass = member.getDeclaringClass();
            throw new IllegalArgumentException("Can not access " + member + " (from class "
                    + declClass.getName() + "; failed to set access: " + se.getMessage());
        }
    }
    //}
}

From source file:org.grails.datastore.gorm.finders.DynamicFinder.java

/**
 * Registers a new method expression. The Class must extends from the class {@link MethodExpression} and provide
 * a constructor that accepts a Class parameter and a String parameter.
 *
 * @param methodExpression A class that extends from {@link MethodExpression}
 *//*from  w ww.  j  ava 2  s . c o m*/
public static void registerNewMethodExpression(Class methodExpression) {
    try {
        methodExpressions.put(methodExpression.getSimpleName(),
                methodExpression.getConstructor(Class.class, String.class));
        resetMethodExpressionPattern();
    } catch (SecurityException e) {
        throw new IllegalArgumentException("Class [" + methodExpression
                + "] does not provide a constructor that takes parameters of type Class and String: "
                + e.getMessage(), e);
    } catch (NoSuchMethodException e) {
        throw new IllegalArgumentException("Class [" + methodExpression
                + "] does not provide a constructor that takes parameters of type Class and String: "
                + e.getMessage(), e);
    }
}

From source file:com.amalto.workbench.utils.HttpClientUtil.java

public static String invokeCreateTDSCampaignService(String protocol, String host, String port,
        String contextPath, String username, String password, String modelName) throws XtentisException {
    try {/* w ww . j  a va  2 s. c  o  m*/
        String url = protocol + host + ":" + port + contextPath + "/services/rest/tds/setup?model=" + modelName; //$NON-NLS-1$ //$NON-NLS-2$ 

        DefaultHttpClient httpClient = wrapAuthClient(url, username, password);

        HttpUriRequest request = new HttpPut(url);
        request.setHeader("Accept", "application/json"); //$NON-NLS-1$ //$NON-NLS-2$
        addStudioToken(request, username);
        HttpContext preemptiveContext = getPreemptiveContext(url);
        authenticate(username, password, request, preemptiveContext);
        String errMessage = Messages.Util_21 + "%s" + Messages.Util_22 + "%s"; //$NON-NLS-1$//$NON-NLS-2$
        String content = getResponseContent(httpClient, request, null, errMessage, String.class, true);
        if (content == null) {
            content = ""; //$NON-NLS-1$
        }
        return content;
    } catch (SecurityException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.thinkbiganalytics.nifi.v2.spark.ExecuteSparkJob.java

public static final Validator createMultipleFilesExistValidator() {
    return new Validator() {
        @Override//from  w w w . j  a  v  a  2  s  . c o m
        public ValidationResult validate(String subject, String input, ValidationContext context) {
            final String[] files = input.split(",");
            for (String filename : files) {
                try {
                    final File file = new File(filename.trim());
                    if (!file.exists()) {
                        final String message = "file " + filename + " does not exist";
                        return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                                .explanation(message).build();
                    } else if (!file.isFile()) {
                        final String message = filename + " is not a file";
                        return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                                .explanation(message).build();
                    } else if (!file.canRead()) {
                        final String message = "could not read " + filename;
                        return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                                .explanation(message).build();
                    }
                } catch (SecurityException e) {
                    final String message = "Unable to access " + filename + " due to " + e.getMessage();
                    return new ValidationResult.Builder().subject(subject).input(input).valid(false)
                            .explanation(message).build();
                }
            }
            return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
        }

    };
}

From source file:com.thinkbiganalytics.nifi.pyspark.core.ExecutePySpark.java

public static Validator multipleFilesExistValidator() {
    return new Validator() {
        @Override//from  w w w .  j  a va 2 s  .c  o  m
        public ValidationResult validate(String subject, String input, ValidationContext context) {
            try {
                final String[] files = input.split(",");

                for (String filename : files) {
                    try {
                        final File file = new File(filename.trim());
                        if (!file.exists()) {
                            final String message = "file " + filename + " does not exist.";
                            return new ValidationResult.Builder().subject(this.getClass().getSimpleName())
                                    .input(input).valid(false).explanation(message).build();
                        } else if (!file.isFile()) {
                            final String message = filename + " is not a file.";
                            return new ValidationResult.Builder().subject(this.getClass().getSimpleName())
                                    .input(input).valid(false).explanation(message).build();
                        } else if (!file.canRead()) {
                            final String message = "could not read " + filename;
                            return new ValidationResult.Builder().subject(this.getClass().getSimpleName())
                                    .input(input).valid(false).explanation(message).build();
                        }
                    } catch (SecurityException e) {
                        final String message = "unable to access " + filename + " due to " + e.getMessage();
                        return new ValidationResult.Builder().subject(this.getClass().getSimpleName())
                                .input(input).valid(false).explanation(message).build();
                    }
                }
            } catch (Exception e) {
                return new ValidationResult.Builder().subject(this.getClass().getSimpleName()).input(input)
                        .valid(false)
                        .explanation(
                                "error evaluating value. Please sure that value is provided as file1,file2,file3 and so on. "
                                        + "Also, the files should exist and be readable.")
                        .build();
            }

            return new ValidationResult.Builder().subject(this.getClass().getSimpleName()).input(input)
                    .valid(true).build();
        }
    };
}