Package com.ibm.commons.runtime

Examples of com.ibm.commons.runtime.Context


  }
 
  public CredentialEncryptor findEncryptor() throws CredentialStoreException {
    String name = getEncryptor();
    if(StringUtil.isNotEmpty(name)) {
        Context context = Context.get();
          // Look for a bean and/or class
          Object o = context.getBean(name);
          if(o==null) {
              throw new CredentialStoreException(null,"Encryptor bean {0} is not available. Please verify your configuration files.",name);
          }
          if(!(o instanceof CredentialStore)) {
              throw new CredentialStoreException(null,"Invalid Encryptor bean implementation {0}, class {1}",name,o.getClass());
View Full Code Here


    public static CredentialStore getCredentialStore() throws CredentialStoreException {
        return getCredentialStore(null);
    }
   
    public static CredentialStore getCredentialStore(String name) throws CredentialStoreException {
      Context context = Context.get();
     
        // Look for a global property if the name is empty
        if(StringUtil.isEmpty(name)) {
            name = context.getProperty("sbt.credentialstore", null);
        }
        if(StringUtil.isEmpty(name)) {
          return null;
        }
     
      // If the user is anonynmous, then the store should happen in memory
      // This is a shared object for all the users
        // Do we actually need this? If the beans are set to the session scope, then this
        // is redundant.
      if(context.isCurrentUserAnonymous()) {
        return AnonymousSessionCredentialStore.get();
      }
       
        // Look for a bean and/or class
        Object o = context.getBean(name);
        if(o==null) {
            throw new CredentialStoreException(null,"Credential store {0} is not available. Please verify your configuration files.",name);
        }
        if(!(o instanceof CredentialStore)) {
            throw new CredentialStoreException(null,"Invalid credential store implementation {0}, class {1}",name,o.getClass());
View Full Code Here

        // No Proxy is defined by endpoint
        // return default SBT Proxy
        return new SBTProxy();
      }
     
      Context context = Context.get();
     
       // Look for a bean and/or class
        Object o = context.getBean(name);
        if(o==null) {
            throw new ProxyConfigException(null,"Proxy Configuration {0} is not available. Please verify your configuration files.",name);
        }
        if(!(o instanceof Proxy)) {
            throw new ProxyConfigException(null,"Invalid Proxy Configuration implementation {0}, class {1}",name,o.getClass());
View Full Code Here

    jsonProperties.putJsonProperty(PROP_LIBRARY_URL, addMakeAbsoluteUrl(request.getLibraryUrl()));

    // add the requested properties
    Property[] properties = request.getEnvironment().getPropertiesArray();
    if (properties != null) {
        Context context = Context.get();
      for (Property property : properties) {
        String value = property.getValue();
        if (StringUtil.isEmpty(value)) {
          value = context.getProperty(property.getName());
        }
        if (value != null) {
          jsonProperties.putJsonProperty(property.getName(), value);
        }
      }
View Full Code Here

     * @return
     */
    public static String process(String input) {
        if(StringUtil.isNotEmpty(input)) {
            // default behaviour is to use context or if not available use application properties
            final Context context = Context.getUnchecked();
            final Application application = Application.getUnchecked();
            ParameterProvider provider = new ParameterProvider() {
                @Override
                public String getParameter(String name) {
                    if (context != null) {
                        return context.getProperty(name);
                    }
                    return (application == null) ? null : application.getProperty(name);
                }
            };
           
View Full Code Here

     * @return
     */
    public static ParameterProvider getDefaultProvider(){
        if(defaultProvider != null)
            return defaultProvider;
        final Context context = Context.getUnchecked();
        final Application application = Application.getUnchecked();
        defaultProvider = new ParameterProvider() {
            @Override
            public String getParameter(String name) {
                if (context != null) {
                    return context.getProperty(name);
                }
                return (application == null) ? null : application.getProperty(name);
            }
        };
        return defaultProvider;
View Full Code Here

        if (!includeDefault) {
            return process(input, provider);
        }
        if(StringUtil.isNotEmpty(input)) {
            // default behaviour is to use context or if not available use application properties
            final Context context = Context.getUnchecked();
            final Application application = Application.getUnchecked();
            ParameterProvider defaultProvider = new ParameterProvider() {
                @Override
                public String getParameter(String name) {
                    if (provider != null) {
                        String value = provider.getParameter(name);
                        if (value != null) {
                            return value;
                        }
                    }
                    if (context != null) {
                        return context.getProperty(name);
                    }
                    return (application == null) ? null : application.getProperty(name);
                }
            };
           
View Full Code Here

    @Override
  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,"LTPA token refresh failed because: "+e.getMessage());
                }
              } else {
View Full Code Here

    return Context.get().getProperty(
        getPropertyBasePath() + name);
  }

    public static String getProperty(String p) {
        Context ctx = RuntimeFactory.get().getContextUnchecked();
        return System.getProperty(p, ctx != null? Context.get().getProperty(p) : null);
    }
View Full Code Here

  public AnonymousSessionCredentialStore() {
  }
 
  @Override
  public Object load(String service, String type, String user) throws CredentialStoreException {
    Context context = Context.get();
    String key = createKey(service, type, user);
    return deSerialize((byte[])context.getSessionMap().get(key));
  }
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.