Package com.ibm.commons.runtime

Examples of com.ibm.commons.runtime.Context


    return deSerialize((byte[])context.getSessionMap().get(key));
  }
 
  @Override
  public void store(String service, String type, String user, Object credentials) throws CredentialStoreException {
    Context context = Context.get();
    String key = createKey(service, type, user);
    context.getSessionMap().put(key, serialize(credentials));
  }
View Full Code Here


    context.getSessionMap().put(key, serialize(credentials));
  }

  @Override
  public void remove(String service, String type, String user) throws CredentialStoreException {
    Context context = Context.get();
    String key = createKey(service, type, user);
    context.getSessionMap().remove(key);
  }
View Full Code Here

      }
    return endPointName;
  }
 
  protected void redirectToJavaApp(HttpServletRequest req, HttpServletResponse resp, String authentication) throws ServletException, IOException {
    Context context = Context.get();
    String url = (String)req.getParameter(REDIRECT_URL);
    if(authentication.equals(AUTH_DECLINED)){
      if(url != null){
        if(url.indexOf("showWrongCredsMessage=true") == -1){// don't add again if wrongCreds parameter is already added for declined Authentication
          if(url.indexOf('?')!= -1)
            url = PathUtil.concat(url,"showWrongCredsMessage=true", '&');
          else
            url = PathUtil.concat(url,"showWrongCredsMessage=true", '?');
       
      }
    }
    context.sendRedirect(url);
  }
View Full Code Here

   * @throws IOException
   */
  private String generateJavaScript(RenderContext renderContext) throws IOException {
    System.out.println("LibraryResource.generateJavaScript: " + renderContext.request.getRequestURL());
    String output = "";
    Context context = null;
   
    Thread current = Thread.currentThread();
    ClassLoader loader = current.getContextClassLoader();
      try {
        current.setContextClassLoader(getClass().getClassLoader());
View Full Code Here

  @Override
  public void service(ServletRequest request, ServletResponse response)
      throws ServletException, IOException {
    // create the context instance
    if(useContext()) {
        Context context = Context.init(application,request, response);
        try {
          super.service(request,response);
        } finally {
          Context.destroy(context);
        }
View Full Code Here

      return null;
    }

    @Override
  public String getUrl() {
      Context ctx = Context.get();
      // Adapt this for portal?
      HttpServletRequest req = ctx.getHttpRequest();
      return UrlUtil.getRequestUrl(req, UrlUtil.URL_CONTEXTPATH);
    }
View Full Code Here

      return UrlUtil.getRequestUrl(req, UrlUtil.URL_CONTEXTPATH);
    }

    @Override
  public String getUserIdentity() throws ClientServicesException {
      Context ctx = Context.getUnchecked();
      if(ctx!=null) {
        return ctx.getCurrentUserId();
      }
      return null;
    }
View Full Code Here

      return false;
    }
   
    @Override
  public boolean isAuthenticated() throws ClientServicesException {
      Context ctx = Context.getUnchecked();
      if(ctx!=null) {
        return !ctx.isCurrentUserAnonymous();
      }
      return false;
    }
View Full Code Here

     * This method is exactly same as authenticate method from Basic endpoint, we need a login page here as well.
     */
  public void authenticate(boolean force) throws ClientServicesException {
        if(force || !isAuthenticated()) {
            String authPage = getAuthenticationPage();
           Context context = Context.get();
            if(StringUtil.isNotEmpty(authPage)) {
              try{
                if(!UrlUtil.isAbsoluteUrl(authPage)){
                  authPage = UrlUtil.makeUrlAbsolute((HttpServletRequest)context.getHttpRequest(), authPage);
                  }

                String redirectUrl = UrlUtil.getRequestUrl((HttpServletRequest)context.getHttpRequest());// change needed to handle portlethttprequest
               
                   String endPointName = authPage.substring(authPage.indexOf("=")+1, authPage.length());
                  String baseUrl = UrlUtil.getBaseUrl(((HttpServletRequest)context.getHttpRequest()));
                  String servletPath = ServiceServlet.getServletPath();
                  String basicProxyUrl = AuthCredsHandler.URL_PATH;
                   
                  //constructing proxy action url
                  String postToProxy = PathUtil.concat(baseUrl, servletPath, '/');
                  postToProxy = PathUtil.concat(postToProxy,basicProxyUrl, '/');
                  postToProxy = PathUtil.concat(postToProxy,endPointName, '/');
                  postToProxy = PathUtil.concat(postToProxy,"JavaApp", '/');
                 
                  // encode URL's
                 postToProxy = URLEncoder.encode(postToProxy,"UTF-8");
               redirectUrl = URLEncoder.encode(redirectUrl,"UTF-8");
                 
                  // passing proxy action url as a parameter to the authentication page
                  authPage = PathUtil.concat(authPage,"proxyPath",'&');
                  authPage = PathUtil.concat(authPage,postToProxy,'=');
                  // passing redirectURL as a parameter to the authentication page
                  authPage = PathUtil.concat(authPage,"redirectURL",'&');
                  authPage = PathUtil.concat(authPage,redirectUrl,'=');
                  context.sendRedirect(authPage);
                      
                   
              } catch (IOException e) {
                throw new ClientServicesException(e,"Authentication page not found. Could not redirect to login page");
              }
View Full Code Here

 
  @Override
  public String getHttpProxy() {
    String proxyinfo = super.getHttpProxy();
    if (StringUtil.isEmpty(proxyinfo)) {
      Context context = Context.getUnchecked();
      if (context != null) {
        proxyinfo = Context.get().getProperty("sbt.httpProxy");
      }
    }
    return proxyinfo;
View Full Code Here

TOP

Related Classes of com.ibm.commons.runtime.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.