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.smhdemo.common.datasource.generate.factory.bean.BeanDataSourceFactory.java

@Override
public DataSourceServiceable createService(Base alqcDataSource) {
    if (!(alqcDataSource instanceof Bean)) {
        logger.error("Bean?");
        throw new BaseRuntimeException("Bean??", new Object[] { alqcDataSource.getClass() });
    }// www .  j av a  2s  . c o  m
    Bean beanDataSource = (Bean) alqcDataSource;

    Object bean = ctx.getBean(beanDataSource.getBeanName());

    if (bean == null) {
        logger.error("Bean???");
        throw new BaseRuntimeException("Bean???", new Object[] { beanDataSource.getBeanName() });
    }

    if (beanDataSource.getBeanMethod() == null) {
        if (!(bean instanceof DataSourceServiceable)) {
            logger.error("Bean???EwcmsDataSourceServiceable");
            throw new BaseRuntimeException("Bean???EwcmsDataSourceServiceable",
                    new Object[] { beanDataSource.getBeanName() });
        } else {
            return (DataSourceServiceable) bean;
        }
    } else {
        Method serviceMethod;
        try {
            // serviceMethod = bean.getClass().getMethod(beanDataSource.getBeanMethod(),null);
            // return (ReportDataSourceServiceable)serviceMethod.invoke(bean,null);
            serviceMethod = bean.getClass().getMethod(beanDataSource.getBeanMethod(), new Class[0]);
            return (DataSourceServiceable) serviceMethod.invoke(bean, new Object[0]);
        } catch (SecurityException e) {
            logger.error("SecurityException", e);
            throw new BaseRuntimeException(e);
        } catch (NoSuchMethodException e) {
            logger.error("bean??", e);
            throw new BaseRuntimeException("bean??",
                    new Object[] { beanDataSource.getBeanName(), beanDataSource.getBeanMethod() });
        } catch (IllegalArgumentException e) {
            logger.error("IllegalArgumentException", e);
            throw new BaseRuntimeException(e);
        } catch (IllegalAccessException e) {
            logger.error("IllegalAccessException", e);
            throw new BaseRuntimeException(e);
        } catch (InvocationTargetException e) {
            logger.error("InvocationTargetException", e.getMessage());
            throw new BaseRuntimeException(e);
        }
    }
}

From source file:com.sshdemo.common.extendds.generate.factory.bean.BeanDataSourceFactory.java

@Override
public EwcmsDataSourceServiceable createService(BaseDS alqcDataSource) {
    if (!(alqcDataSource instanceof BeanDS)) {
        logger.error("Bean?");
        throw new BaseRuntimeException("Bean??", new Object[] { alqcDataSource.getClass() });
    }/*from  w  ww  .j  a v a 2  s .  c o  m*/
    BeanDS beanDataSource = (BeanDS) alqcDataSource;

    Object bean = ctx.getBean(beanDataSource.getBeanName());

    if (bean == null) {
        logger.error("Bean???");
        throw new BaseRuntimeException("Bean???", new Object[] { beanDataSource.getBeanName() });
    }

    if (beanDataSource.getBeanMethod() == null) {
        if (!(bean instanceof EwcmsDataSourceServiceable)) {
            logger.error("Bean???EwcmsDataSourceServiceable");
            throw new BaseRuntimeException("Bean???EwcmsDataSourceServiceable",
                    new Object[] { beanDataSource.getBeanName() });
        } else {
            return (EwcmsDataSourceServiceable) bean;
        }
    } else {
        Method serviceMethod;
        try {
            // serviceMethod = bean.getClass().getMethod(beanDataSource.getBeanMethod(),null);
            // return (ReportDataSourceServiceable)serviceMethod.invoke(bean,null);
            serviceMethod = bean.getClass().getMethod(beanDataSource.getBeanMethod(), new Class[0]);
            return (EwcmsDataSourceServiceable) serviceMethod.invoke(bean, new Object[0]);
        } catch (SecurityException e) {
            logger.error("SecurityException", e);
            throw new BaseRuntimeException(e);
        } catch (NoSuchMethodException e) {
            logger.error("bean??", e);
            throw new BaseRuntimeException("bean??",
                    new Object[] { beanDataSource.getBeanName(), beanDataSource.getBeanMethod() });
        } catch (IllegalArgumentException e) {
            logger.error("IllegalArgumentException", e);
            throw new BaseRuntimeException(e);
        } catch (IllegalAccessException e) {
            logger.error("IllegalAccessException", e);
            throw new BaseRuntimeException(e);
        } catch (InvocationTargetException e) {
            logger.error("InvocationTargetException", e.getMessage());
            throw new BaseRuntimeException(e);
        }
    }
}

From source file:com.blackducksoftware.tools.nrt.generator.NRTReportGenerator.java

/**
 * Generates Text output alongside the HTML
 * /*from w ww.j  a  va2 s.  c om*/
 * @param projectName
 * @param outputFilename
 * @throws Exception
 */
public void generateTextReport(String projectName) throws Exception {

    PrintStream outputTextFile = null;
    FileOutputStream outputStream = null;

    try {
        File dir = new File(projectName + "_text_files\\");
        dir.mkdirs();
    } catch (SecurityException e) {
        log.error("Unable to create directory for file output", e);
    }

    for (String compKey : componentMap.keySet()) {
        ComponentModel model = componentMap.get(compKey);

        try {
            String name = model.getName() + "_" + model.getVersion();

            outputStream = new FileOutputStream(projectName + "_text_files\\" + name + ".txt");

            outputTextFile = new PrintStream(outputStream);
        } catch (FileNotFoundException e) {
            outputStream.close();
            outputTextFile.close();
            log.error("File not found: " + e.getMessage());
        }

        // Add copyrights, filepaths and license text into the next column.
        /**
         * Write out the file paths
         */
        writeOutFilePaths(compKey, outputTextFile);

        /**
         * Write out all the copy rights
         */
        writeOutCopyrights(compKey, outputTextFile);

        /**
         * Write out all the licenses
         */
        writeOutLicenseText(compKey, outputTextFile);

    } // For all component names

    // Close the stream
    outputStream.close();
    outputTextFile.close();
}

From source file:org.apache.directory.fortress.core.ReviewMgrConsole.java

/**
 *
 *//*from w w w  .  j a va  2 s .com*/
void readRole() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter Role name to read:");
        Role role = new Role();
        role.setName(ReaderUtil.readLn());
        Role re = rm.readRole(role);
        if (re != null) {
            System.out.println("ROLE OBJECT:");
            System.out.println("    name      [" + re.getName() + "]");
            System.out.println("    internalId  [" + re.getId() + "]");
            System.out.println("    description [" + re.getDescription() + "]");
            System.out.println("    parents [" + re.getParents() + "]");
            printTemporal(re, "RBACROLE");
        } else {
            System.out.println("    name [" + role.getName() + "] was not found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("readRole caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.ReviewMgrConsole.java

void findRoles() {
    ReaderUtil.clearScreen();/*from w  w w.  j  ava 2s.  com*/
    try {
        System.out.println("");
        System.out.println("Enter value to search Roles with:");
        String val = ReaderUtil.readLn();
        List<Role> list = rm.findRoles(val);
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                Role re = list.get(i);
                System.out.println("ROLE OBJECT [" + i + "]:");
                System.out.println("    name      [" + re.getName() + "]");
                System.out.println("    internalId  [" + re.getId() + "]");
                System.out.println("    description [" + re.getDescription() + "]");
                System.out.println("    parents [" + re.getParents() + "]");
                printTemporal(re, "RBACROLE");
            }
        } else {
            System.out.println("name [" + val + "] was not found");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.ReviewMgrConsole.java

/**
  *//from   w w  w. j a  va2s.c o m
  */
void assignedRoles() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter UserId:");
        User user = new User();
        user.setUserId(ReaderUtil.readLn());
        List<UserRole> userRoles = rm.assignedRoles(user);
        if (userRoles != null) {
            for (UserRole userRole : userRoles) {
                System.out.println("ROLE OBJECT:");
                System.out.println("    name      [" + userRole.getName() + "]");
                printTemporal(userRole, "RBACROLE");
            }

        } else {
            System.out.println("    userId [" + user.getUserId() + "] has no roles");
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("assignedRoles caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.AuditMgrConsole.java

/**
 *
 *//*  www  .  j  a va  2 s  . c  om*/
void getAuthZs() {
    ReaderUtil.clearScreen();
    try {
        UserAudit uAudit = new UserAudit();
        System.out.println("Enter userId to search Audit AuthZs with:");
        String val = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(val)) {
            uAudit.setUserId(val);
            System.out.println("size=" + val.length() + " val=" + val);

        } else {
            System.out.println("val is empty or null");

        }
        System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
        val = ReaderUtil.readLn();
        if (val.equalsIgnoreCase("Y"))
            uAudit.setFailedOnly(true);

        List<AuthZ> list = am.getUserAuthZs(uAudit);
        printAuthZs(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("getUserAuthZs caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.ReviewMgrConsole.java

/**
 *
 *///from  w w  w .  j a v  a2s. c om
void authorizedUsers() {
    try {
        System.out.println("Enter role name:");
        String name = ReaderUtil.readLn();
        User ue;
        ArrayList list = (ArrayList) rm.authorizedUsers(new Role(name));
        int size = list.size();

        for (int i = 0; i < size; i++) {
            ue = (User) list.get(i);
            System.out.println("USER[" + i + "]");
            System.out.println("    userId      [" + ue.getUserId() + "]");
            System.out.println("    internalId  [" + ue.getInternalId() + "]");
            System.out.println("    description [" + ue.getDescription() + "]");
            System.out.println("    common name [" + ue.getCn() + "]");
            System.out.println("    surname     [" + ue.getSn() + "]");
            System.out.println("    orgUnitId   [" + ue.getOu() + "]");
            printTemporal(ue, "USER");
            printPosixAccount(ue, "POSIX");
            System.out.println();
        }
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("authorizedUsers caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(),
                e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.AuditMgrConsole.java

/**
 *
 *//*www.j  a v a2 s .  c  o  m*/
void getBindReport() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter userId value to search Audit Binds with or null to retrieve all:");
        String val = ReaderUtil.readLn();
        UserAudit uAudit = new UserAudit();
        uAudit.setUserId(val);
        System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
        val = ReaderUtil.readLn();
        if (val.equalsIgnoreCase("Y"))
            uAudit.setFailedOnly(true);

        System.out.println("Check within the last n hours?  Enter number of hours or null for unlimited");
        val = ReaderUtil.readLn();
        if (val != null && val.length() > 0) {
            int hours = Integer.parseInt(val);
            Date date = new Date();
            long millis = date.getTime();
            millis = millis - (1000 * 60 * 60 * hours);
            Date date2 = new Date(millis);
            uAudit.setBeginDate(date2);
        }

        List<Bind> list = am.searchBinds(uAudit);
        printAuthNReport(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("getBindReport caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.apache.directory.fortress.core.AuditMgrConsole.java

/**
 *
 *//*from  w w w.java  2s. co m*/
void findAuthZs() {
    ReaderUtil.clearScreen();
    try {
        System.out.println("Enter object name to search Audit AuthZs with:");
        String val = ReaderUtil.readLn();
        UserAudit uAudit = new UserAudit();
        uAudit.setObjName(val);
        System.out.println("Enter operation name to search Audit AuthZs with:");
        val = ReaderUtil.readLn();
        uAudit.setOpName(val);
        System.out.println("Enter userId to search Audit AuthZs with:");
        val = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(val)) {
            uAudit.setUserId(val);
            System.out.println("size=" + val.length() + " val=" + val);

        } else {
            System.out.println("val is empty or null");

        }
        //uAudit.setUserId(val);
        System.out.println("Check for failed only? (Enter 'Y' for yes or 'N' for no");
        val = ReaderUtil.readLn();
        if (val.equalsIgnoreCase("Y"))
            uAudit.setFailedOnly(true);

        List<AuthZ> list = am.searchAuthZs(uAudit);
        printAuthZs(list);
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("findAuthZs caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}