/** * This method initializes cCancelButton * * @return org.compiere.swing.CButton */ private CButton getCCancelButton() { if (cCancelButton == null) { cCancelButton = new CButton(); cCancelButton.setIcon(getPoS().getImageIcon("Cancel16.gif")); cCancelButton.setPreferredSize(new java.awt.Dimension(BUTTON_WIDTH, 26)); cCancelButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { commandCancel(); } }); KeyUtils.setCancelButtonKeys(cCancelButton); KeyUtils.setButtonText(cCancelButton, MSG_CANCEL); FocusUtils.addFocusHighlight(cCancelButton); } return cCancelButton; }
/** * This method initializes cClearButton * * @return org.compiere.swing.CButton */ private CButton getCClearButton() { if (cClearButton == null) { cClearButton = new CButton(); cClearButton.setIcon(getPoS().getImageIcon("Reset16.gif")); cClearButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { commandClear(); } }); cClearButton.setPreferredSize(new java.awt.Dimension(BUTTON_WIDTH, 26)); KeyUtils.setButtonKey(cClearButton, true, KeyEvent.VK_F5); KeyUtils.setDefaultKey(cClearButton); KeyUtils.setButtonText(cClearButton, MSG_CLEAR); FocusUtils.addFocusHighlight(cClearButton); } return cClearButton; }
/** * @param fallbackResolver The {@link PublicKeyEntryResolver} to consult if none of the built-in * ones can be used. If {@code null} and no built-in resolver can be used then an {@link * InvalidKeySpecException} is thrown. * @return The resolved {@link PublicKey} - or {@code null} if could not be resolved. <B>Note:</B> * may be called only after key type and data bytes have been set or exception(s) may be * thrown * @throws IOException If failed to decode the key * @throws GeneralSecurityException If failed to generate the key */ public PublicKey resolvePublicKey(PublicKeyEntryResolver fallbackResolver) throws IOException, GeneralSecurityException { String kt = getKeyType(); PublicKeyEntryResolver decoder = KeyUtils.getPublicKeyEntryDecoder(kt); if (decoder == null) { decoder = fallbackResolver; } if (decoder == null) { throw new InvalidKeySpecException("No decoder available for key type=" + kt); } return decoder.resolve(kt, getKeyData()); }
public ElementUriKey( DocumentSelector documentSelector, ElementSelector elementSelector, Map<String, String> namespaces) { super( new ResourceSelector( documentSelector.toString(), KeyUtils.getPercentEncondedElementSelector(elementSelector), namespaces)); this.documentSelector = documentSelector; this.elementSelector = elementSelector; this.namespaces = namespaces; }
/** * Encodes a public key data the same way as the {@link #parsePublicKeyEntry(String)} expects it * * @param <A> The generic appendable class * @param sb The {@link Appendable} instance to encode the data into * @param key The {@link PublicKey} - ignored if {@code null} * @return The updated appendable instance * @throws IOException If failed to append the data */ public static <A extends Appendable> A appendPublicKeyEntry(A sb, PublicKey key) throws IOException { if (key == null) { return sb; } @SuppressWarnings("unchecked") PublicKeyEntryDecoder<PublicKey, ?> decoder = (PublicKeyEntryDecoder<PublicKey, ?>) KeyUtils.getPublicKeyEntryDecoder(key); if (decoder == null) { throw new StreamCorruptedException("Cannot retrieve decoder for key=" + key.getAlgorithm()); } try (ByteArrayOutputStream s = new ByteArrayOutputStream(Byte.MAX_VALUE)) { String keyType = decoder.encodePublicKey(s, key); byte[] bytes = s.toByteArray(); String b64Data = Base64.encodeToString(bytes); sb.append(keyType).append(' ').append(b64Data); } return sb; }
public static void fixCopyPasteBug(JComponent comp) { KeyUtils.installLostClipboardActions(comp); }
/** * Create or replace a Pico file. If the file exists it will be replaced. If it does not exist it * is created. A random key is used. * * <p>TODO: May want to add a String parameter that is "rw", "r", etc. * * @param filename The filename. * @return The Pico file instance. * @throws IOException The file cannot be created. */ public static PicoFile create(File file) throws IOException { if (file == null) { throw new NullPointerException("The file is null."); } return create(file, KeyUtils.makeKey()); }