Example usage for java.util.zip DataFormatException DataFormatException

List of usage examples for java.util.zip DataFormatException DataFormatException

Introduction

In this page you can find the example usage for java.util.zip DataFormatException DataFormatException.

Prototype

public DataFormatException() 

Source Link

Document

Constructs a DataFormatException with no detail message.

Usage

From source file:jp.co.yahoo.yconnect.core.oidc.IdTokenDecoder.java

private HashMap<String, String> splitIdToken() throws DataFormatException {
    String[] idTokens = this.idTokenString.split("\\.");

    if (idTokens.length != 3) {
        throw new DataFormatException();
    }/*from   w  w  w .j  av a 2 s .  co m*/

    // ??idToken?
    HashMap<String, String> idTokenMap = new HashMap<String, String>();
    idTokenMap.put("header", new String(Base64.decodeBase64(idTokens[0].getBytes())));
    idTokenMap.put("payload", new String(Base64.decodeBase64(idTokens[1].getBytes())));
    idTokenMap.put("signature", idTokens[2]);

    return idTokenMap;
}

From source file:org.opencms.workplace.commons.CmsPublishResourcesList.java

/**
 * @see org.opencms.workplace.list.A_CmsListDialog#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
 *///  w  ww  . ja  v a  2 s  . co m
@Override
protected void setIndependentActions(CmsListMetadata metadata) {

    /**
     * Class to render a javascript driven detail action button.<p>
     */
    abstract class DetailsJsAction extends A_CmsListIndependentJsAction {

        /**
         * Default constructor.<p>
         * 
         * @param id the action id
         */
        public DetailsJsAction(String id) {

            super(id);
        }

        /**
         * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
         */
        @Override
        public String buttonHtml(CmsWorkplace wp) {

            StringBuffer html = new StringBuffer(1024);
            html.append("\t<span id='");
            html.append(getId());
            html.append("' class=\"link");
            html.append("\"");
            html.append(" onClick=\"");
            html.append(resolveOnClic(wp));
            html.append("\"");
            html.append(">");
            html.append("<img src='");
            html.append(CmsWorkplace.getSkinUri());
            html.append(getIconPath());
            html.append("'");
            html.append(" alt='");
            html.append(getName().key(wp.getLocale()));
            html.append("'");
            html.append(" title='");
            html.append(getName().key(wp.getLocale()));
            html.append("'");
            html.append(">");
            html.append("&nbsp;");
            html.append("<a href='#'>");
            html.append(getName().key(wp.getLocale()));
            html.append("</a>");
            html.append("</span>");
            return html.toString();
        }
    }

    I_CmsListAction hideAction = new DetailsJsAction(LIST_DETAIL_RELATIONS_HIDE) {

        /**
         * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
         */
        @Override
        public String jsCode(CmsWorkplace wp) {

            return "javascript:showRelatedResources(false);";
        }
    };
    hideAction.setIconPath(A_CmsListDialog.ICON_DETAILS_HIDE);
    hideAction.setName(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
    hideAction.setHelpText(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));
    metadata.addIndependentAction(hideAction);

    I_CmsListAction showAction = new DetailsJsAction(LIST_DETAIL_RELATIONS_SHOW) {

        /**
         * @see org.opencms.workplace.list.A_CmsListIndependentJsAction#jsCode(CmsWorkplace)
         */
        @Override
        public String jsCode(CmsWorkplace wp) {

            return "javascript:showRelatedResources(true);";
        }
    };
    showAction.setIconPath(A_CmsListDialog.ICON_DETAILS_SHOW);
    showAction.setName(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
    showAction.setHelpText(Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
    metadata.addIndependentAction(showAction);

    // create list item detail
    CmsListItemDetails relationsDetails = new CmsListItemDetails(LIST_DETAIL_RELATIONS) {

        /**
         * @see org.opencms.workplace.list.CmsListItemDetails#getAction()
         */
        @Override
        public I_CmsListAction getAction() {

            return new CmsListIndependentAction("hide") {

                /**
                 * @see org.opencms.workplace.list.CmsListIndependentAction#buttonHtml(org.opencms.workplace.CmsWorkplace)
                 */
                @Override
                public String buttonHtml(CmsWorkplace wp) {

                    return "";
                }
            };
        }
    };
    relationsDetails.setAtColumn(LIST_COLUMN_NAME);
    relationsDetails.setVisible(true);
    relationsDetails.setFormatter(new I_CmsListFormatter() {

        public String format(Object data, Locale locale) {

            if (!(data instanceof List)) {
                return new DataFormatException().getLocalizedMessage();
            }
            StringBuffer html = new StringBuffer(512);
            @SuppressWarnings("unchecked")
            Iterator<String> itResourceNames = ((List<String>) data).iterator();
            if (itResourceNames.hasNext()) {
                html.append("<table border='0' cellspacing='0' cellpadding='0'>\n");
            }
            while (itResourceNames.hasNext()) {
                String resName = itResourceNames.next();
                html.append("\t<tr>\n");
                html.append("\t\t<td width='150' align='right' class='listdetailhead'>\n");
                html.append("\t\t\t");
                if (resName.endsWith("*")) {
                    // resource is not lockable, and will not be published
                    resName = resName.substring(0, resName.length() - 1);
                    html.append("<font color='red' />");
                    html.append(Messages.get().getBundle(locale)
                            .key(Messages.GUI_PUBLISH_DETAIL_RELATED_LOCKED_RESOURCE_0));
                    html.append("</font/>");
                } else if (resName.endsWith("!")) {
                    // resource will be published
                    resName = resName.substring(0, resName.length() - 1);
                    html.append(Messages.get().getBundle(locale)
                            .key(Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_0));
                } else if (resName.endsWith("$")) {
                    // reverse reference
                    resName = resName.substring(0, resName.length() - 1);
                    html.append(Messages.get().getBundle(locale)
                            .key(Messages.GUI_PUBLISH_DETAIL_REVERSE_REFERENCE_0));
                } else {
                    // resource will not be published
                    html.append("<font color='red' />");
                    html.append(Messages.get().getBundle(locale)
                            .key(Messages.GUI_PUBLISH_DETAIL_RELATED_RESOURCE_NO_0));
                    html.append("</font/>");
                }
                html.append("&nbsp;:&nbsp;\n");
                html.append("\t\t</td>\n");
                html.append("\t\t<td class='listdetailitem' style='white-space:normal;'>\n");
                html.append("\t\t\t");
                html.append(resName);
                html.append("\n");
                html.append("\t\t</td>\n");
                html.append("\t</tr>\n");
            }
            if (html.length() > 0) {
                html.append("</table>\n");
            }
            return html.toString();
        }

    });
    relationsDetails.setShowActionName(
            Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_NAME_0));
    relationsDetails.setShowActionHelpText(
            Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_SHOW_HELP_0));
    relationsDetails.setHideActionName(
            Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_NAME_0));
    relationsDetails.setHideActionHelpText(
            Messages.get().container(Messages.GUI_PUBLISH_RELATED_RESOURCES_DETAIL_HIDE_HELP_0));

    // add resources info item detail to meta data
    metadata.addItemDetails(relationsDetails);
}