List of usage examples for javax.servlet.http HttpServletResponse SC_NOT_IMPLEMENTED
int SC_NOT_IMPLEMENTED
To view the source code for javax.servlet.http HttpServletResponse SC_NOT_IMPLEMENTED.
Click Source Link
From source file:org.dspace.app.dav.DAVBitstream.java
@Override protected void put() throws SQLException, AuthorizeException, IOException, DAVStatusException { throw new DAVStatusException(HttpServletResponse.SC_NOT_IMPLEMENTED, "PUT is not implemented for Bitstream (yet?)."); }
From source file:org.ejbca.ui.web.protocol.ScepServlet.java
private void service(String operation, String message, String remoteAddr, HttpServletResponse response, String pathInfo) throws IOException { String alias = getAlias(pathInfo); if (alias == null) { log.info("Wrong URL format. The SCEP URL should look like: " + "'http://HOST:PORT/ejbca/publicweb/apply/scep/ALIAS/pkiclien.exe' " + "but was 'http://HOST:PORT/ejbca/publicweb/apply/scep" + pathInfo + "'"); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Wrong URL. No alias found."); return;/*from www . ja v a 2 s . c o m*/ } if (alias.length() > 32) { log.info("Unaccepted alias more than 32 characters."); response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unaccepted alias more than 32 characters."); return; } ScepConfiguration scepConfig = (ScepConfiguration) this.globalConfigSession .getCachedConfiguration(ScepConfiguration.SCEP_CONFIGURATION_ID); if (!scepConfig.aliasExists(alias)) { String msg = "SCEP alias '" + alias + "' does not exist"; log.info(msg); response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); return; } try { if (operation == null) { String errMsg = intres.getLocalizedMessage("scep.errormissingparam", remoteAddr); log.error(errMsg); response.sendError(HttpServletResponse.SC_BAD_REQUEST, errMsg); return; } final AuthenticationToken administrator = new AlwaysAllowLocalAuthenticationToken( new UsernamePrincipal("ScepServlet: " + remoteAddr)); if (log.isDebugEnabled()) { log.debug("Got request '" + operation + "'"); log.debug("Message: " + message); } String iMsg = intres.getLocalizedMessage("scep.receivedmsg", remoteAddr); log.info(iMsg); if (operation.equals("PKIOperation")) { if (message == null) { String errMsg = intres.getLocalizedMessage("scep.errormissingparam", remoteAddr); log.error(errMsg); response.sendError(HttpServletResponse.SC_BAD_REQUEST, errMsg); return; } byte[] scepmsg = Base64.decode(message.getBytes()); // Read the message end get the cert, this also checks authorization byte[] reply = scepCertRequest(administrator, scepmsg, alias, scepConfig); if (reply == null) { // This is probably a getCert message? response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "Can not handle request"); return; } // Send back Scep response, PKCS#7 which contains the end entity's certificate (or failure) RequestHelper.sendBinaryBytes(reply, response, "application/x-pki-message", null); iMsg = intres.getLocalizedMessage("scep.sentresponsemsg", "PKIOperation", remoteAddr); log.info(iMsg); } else if (operation.equals("GetCACert")) { // The response has the content type tagged as application/x-x509-ca-cert. // The body of the response is a DER encoded binary X.509 certificate. // For example: "Content-Type:application/x-x509-ca-cert\n\n"<BER-encoded X509> // CA_IDENT is the message for this request to indicate which CA we are talking about final String caname = getCAName(message); if (log.isDebugEnabled()) { log.debug("Got SCEP cert request for CA '" + caname + "'"); } Collection<Certificate> certs = null; CAInfo cainfo = casession.getCAInfoInternal(-1, caname, true); if (cainfo != null) { certs = cainfo.getCertificateChain(); } if ((certs != null) && (certs.size() > 0)) { // CAs certificate is in the first position in the Collection X509Certificate cert = (X509Certificate) certs.iterator().next(); if (log.isDebugEnabled()) { log.debug("Sent certificate for CA '" + caname + "' to SCEP client."); } RequestHelper.sendNewX509CaCert(cert.getEncoded(), response); iMsg = intres.getLocalizedMessage("scep.sentresponsemsg", "GetCACert", remoteAddr); log.info(iMsg); } else { String errMsg = intres.getLocalizedMessage("scep.errorunknownca", "cert"); log.error(errMsg); response.sendError(HttpServletResponse.SC_NOT_FOUND, "No CA certificates found."); } } else if (operation.equals("GetCACertChain")) { // The response for GetCACertChain is a certificates-only PKCS#7 // SignedDatato carry the certificates to the end entity, with a // Content-Type of application/x-x509-ca-ra-cert-chain. // CA_IDENT is the message for this request to indicate which CA we are talking about final String caname = getCAName(message); log.debug("Got SCEP pkcs7 request for CA '" + caname + "'"); CAInfo cainfo = casession.getCAInfo(administrator, caname); byte[] pkcs7 = signsession.createPKCS7(administrator, cainfo.getCAId(), true); if ((pkcs7 != null) && (pkcs7.length > 0)) { if (log.isDebugEnabled()) { log.debug("Sent PKCS7 for CA '" + caname + "' to SCEP client."); } RequestHelper.sendBinaryBytes(pkcs7, response, "application/x-x509-ca-ra-cert-chain", null); iMsg = intres.getLocalizedMessage("scep.sentresponsemsg", "GetCACertChain", remoteAddr); log.info(iMsg); } else { String errMsg = intres.getLocalizedMessage("scep.errorunknownca", "pkcs7"); log.error(errMsg); response.sendError(HttpServletResponse.SC_NOT_FOUND, "No CA certificates found."); } } else if (operation.equals("GetCACaps")) { // The response for GetCACaps is a <lf> separated list of capabilities /* "GetNextCACert" CA Supports the GetNextCACert message. "POSTPKIOperation" PKIOPeration messages may be sent via HTTP POST. "SHA-1" CA Supports the SHA-1 hashing algorithm in signatures and fingerprints. If present, the client SHOULD use SHA-1. If absent, the client MUST use MD5 to maintain backward compatability. "Renewal" Clients may use current certificate and key to authenticate an enrollment request for a new certificate. */ log.debug("Got SCEP GetCACaps request"); response.setContentType("text/plain"); response.getOutputStream().print("POSTPKIOperation\nRenewal\nSHA-1"); } else { log.error("Invalid parameter '" + operation); // Send back proper Failure Response response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid parameter: " + HTMLTools.htmlescape(operation)); } } catch (CADoesntExistsException cae) { String errMsg = intres.getLocalizedMessage("scep.errorunknownca", "cert"); log.info(errMsg, cae); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_NOT_FOUND, cae.getMessage()); } catch (DecoderException de) { String errMsg = intres.getLocalizedMessage("scep.errorinvalidreq"); log.info(errMsg, de); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_BAD_REQUEST, de.getMessage()); } catch (AuthorizationDeniedException ae) { String errMsg = intres.getLocalizedMessage("scep.errorauth"); log.info(errMsg, ae); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_UNAUTHORIZED, ae.getMessage()); } catch (AuthLoginException ae) { String errMsg = intres.getLocalizedMessage("scep.errorauth"); log.info(errMsg, ae); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_UNAUTHORIZED, ae.getMessage()); } catch (AuthStatusException ae) { String errMsg = intres.getLocalizedMessage("scep.errorclientstatus"); log.info(errMsg, ae); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_UNAUTHORIZED, ae.getMessage()); } catch (CryptoTokenOfflineException ee) { String errMsg = intres.getLocalizedMessage("scep.errorgeneral"); log.info(errMsg, ee); // TODO: Send back proper Failure Response response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ee.getMessage()); } catch (NoSuchEndEntityException ee) { String errMsg = intres.getLocalizedMessage("scep.errorgeneral"); errMsg += " Registering new EndEntities is only allowed in RA mode."; log.info(errMsg, ee); response.sendError(HttpServletResponse.SC_FORBIDDEN, ee.getMessage()); } catch (IllegalKeyException e) { String errMsg = intres.getLocalizedMessage("scep.errorclientcertificaterenewal"); errMsg += " Reusing the old keys was attempted, but this action is prohibited by configuration."; log.info(errMsg, e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } catch (SignatureException e) { String errMsg = intres.getLocalizedMessage("scep.errorclientcertificaterenewal"); errMsg += " Request was not signed with previous certificate's public key."; log.info(errMsg, e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } catch (ClientCertificateRenewalException e) { String errMsg = intres.getLocalizedMessage("scep.errorclientcertificaterenewal"); log.info(errMsg, e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } catch (Exception e) { String errMsg = intres.getLocalizedMessage("scep.errorgeneral"); log.info(errMsg, e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } }
From source file:org.dspace.app.dav.DAVBitstream.java
@Override protected int copyInternal(DAVResource destination, int depth, boolean overwrite, boolean keepProperties) throws DAVStatusException, SQLException, AuthorizeException, IOException { throw new DAVStatusException(HttpServletResponse.SC_NOT_IMPLEMENTED, "COPY method not implemented."); }
From source file:org.occiware.mart.servlet.impl.ServletEntry.java
private void parseResponseAuthenticationNotImplemented(String authenticationMethod) { occiResponse.getHttpResponse().setHeader(Constants.HEADER_WWW_AUTHENTICATE, authenticationMethod + " realm=\"" + getServerURI() + "\""); String message = "HTTP " + authenticationMethod + " authentication method is not implemented at this time"; occiResponse.parseMessage(message, HttpServletResponse.SC_NOT_IMPLEMENTED); occiResponse.setExceptionThrown(new AuthenticationException(message)); }
From source file:org.jscep.server.ScepServlet.java
private void doGetNextCaCert(final HttpServletRequest req, final HttpServletResponse res) throws Exception { res.setHeader("Content-Type", "application/x-x509-next-ca-cert"); List<X509Certificate> certs = getNextCaCertificate(req.getParameter(MSG_PARAM)); if (certs.size() == 0) { res.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "GetNextCACert Not Supported"); } else {//from w ww . ja v a 2 s .co m CMSSignedDataGenerator generator = new CMSSignedDataGenerator(); JcaCertStore store; try { store = new JcaCertStore(certs); } catch (CertificateEncodingException e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } generator.addCertificates(store); DigestCalculatorProvider digestProvider = new JcaDigestCalculatorProviderBuilder().build(); SignerInfoGeneratorBuilder infoGenBuilder = new SignerInfoGeneratorBuilder(digestProvider); X509CertificateHolder certHolder = new X509CertificateHolder(getRecipient().getEncoded()); ContentSigner contentSigner = new JcaContentSignerBuilder("SHA1withRSA").build(getRecipientKey()); SignerInfoGenerator infoGen = infoGenBuilder.build(contentSigner, certHolder); generator.addSignerInfoGenerator(infoGen); CMSSignedData degenerateSd = generator.generate(new CMSAbsentContent()); byte[] bytes = degenerateSd.getEncoded(); res.getOutputStream().write(bytes); res.getOutputStream().close(); } }
From source file:org.b3log.latke.remote.RepositoryAccessor.java
/** * Determines whether the specified request is authenticated. * //from ww w . j a va2 s .c om * <p> * If the specified request is unauthenticated, puts {@link Keys#STATUS_CODE sc} and {@link Keys#MSG msg} * into the specified json object to render. * </p> * * @param request the specified request * @param jsonObject the specified json object * @return {@code true} if authenticated, returns {@code false} otherwise */ private boolean authSucc(final HttpServletRequest request, final JSONObject jsonObject) { if (!Latkes.isRemoteEnabled()) { jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_NOT_IMPLEMENTED); jsonObject.put(Keys.MSG, "Latke remote interfaces are disabled"); return false; } final String userName = request.getParameter("userName"); final String password = request.getParameter("password"); if (Strings.isEmptyOrNull(userName)) { jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_BAD_REQUEST); jsonObject.put(Keys.MSG, "Requires parameter[userName]"); return false; } if (Strings.isEmptyOrNull(password)) { jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_BAD_REQUEST); jsonObject.put(Keys.MSG, "Requires parameter[password]"); return false; } final String repositoryAccessorUserName = Latkes.getRemoteProperty("repositoryAccessor.userName"); final String repositoryAccessorPassword = Latkes.getRemoteProperty("repositoryAccessor.password"); if (userName.equals(repositoryAccessorUserName) && password.equals(repositoryAccessorPassword)) { return true; } jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_FORBIDDEN); jsonObject.put(Keys.MSG, "Auth failed[userName=" + userName + ", password=" + password + "]"); return false; }
From source file:uk.ac.horizon.ug.mrcreator.http.CRUDServlet.java
protected Key validateCreate(Object o) throws RequestException { throw new RequestException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Create not support for " + getObjectClass()); }
From source file:uk.ac.horizon.ug.mrcreator.http.CRUDServlet.java
protected void validateUpdate(Object newobj, Object oldobj) throws RequestException { throw new RequestException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Update not support for " + getObjectClass()); }
From source file:uk.ac.horizon.ug.mrcreator.http.CRUDServlet.java
protected Key validateDelete(Object o) throws RequestException { throw new RequestException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Delete not support for " + getObjectClass()); }