Examples of ExtensionDescriptor


Examples of com.adito.extensions.ExtensionDescriptor

            resource,
            policy);
          launchSession.checkAccessRights(null, agent.getSession());

          ApplicationShortcut shortcut = (ApplicationShortcut) launchSession.getResource();
          ExtensionDescriptor descriptor = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());

          Request newRequest = launchApplication(launchSession);
          request.setRequestData(newRequest.getRequestData());

          CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this,
              ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED,
                  launchSession.getResource(),
                  launchSession.getPolicy(),
                  launchSession.getSession(),
                  CoreEvent.STATE_SUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME,
            descriptor.getName()).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, descriptor.getId()));

        }
        return true;
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

Examples of com.adito.extensions.ExtensionDescriptor

        if (launchSession == null) {
            throw new Exception("No launch session id " + launchSessionId);
        }
        final ApplicationShortcut shortcut = (ApplicationShortcut)launchSession.getResource();
        launchSession.checkAccessRights(null, getSessionInfo(request));
        ExtensionDescriptor app = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());
        if (app == null) {
            throw new Exception("No application named " + shortcut.getApplication() + ".");
        }

        if (!(app.getExtensionType() instanceof HtmlType)) {
            throw new Exception(getClass().getName() + " only supports applications of type " + HtmlType.class + ".");
        }

        // Get the primary VPN client ticket

        HtmlType type = (HtmlType) app.getExtensionType();
        File file = new File(app.getApplicationBundle().getBaseDir(), type.getTemplate());
        if (log.isDebugEnabled())
          log.debug("Loading template " + file.getAbsolutePath());

        InputStream in = null;
        StringBuffer template = new StringBuffer((int) file.length());
        try {
            in = new FileInputStream(file);
            String line = null;
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            while ((line = reader.readLine()) != null) {
                if (template.length() != 0) {
                    template.append("\n");
                }
                template.append(line);
            }
        } finally {
            Util.closeStream(in);
        }

        if (log.isDebugEnabled())
          log.debug("Parsing parameters.");
        for (Iterator i = shortcut.getParameters().entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();           
            String content = (String) entry.getValue();
           
            VariableReplacement r = new VariableReplacement();
            r.setApplicationShortcut(app, null);
            r.setServletRequest(request);
            r.setLaunchSession(launchSession);
           
            entry.setValue(r.replace(content));
        }

        if (log.isDebugEnabled())
          log.debug("Template loaded, doing standard replacements.");

        VariableReplacement r = new VariableReplacement();
        r.setApplicationShortcut(app, shortcut.getParameters());
        r.setServletRequest(request);
        r.setLaunchSession(launchSession);       
        String templateText = r.replace(template.toString());

        ReplacementEngine engine = new ReplacementEngine();

        String tunnels = request.getParameter("tunnels");
        if (tunnels != null && !tunnels.equals("")) {
            StringTokenizer t = new StringTokenizer(tunnels, ",");
            while (t.hasMoreTokens()) {
                String name = null;
                String hostname = null;
                int port = -1;
                try {
                    String tunnel = t.nextToken();
                    StringTokenizer t2 = new StringTokenizer(tunnel, ":");
                    name = t2.nextToken();
                    hostname = t2.nextToken();
                    port = Integer.parseInt(t2.nextToken());
                } catch (Exception e) {
                    throw new Exception("Failed to parse tunnels parameter '" + tunnels + "'.", e);
                }
                final ExtensionDescriptor.TunnelDescriptor tunnelDescriptor = app.getTunnel(name);
                if (tunnelDescriptor == null) {
                    throw new Exception("No tunnel named " + name);
                }
                final String fHostname = hostname;
                final int fPort = port;
                String pattern = "\\$\\{tunnel:" + name + "\\.[^\\}]*\\}";
                engine.addPattern(pattern, new Replacer() {
                    public String getReplacement(Pattern pattern, Matcher matcher, String sequence) {
                        String match = matcher.group();
                        if (match.equals("${tunnel:" + tunnelDescriptor.getName() + ".hostname}")) {
                            return fHostname;
                        } else if (match.equals("${tunnel:" + tunnelDescriptor.getName() + ".port}")) {
                            return String.valueOf(fPort);
                        } else {
                            return "";
                        }
                    }
                }, null);

            }
        }

        // Get the location of Adito as the client sees it
        String url = request.getParameter("adito");
        if (url != null) {
            String host = request.getHeader(HttpConstants.HDR_HOST);
            if (host != null) {
                url = (request.isSecure() ? "https" : "http") + "://" + host;
            } else {

                throw new Exception("No adito parameter supplied.");
            }
        }
        final URL aditoUrl = new URL(url);
        engine.addPattern("\\$\\{adito:[^\\}]*\\}", new Replacer() {
            public String getReplacement(Pattern pattern, Matcher matcher, String sequence) {
                String match = matcher.group();
                try {
                    String param = match.substring(14, match.length() - 1);
                    if (param.equals("host")) {
                        return aditoUrl.getHost();
                    } else if (param.equals("port")) {
                        return String.valueOf(aditoUrl.getPort() == -1 ? (aditoUrl.getProtocol().equals("https") ? 443
                                        : 80) : aditoUrl.getPort());
                    } else if (param.equals("protocol")) {
                        return aditoUrl.getProtocol();
                    } else {
                        throw new Exception("Unknow variable.");
                    }
                } catch (Throwable t) {
                    log.error("Failed to replace " + match + ".", t);
                }
                return "";
            }
        }, null);

        String processed = engine.replace(templateText);
        if (log.isDebugEnabled())
          log.debug("Returning " + processed);

        Util.noCache(response);

        response.setContentType("text/html");
        response.setContentLength(processed.length());
        request.setAttribute(Constants.REQ_ATTR_COMPRESS, Boolean.FALSE);

        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(out));
        pw.print(processed);
        pw.flush();

        Policy pol = PolicyDatabaseFactory.getInstance().getGrantingPolicyForUser(launchSession.getSession().getUser(), shortcut);
        CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this, ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED, shortcut, pol, launchSession.getSession(), CoreEvent.STATE_SUCCESSFUL)
        .addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME, app.getName())
        .addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, shortcut.getApplication()));
        //////////////////////////////////////////////
       
        return null;
    }
View Full Code Here

Examples of com.tinkerpop.rexster.extension.ExtensionDescriptor

                if (rexsterExtension != null) {
                    if (rexsterExtension.isConfigurationValid(extensionConfig)) {
                        final Method[] methods = clazz.getMethods();
                        for (Method method : methods) {
                            final ExtensionDescriptor descriptor = method.getAnnotation(ExtensionDescriptor.class);
                            final ExtensionDefinition definition = method.getAnnotation(ExtensionDefinition.class);

                            if (definition != null && definition.extensionPoint() == extensionPoint) {
                                String href = currentExtensionNamespace + "/" + currentExtensionName;
                                if (!definition.path().isEmpty()) {
                                    href = href + "/" + definition.path();
                                }

                                final HashMap<String, Object> hypermediaLink = new HashMap<String, Object>();
                                hypermediaLink.put("href", href);
                                hypermediaLink.put("op", definition.method().name());
                                hypermediaLink.put("namespace", currentExtensionNamespace);
                                hypermediaLink.put("name", currentExtensionName);

                                final String path = definition.path();
                                if (path != null && !path.isEmpty()) {
                                    hypermediaLink.put("path", path);
                                    hypermediaLink.put("title", currentNamespaceAndName + "-" + path);
                                } else {
                                    hypermediaLink.put("title", currentNamespaceAndName);
                                }

                                // descriptor is not a required annotation for extensions.
                                if (descriptor != null) {
                                    hypermediaLink.put("description", descriptor.description());
                                }

                                final JSONArray queryStringParameters = buildQueryStringParameters(method, descriptor);
                                if (queryStringParameters.length() > 0) {
                                    hypermediaLink.put("parameters", queryStringParameters);
View Full Code Here

Examples of com.tinkerpop.rexster.extension.ExtensionDescriptor

            final Method[] methods = rexsterExtensionClass.getMethods();

            for (Method method : methods) {
                // looks for the first method that matches.  methods that multi-match will be ignored right now
                final ExtensionDefinition extensionDefinition = method.getAnnotation(ExtensionDefinition.class);
                final ExtensionDescriptor extensionDescriptor = method.getAnnotation(ExtensionDescriptor.class);

                // checks if the extension point is graph, and if the method path matches the specified action on
                // the uri (if it exists) or if the method has no path.
                if (extensionDefinition != null && extensionDefinition.extensionPoint() == extensionPoint
                        && (extensionDefinition.method() == HttpMethod.ANY || extensionDefinition.method() == httpMethodRequested)) {

                    if ((!extensionAction.isEmpty() && extensionDefinition.path().equals(extensionAction))
                            || (extensionAction.isEmpty() && extensionDefinition.path().isEmpty())) {
                        methodToCall = new ExtensionMethod(method, extensionDefinition, extensionDescriptor, rexsterExtension);
                        break;
                    }
                }
            }

            if (methodToCall == null) {
                for (Method method : methods) {
                    final ExtensionDefinition extensionDefinition = method.getAnnotation(ExtensionDefinition.class);
                    final ExtensionDescriptor extensionDescriptor = method.getAnnotation(ExtensionDescriptor.class);

                    if (extensionDefinition != null && extensionDefinition.extensionPoint() == extensionPoint
                            && (extensionDefinition.method() == HttpMethod.ANY || extensionDefinition.method() == httpMethodRequested)) {

                        if (!extensionAction.isEmpty() && extensionDefinition.path().isEmpty()) {
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

        }

        writer.write( "\n  <extensions>" );
        for( int i = 0; i < extensions.length; i++ )
        {
            final ExtensionDescriptor extension = extensions[ i ];

            writer.write( "\n    <extension " );
            writer.write( "id=\"" );
            writer.write( extension.getKey() );

            final int count = extension.getAttributeNames().length;
            if( 0 == count )
            {
                writer.write( "\"/>" );
            }
            else
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

        }

        writer.write( "\n  <extensions>" );
        for( int i = 0; i < extensions.length; i++ )
        {
            final ExtensionDescriptor extension = extensions[ i ];

            writer.write( "\n    <extension " );
            writer.write( "id=\"" );
            writer.write( extension.getKey() );

            final int count = extension.getAttributeNames().length;
            if( 0 == count )
            {
                writer.write( "\"/>" );
            }
            else
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

    {
        String value = getNamedParameter( tag, TYPE_PARAM, null );
        if( value != null )
        {
            final String type = resolveType( value );
            return new ExtensionDescriptor( type );
        }
        else
        {
            value = getNamedParameter( tag, LEGACY_KEY_PARAM, null );
            if( value == null )
            {
                value = getNamedParameter( tag, LEGACY_URN_PARAM, null );
            }
            if( value == null )
            {
                value = getNamedParameter( tag, ID_PARAM );
            }
            return new ExtensionDescriptor( value );
        }
    }
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

        if( config.getAttribute( "type", null ) != null ) // legacy
        {
            String urn = config.getAttribute( "type", null );
            final Properties attributes =
              buildAttributes( config.getChild( "attributes" ) );
            return new ExtensionDescriptor( urn, attributes );
        }
        else
        {
            String id = config.getAttribute( "urn", null ); // legacy
            if( id == null )
            {
               try
               {
                   id = config.getAttribute( "id" );
               }
               catch( ConfigurationException e )
               {
                   final String error =
                     "Missing extensions identifier 'id' attribute."
                     + ConfigurationUtil.list( config );
                   throw new BuildException( error, e );
               }
            }
            final Properties attributes =
              buildAttributes( config.getChild( "attributes" ) );
            return new ExtensionDescriptor( id, attributes );
        }
    }
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

        }

        writer.write( "\n  <extensions>" );
        for( int i = 0; i < extensions.length; i++ )
        {
            final ExtensionDescriptor extension = extensions[ i ];

            writer.write( "\n    <extension " );
            writer.write( "id=\"" );
            writer.write( extension.getKey() );

            final int count = extension.getAttributeNames().length;
            if( 0 == count )
            {
                writer.write( "\"/>" );
            }
            else
View Full Code Here

Examples of org.apache.avalon.meta.info.ExtensionDescriptor

    {
        String value = getNamedParameter( tag, TYPE_PARAM, null );
        if( value != null )
        {
            final String type = resolveType( value );
            return new ExtensionDescriptor( type );
        }
        else
        {
            value = getNamedParameter( tag, LEGACY_KEY_PARAM, null );
            if( value == null )
            {
                value = getNamedParameter( tag, LEGACY_URN_PARAM, null );
            }
            if( value == null )
            {
                value = getNamedParameter( tag, ID_PARAM );
            }
            return new ExtensionDescriptor( value );
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.