List of usage examples for javax.servlet.http HttpServletRequest getScheme
public String getScheme();
From source file:be.fedict.eid.dss.sp.bean.SPBean.java
private byte[] setRequest(HttpServletRequest httpServletRequest, String language, String target) { byte[] document = (byte[]) httpServletRequest.getSession() .getAttribute(UploadServlet.DOCUMENT_SESSION_ATTRIBUTE); this.language = language; this.contentType = (String) httpServletRequest.getSession().getAttribute("ContentType"); this.relayState = UUID.randomUUID().toString(); LOG.debug("RelayState: " + this.relayState); this.destination = "../eid-dss/protocol/simple"; this.target = httpServletRequest.getScheme() + "://" + httpServletRequest.getServerName() + ":" + httpServletRequest.getServerPort() + httpServletRequest.getContextPath() + "/" + target + "?requestId=" + new Random().nextInt(1000); // store data on session for response handling httpServletRequest.getSession().setAttribute("target", this.target); httpServletRequest.getSession().setAttribute("RelayState", this.relayState); return document; }
From source file:it.cnr.icar.eric.server.interfaces.soap.RegistrySAMLServlet.java
/** * This method is a copy of the respective method from RegistrySOAPServlet. * It informs the user about GET requests and the corresponding URL for Web * Access.//from w w w.ja v a2 s.c om */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); String scheme = request.getScheme(); String serverName = request.getServerName(); String ericName = RegistryProperties.getInstance().getProperty("eric.name", "eric"); int serverPort = request.getServerPort(); StringBuffer sb = new StringBuffer(); sb.append(scheme).append("://").append(serverName).append(':'); sb.append(serverPort); sb.append('/'); sb.append(ericName); sb.append("/registry/thin/browser.jsp"); String url = sb.toString(); PrintWriter wt = response.getWriter(); wt.println(ServerResourceBundle.getInstance().getString("message.urlForSOAP")); wt.println(ServerResourceBundle.getInstance().getString("message.urlForWebAccess", new Object[] { url })); wt.flush(); wt.close(); }
From source file:jp.or.openid.eiwg.scim.servlet.ResourceTypes.java
/** * GET?//from w w w . j av a 2 s .co m * * @param request * @param response ? * @throws ServletException * @throws IOException */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ? ServletContext context = getServletContext(); // ?? Operation op = new Operation(); boolean result = op.Authentication(context, request); if (!result) { // errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage()); } else { // location?URL? String location = request.getScheme() + "://" + request.getServerName(); int serverPort = request.getServerPort(); if (serverPort != 80 && serverPort != 443) { location += ":" + Integer.toString(serverPort); } location += request.getContextPath(); // ? @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> resourceTypes = (ArrayList<LinkedHashMap<String, Object>>) context .getAttribute("ResourceTypes"); // location? Iterator<LinkedHashMap<String, Object>> resourceTypesIt = resourceTypes.iterator(); while (resourceTypesIt.hasNext()) { LinkedHashMap<String, Object> resourceTypeInfo = resourceTypesIt.next(); // meta? Object metaObject = SCIMUtil.getAttribute(resourceTypeInfo, "meta"); if (metaObject != null && metaObject instanceof LinkedHashMap) { @SuppressWarnings("unchecked") LinkedHashMap<String, Object> metaInfo = (LinkedHashMap<String, Object>) metaObject; Object locationInfo = SCIMUtil.getAttribute(metaInfo, "location"); if (locationInfo != null && locationInfo instanceof String) { String locationValue = String.format(locationInfo.toString(), location); metaInfo.put("location", locationValue); resourceTypeInfo.put("meta", metaInfo); } } } try { // javaJSON?? ObjectMapper mapper = new ObjectMapper(); StringWriter writer = new StringWriter(); mapper.writeValue(writer, resourceTypes); // ?? String listResponse = "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:ListResponse\"],"; listResponse += "\"totalResults\":" + resourceTypes.size(); if (resourceTypes.size() > 0) { listResponse += ",\"Resources\":"; listResponse += writer.toString(); } listResponse += "}"; response.setContentType("application/scim+json;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(listResponse); } catch (IOException e) { e.printStackTrace(); } } }
From source file:jp.or.openid.eiwg.scim.servlet.Schemas.java
/** * GET?//from www . j a va2s. co m * * @param request * @param response ? * @throws ServletException * @throws IOException */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ? ServletContext context = getServletContext(); // ?? Operation op = new Operation(); boolean result = op.Authentication(context, request); if (!result) { // errorResponse(response, op.getErrorCode(), op.getErrorType(), op.getErrorMessage()); } else { // location?URL? String location = request.getScheme() + "://" + request.getServerName(); int serverPort = request.getServerPort(); if (serverPort != 80 && serverPort != 443) { location += ":" + Integer.toString(serverPort); } location += request.getContextPath(); // ? @SuppressWarnings("unchecked") ArrayList<LinkedHashMap<String, Object>> schemas = (ArrayList<LinkedHashMap<String, Object>>) context .getAttribute("Schemas"); // location? Iterator<LinkedHashMap<String, Object>> schemasIt = schemas.iterator(); while (schemasIt.hasNext()) { LinkedHashMap<String, Object> schemaInfo = schemasIt.next(); // meta? Object metaObject = SCIMUtil.getAttribute(schemaInfo, "meta"); if (metaObject != null && metaObject instanceof LinkedHashMap) { @SuppressWarnings("unchecked") LinkedHashMap<String, Object> metaInfo = (LinkedHashMap<String, Object>) metaObject; Object locationInfo = SCIMUtil.getAttribute(metaInfo, "location"); if (locationInfo != null && locationInfo instanceof String) { String locationValue = String.format(locationInfo.toString(), location); metaInfo.put("location", locationValue); schemaInfo.put("meta", metaInfo); } } } try { // javaJSON?? ObjectMapper mapper = new ObjectMapper(); StringWriter writer = new StringWriter(); mapper.writeValue(writer, schemas); // ?? String listResponse = "{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:ListResponse\"],"; listResponse += "\"totalResults\":" + schemas.size(); if (schemas.size() > 0) { listResponse += ",\"Resources\":"; listResponse += writer.toString(); } listResponse += "}"; response.setContentType("application/scim+json;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(listResponse); } catch (IOException e) { e.printStackTrace(); } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSMWar.CFAsteriskSMWarLoginHtml.java
protected void sendConfirmationEMail(ICFSecuritySecDeviceObj defDev, HttpServletRequest request, ICFSecuritySecUserObj confirmUser, ICFSecurityClusterObj cluster) throws IOException, MessagingException, NamingException { String clusterDescription = cluster.getRequiredDescription(); String thisURI = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI().toString(); int lastSlash = thisURI.lastIndexOf('/'); String baseURI = thisURI.substring(0, lastSlash); UUID confirmationUUID = confirmUser.getOptionalEMailConfirmationUuid(); String msgBody = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n" + "<HTML>\n" + "<BODY>\n" + "<p>\n" + "You requested a new account for " + confirmUser.getRequiredEMailAddress() + " with " + clusterDescription + ".\n" + "<p>" + "Please click on the following link to confirm your email address:<br>\n" + "<A HRef=\"" + baseURI + "/CFAsteriskSMWarConfirmEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "\">" + baseURI + "/CFAsteriskSMWarConfirmEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "</A>\n" + "<p>" + "Or click on the following link to cancel the request for a new account:<br>\n" + "<A HRef=\"" + baseURI + "/CFAsteriskSMWarCancelEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "\">" + baseURI + "/CFAsteriskSMWarCancelEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "</A>\n" + "</BODY>\n" + "</HTML>\n"; CFAsteriskSMWarUtil warUtil = new CFAsteriskSMWarUtil(); warUtil.sendEMailToUser(confirmUser, "You requested an account with " + clusterDescription + "?", msgBody); }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstSMWar.CFAstSMWarLoginHtml.java
protected void sendPasswordResetEMail(HttpServletRequest request, ICFAstSecUserObj resetUser, ICFAstClusterObj cluster) throws IOException, MessagingException, NamingException { String clusterDescription = cluster.getRequiredDescription(); String thisURI = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI().toString(); int lastSlash = thisURI.lastIndexOf('/'); String baseURI = thisURI.substring(0, lastSlash); UUID resetUUID = resetUser.getOptionalPasswordResetUuid(); String msgBody = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n" + "<HTML>\n" + "<BODY>\n" + "<p>\n" + "You requested a password reset for " + resetUser.getRequiredEMailAddress() + " used for accessing " + clusterDescription + ".\n" + "<p>" + "Please click on the following link to reset your password:<br>\n" + "<A HRef=\"" + baseURI + "/CFAstSMWarResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "\">" + baseURI + "/CFAstSMWarResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "</A>\n" + "<p>" + "Or click on the following link to cancel the reset request:<br>\n" + "<A HRef=\"" + baseURI + "/CFAstSMWarCancelResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "\">" + baseURI + "/CFAstSMWarCancelResetPasswordHtml?ResetUUID=" + resetUUID.toString() + "</A>\n" + "</BODY>\n" + "</HTML>\n"; CFAstSMWarUtil warUtil = new CFAstSMWarUtil(); warUtil.sendEMailToUser(resetUser,/*ww w .ja v a2 s .c o m*/ "You requested a password reset for your account with " + clusterDescription + "?", msgBody); }
From source file:com.sun.identity.saml2.plugins.SAML2IDPProxyFRImpl.java
private String getRedirect(HttpServletRequest request, String idpFinderImplementation) { String methodName = "getRedirect"; // Get the base URL and construct the IdP Finder URL String baseURL = request.getScheme() + "://" + request.getHeader("host") + request.getContextPath(); String idpFinder = baseURL + "/" + idpFinderImplementation; debugMessage(methodName, ": Redirect url = " + idpFinder); return idpFinder; }
From source file:com.provenance.cloudprovenance.traceabilitystore.ws.controler.TraceabilityStoreController.java
@Override @GET/*from ww w . j a va 2 s . c o m*/ @Path(value = "/{serviceId}/{traceabilityType}") public Response getTraceabilityDocumentId(@PathParam("serviceId") String serviceId, @PathParam("traceabilityType") String traceabilityType, @Context HttpServletRequest request) { if (currentTraceabilityRecordId == null) { logger.warn("Current file record Id does not exist, need to create a new record !!!"); ResponseBuilder rBuilder = Response.status(404); rBuilder.entity("<TraceabilityDocument></TraceabilityDocument>"); return rBuilder.build(); } else { String responseUri = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI() + "/" + currentTraceabilityRecordId; logger.info("Response URI: " + responseUri); logger.info("Returning the current record Id"); ResponseBuilder rBuilder = Response.status(200); String responseContent = trResponse.genTraceabilityRecordIdResponse(currentTraceabilityRecordId, serviceId, defaultFileExtensionOfrecord, responseUri); logger.info("Sending GET resource URI response: " + responseContent); rBuilder.entity(responseContent); return rBuilder.build(); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstSMWar.CFAstSMWarLoginHtml.java
protected void sendConfirmationEMail(ICFAstSecDeviceObj defDev, HttpServletRequest request, ICFAstSecUserObj confirmUser, ICFAstClusterObj cluster) throws IOException, MessagingException, NamingException { String clusterDescription = cluster.getRequiredDescription(); String thisURI = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getRequestURI().toString(); int lastSlash = thisURI.lastIndexOf('/'); String baseURI = thisURI.substring(0, lastSlash); UUID confirmationUUID = confirmUser.getOptionalEMailConfirmationUuid(); String msgBody = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n" + "<HTML>\n" + "<BODY>\n" + "<p>\n" + "You requested a new account for " + confirmUser.getRequiredEMailAddress() + " with " + clusterDescription + ".\n" + "<p>" + "Please click on the following link to confirm your email address:<br>\n" + "<A HRef=\"" + baseURI + "/CFAstSMWarConfirmEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "\">" + baseURI + "/CFAstSMWarConfirmEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "</A>\n" + "<p>" + "Or click on the following link to cancel the request for a new account:<br>\n" + "<A HRef=\"" + baseURI + "/CFAstSMWarCancelEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "\">" + baseURI + "/CFAstSMWarCancelEMailAddressHtml?ConfirmationUUID=" + confirmationUUID.toString() + "</A>\n" + "</BODY>\n" + "</HTML>\n"; CFAstSMWarUtil warUtil = new CFAstSMWarUtil(); warUtil.sendEMailToUser(confirmUser, "You requested an account with " + clusterDescription + "?", msgBody); }
From source file:org.gluu.oxauth.client.session.SignOutHandler.java
protected final String constructRedirectUrl(final HttpServletRequest request) { log.trace("Starting constructRedirectUrl"); String redirectUri = null;/*from w ww .ja v a2 s. c o m*/ String[] redirectUriParameters = (String[]) request.getParameterMap() .get(Configuration.OAUTH_POST_LOGOUT_REDIRECT_URI); if (redirectUriParameters != null && redirectUriParameters.length > 0) { redirectUri = redirectUriParameters[0]; } log.trace("redirectUri from request = " + redirectUri); if (redirectUri == null || redirectUri.equals("")) { int serverPort = request.getServerPort(); if ((serverPort == 80) || (serverPort == 443)) { redirectUri = String.format("%s://%s%s", request.getScheme(), request.getServerName(), "/identity/authentication/finishlogout"); } else { redirectUri = String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), request.getServerPort(), "/identity"); } } log.trace("Final redirectUri = " + redirectUri); return redirectUri; }