/** * Builds a new page stream transform using the given PDF operator processors (represented by * their class) to process the given PDF operators (represented by their operator string), and * imposing a default of {@link SimpleOperatorProcessor} for all others. * * @param pdfOperatorString1 A PDF operator string. * @param pdfOperatorProcessor1 A PDF operator processor class for <code>pdfOperatorString1</code> * . * @param pdfOperatorString2 A PDF operator string. * @param pdfOperatorProcessor2 A PDF operator processor class for <code>pdfOperatorString2</code> * . * @throws IOException if any processing error occurs. * @see #PageStreamTransform(Properties) * @see PropUtil#fromArgs(String, String, String, String) * @deprecated Use {@link #PageStreamTransform(OperatorProcessorFactory, String, Class, String, * Class)}. */ public PageStreamTransform( String pdfOperatorString1, Class pdfOperatorProcessor1, String pdfOperatorString2, Class pdfOperatorProcessor2) throws IOException { this( PropUtil.fromArgs( pdfOperatorString1, pdfOperatorProcessor1.getName(), pdfOperatorString2, pdfOperatorProcessor2.getName())); }
protected String getHttpResponseString(CachedUrl cu) { Properties cuProps = cu.getProperties(); Properties filteredProps = filterResponseProps(cuProps); String hdrString = PropUtil.toHeaderString(filteredProps); StringBuilder sb = new StringBuilder(hdrString.length() + 30); String line1 = inferHttpResponseCode(cu, cuProps); sb.append(line1); sb.append(Constants.CRLF); sb.append(hdrString); sb.append(Constants.CRLF); return sb.toString(); }
private boolean doFindUrl() throws IOException { String url = getParameter(KEY_URL); String redir = srvURL( AdminServletManager.SERVLET_DAEMON_STATUS, PropUtil.fromArgs("table", ArchivalUnitStatus.AUS_WITH_URL_TABLE_NAME, "key", url)); resp.setContentLength(0); // resp.sendRedirect(resp.encodeRedirectURL(redir)); resp.sendRedirect(redir); return false; }
/** * Builds a new page stream transform using the given PDF operator processors (represented by * their class) to process the given PDF operators (represented by their operator string), and * imposing a default of {@link SimpleOperatorProcessor} for all others. * * @param factory A {@link PdfOperatorProcessor} factory. * @param pdfOperatorString1 A PDF operator string. * @param pdfOperatorProcessor1 A PDF operator processor class for <code>pdfOperatorString1</code> * . * @param pdfOperatorString2 A PDF operator string. * @param pdfOperatorProcessor2 A PDF operator processor class for <code>pdfOperatorString2</code> * . * @param pdfOperatorString3 A PDF operator string. * @param pdfOperatorProcessor3 A PDF operator processor class for <code>pdfOperatorString3</code> * . * @throws IOException if any processing error occurs. * @see #PageStreamTransform(OperatorProcessorFactory, Properties) * @see PropUtil#fromArgs(String, String, String, String, String, String) */ public PageStreamTransform( OperatorProcessorFactory factory, String pdfOperatorString1, Class pdfOperatorProcessor1, String pdfOperatorString2, Class pdfOperatorProcessor2, String pdfOperatorString3, Class pdfOperatorProcessor3) throws IOException { this( factory, PropUtil.fromArgs( pdfOperatorString1, pdfOperatorProcessor1.getName(), pdfOperatorString2, pdfOperatorProcessor2.getName(), pdfOperatorString3, pdfOperatorProcessor3.getName())); }
/** * Builds a new page stream transform using the given PDF operator processor (represented by its * class) to process the given PDF operator (represented by its operator string), and imposing a * default of {@link SimpleOperatorProcessor} for all others. * * @param factory A {@link PdfOperatorProcessor} factory. * @param pdfOperatorString A PDF operator string. * @param pdfOperatorProcessor A PDF operator processor class for <code>pdfOperatorString</code>.. * @throws IOException if any processing error occurs. * @see #PageStreamTransform(OperatorProcessorFactory, Properties) * @see PropUtil#fromArgs(String, String) */ public PageStreamTransform( OperatorProcessorFactory factory, String pdfOperatorString, Class pdfOperatorProcessor) throws IOException { this(factory, PropUtil.fromArgs(pdfOperatorString, pdfOperatorProcessor.getName())); }
public boolean authenticate( String[] mechs, final String realm, final String authzid, final String u, final String p) throws ProtocolException { synchronized (pr) { // authenticate method should be synchronized List<Response> v = new ArrayList<Response>(); String tag = null; Response r = null; boolean done = false; if (logger.isLoggable(Level.FINE)) { logger.fine("SASL Mechanisms:"); for (int i = 0; i < mechs.length; i++) logger.fine(" " + mechs[i]); logger.fine(""); } SaslClient sc; CallbackHandler cbh = new CallbackHandler() { public void handle(Callback[] callbacks) { if (logger.isLoggable(Level.FINE)) logger.fine("SASL callback length: " + callbacks.length); for (int i = 0; i < callbacks.length; i++) { if (logger.isLoggable(Level.FINE)) logger.fine("SASL callback " + i + ": " + callbacks[i]); if (callbacks[i] instanceof NameCallback) { NameCallback ncb = (NameCallback) callbacks[i]; ncb.setName(u); } else if (callbacks[i] instanceof PasswordCallback) { PasswordCallback pcb = (PasswordCallback) callbacks[i]; pcb.setPassword(p.toCharArray()); } else if (callbacks[i] instanceof RealmCallback) { RealmCallback rcb = (RealmCallback) callbacks[i]; rcb.setText(realm != null ? realm : rcb.getDefaultText()); } else if (callbacks[i] instanceof RealmChoiceCallback) { RealmChoiceCallback rcb = (RealmChoiceCallback) callbacks[i]; if (realm == null) rcb.setSelectedIndex(rcb.getDefaultChoice()); else { // need to find specified realm in list String[] choices = rcb.getChoices(); for (int k = 0; k < choices.length; k++) { if (choices[k].equals(realm)) { rcb.setSelectedIndex(k); break; } } } } } } }; try { sc = Sasl.createSaslClient(mechs, authzid, name, host, (Map) props, cbh); } catch (SaslException sex) { logger.log(Level.FINE, "Failed to create SASL client", sex); throw new UnsupportedOperationException(sex.getMessage(), sex); } if (sc == null) { logger.fine("No SASL support"); throw new UnsupportedOperationException("No SASL support"); } if (logger.isLoggable(Level.FINE)) logger.fine("SASL client " + sc.getMechanismName()); try { Argument args = new Argument(); args.writeAtom(sc.getMechanismName()); if (pr.hasCapability("SASL-IR") && sc.hasInitialResponse()) { String irs; byte[] ba = sc.evaluateChallenge(new byte[0]); if (ba.length > 0) { ba = BASE64EncoderStream.encode(ba); irs = ASCIIUtility.toString(ba, 0, ba.length); } else irs = "="; args.writeAtom(irs); } tag = pr.writeCommand("AUTHENTICATE", args); } catch (Exception ex) { logger.log(Level.FINE, "SASL AUTHENTICATE Exception", ex); return false; } OutputStream os = pr.getIMAPOutputStream(); // stream to IMAP server /* * Wrap a BASE64Encoder around a ByteArrayOutputstream * to craft b64 encoded username and password strings * * Note that the encoded bytes should be sent "as-is" to the * server, *not* as literals or quoted-strings. * * Also note that unlike the B64 definition in MIME, CRLFs * should *not* be inserted during the encoding process. So, I * use Integer.MAX_VALUE (0x7fffffff (> 1G)) as the bytesPerLine, * which should be sufficiently large ! */ ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] CRLF = {(byte) '\r', (byte) '\n'}; // Hack for Novell GroupWise XGWTRUSTEDAPP authentication mechanism // http://www.novell.com/developer/documentation/gwimap/? // page=/developer/documentation/gwimap/gwimpenu/data/al7te9j.html boolean isXGWTRUSTEDAPP = sc.getMechanismName().equals("XGWTRUSTEDAPP") && PropUtil.getBooleanProperty( props, "mail." + name + ".sasl.xgwtrustedapphack.enable", true); while (!done) { // loop till we are done try { r = pr.readResponse(); if (r.isContinuation()) { byte[] ba = null; if (!sc.isComplete()) { ba = r.readByteArray().getNewBytes(); if (ba.length > 0) ba = BASE64DecoderStream.decode(ba); if (logger.isLoggable(Level.FINE)) logger.fine("SASL challenge: " + ASCIIUtility.toString(ba, 0, ba.length) + " :"); ba = sc.evaluateChallenge(ba); } if (ba == null) { logger.fine("SASL no response"); os.write(CRLF); // write out empty line os.flush(); // flush the stream bos.reset(); // reset buffer } else { if (logger.isLoggable(Level.FINE)) logger.fine("SASL response: " + ASCIIUtility.toString(ba, 0, ba.length) + " :"); ba = BASE64EncoderStream.encode(ba); if (isXGWTRUSTEDAPP) bos.write(ASCIIUtility.getBytes("XGWTRUSTEDAPP ")); bos.write(ba); bos.write(CRLF); // CRLF termination os.write(bos.toByteArray()); // write out line os.flush(); // flush the stream bos.reset(); // reset buffer } } else if (r.isTagged() && r.getTag().equals(tag)) // Ah, our tagged response done = true; else if (r.isBYE()) // outta here done = true; else // hmm .. unsolicited response here ?! v.add(r); } catch (Exception ioex) { logger.log(Level.FINE, "SASL Exception", ioex); // convert this into a BYE response r = Response.byeResponse(ioex); done = true; // XXX - ultimately return true??? } } if (sc.isComplete() /*&& res.status == SUCCESS*/) { String qop = (String) sc.getNegotiatedProperty(Sasl.QOP); if (qop != null && (qop.equalsIgnoreCase("auth-int") || qop.equalsIgnoreCase("auth-conf"))) { // XXX - NOT SUPPORTED!!! logger.fine("SASL Mechanism requires integrity or confidentiality"); return false; } } /* Dispatch untagged responses. * NOTE: in our current upper level IMAP classes, we add the * responseHandler to the Protocol object only *after* the * connection has been authenticated. So, for now, the below * code really ends up being just a no-op. */ Response[] responses = v.toArray(new Response[v.size()]); pr.notifyResponseHandlers(responses); // Handle the final OK, NO, BAD or BYE response pr.handleResult(r); pr.setCapabilities(r); /* * If we're using the Novell Groupwise XGWTRUSTEDAPP mechanism * to run as a specified authorization ID, we have to issue a * LOGIN command to select the user we want to operate as. */ if (isXGWTRUSTEDAPP && authzid != null) { Argument args = new Argument(); args.writeString(authzid); responses = pr.command("LOGIN", args); // dispatch untagged responses pr.notifyResponseHandlers(responses); // Handle result of this command pr.handleResult(responses[responses.length - 1]); // If the response includes a CAPABILITY response code, process it pr.setCapabilities(responses[responses.length - 1]); } return true; } }