Tech Tips Quiz

Over the years, the Enterprise Java Technologies Tech Tips have covered a wide variety of enterprise Java technology topics. Here's a short quiz that tests your knowledge of some topics covered in recent Tech Tips. You can find the answers at the end of the quiz.

  1. You are developing an application that uses the Jersey 1.0.2 Client API to consume a RESTful web service. You create a Client object for the RESTful web service client. What do you need to create next so that the Client object can be used to issue web service requests?

    a. A ClientPipe object.
    b. A WebResource object.
    c. A ServiceRequest object.
    d. A ClientFactory object.
    e. None of the above.

  2. The following code snippet appears in a program that uses JAXB 2.0 to marshal an XML document:
       import javax.xml.bind.\*;
       import a.JustAType;
       import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
    
          NamespacePrefixMapper m = new PreferredMapper();
                         marshal(jc, e, m);
    
             public static class PreferredMapper extends NamespacePrefixMapper {
                    @Override
                    public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
                      return "mappedNamespace" + namespaceUri;
                    }
              }
    
    

    What does the getPreferredPrefix() method in the PreferredMapper class do?

    a. Returns the preferred prefix, mappedNamespace to be declared at the root element of the marshalled XML.
    b. Returns the preferred namespace prefix, jc, and namespace URI, mappedNamespacee, to be declared at the root element of the marshalled XML.
    c. Returns the preferred prefix, mappedNamespacea, to be declared at the root element of the marshalled XML.
    d. Returns a list of preferred namespace prefixes, jc, e, and m, to be declared in elements of the marshalled XML.
    e. None of the above.

  3. The javafx.servlet.sip.SipFactory interface provides utility methods to create a Session Initiation Protocol (SIP) request in an enterprise application. Which of the following statements about the SipFactory interface is true?

    a. A SipFactory instance can be injected into a Java EE component such as an EJB or MJB using the @SIP annotation.
    b. A SipFactory instance cannot be used in a Converged Enterprise Application.
    c. SipFactory instances that belong to multiple SIP applications can be injected into a Java EE component, whether the applications are co-located in the same .ear file or not.
    d. A SipFactory is specific to a SIP application and there can be only one SipFactory instance for each SIP application.

  4. Metro supports the WS-Trust specification. Which of the following is not true about the WS-Trust support in Metro:

    a. Supports token refactoring.
    b. Supports token issuance and token validation protocols.
    c. Supports the Security Token Service (STS) framework
    d. Supports issuing SAML 1.0, SAML 1.1 and SAML 2.0 tokens, by default.
    e. Supports the issuing of symmetric proof keys, public proof keys, and no proof keys.

  5. Fill in the blank: When SOAP attachments are used in a SOAP message, the SOAP message is accompanied by a MIME header and possibly ________ _________.

    a. Cipher references
    b. STS tokens
    c. Boundary parts
    d. User profiles
    e. Signature values

Answers

  1. You are developing an application that uses the Jersey 1.0.2 Client API to consume a RESTful web service. You create a Client object for the RESTful web service client. What do you need to create next so that the Client object can be used to issue web service requests?

    a. A ClientPipe object.
    b. A WebResource object.
    c. A ServiceRequest object.
    d. A ClientFactory object.
    e. None of the above.

  2. b. A WebResource object. After you create a Client instance, you can start using it. However, to issue requests, you need to create a WebResource object, which encapsulates a web resource for the client. You use the WebResource object to build requests to send to the web resource and to process responses returned from the web resource. For example, you can use the WebResource object for HTTP GET, PUT, POST, and DELETE requests. For more information about using the Jersey 1.0.2 Client API, see the February 26, 2009 Tech Tip, Consuming RESTful Web Services With the Jersey Client API.

  3. The following code snippet appears in a program that uses JAXB 2.0 to marshal an XML document:
       import javax.xml.bind.\*;
       import a.JustAType;
       import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
    
          NamespacePrefixMapper m = new PreferredMapper();
                         marshal(jc, e, m);
    
             public static class PreferredMapper extends NamespacePrefixMapper {
                    @Override
                    public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
                      return "mappedNamespace" + namespaceUri;
                    }
              }
    
    

    What does the getPreferredPrefix() method in the PreferredMapper class do?

    a. Returns the preferred prefix, mappedNamespace to be declared at the root element of the marshalled XML.
    b. Returns the preferred namespace prefix, jc, and namespace URI, mappedNamespacee, to be declared at the root element of the marshalled XML.
    c. Returns the preferred prefix, mappedNamespacea, to be declared at the root element of the marshalled XML.
    d. Returns a list of preferred namespace prefixes, jc, e, and m, to be declared in elements of the marshalled XML.
    e. None of the above.

    c. Returns the preferred prefix, mappedNamespacea, to be declared at the root element of the marshalled XML. JAXB 2.0 (or later) provides a service provider interface (SPI) named com.sun.xml.bind.marshaller.NamespacePrefixMapper that you can use to specify helpful namespace prefixes for marshalling. You implement the SPI and pass it to the Marshaller. One of the methods in the NamespacePrefixMapper class is getPreferredPrefix(), which returns a list of namespace URIs that should be declared at the root element. In the code snippet, the getPreferredPrefix() method in the PreferredMapper class returns the preferred prefix, in this case, mappedNamespacea to be declared at the root element of the marshalled XML, as follows:

       <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
       <mappedNamespacea:JustAnElement xmlns:mappedNamespacea="a">
           <foo>true</foo>
       </mappedNamespacea:JustAnElement>
    
    
    To learn more about customizing namespace prefixes during marshalling, see the December 2, 2008 Tech Tip Customizing JAXB.

  4. The javafx.servlet.sip.SipFactory interface provides utility methods to create a Session Initiation Protocol (SIP) request in an enterprise application. Which of the following statements about the SipFactory interface is true?

    a. A SipFactory instance can be injected into a Java EE component such as an EJB or MJB using the @SIP annotation.
    b. A SipFactory instance cannot be used in a Converged Enterprise Application.
    c. SipFactory instances that belong to multiple SIP applications can be injected into a Java EE component, whether the applications are co-located in the same .ear file or not.
    d. A SipFactory is specific to a SIP application and there can be only one SipFactory instance for each SIP application.

  5. d. A SipFactory is specific to a SIP application and there can be only one SipFactory instance for each SIP application. The SipFactory instance is available in the servlet context of a SIP Application as an attribute of javax.servlet.sip.SipFactory. The servlet specification defines specific context attributes that are used to store and retrieve information specific to SIP servlets and interfaces from the context. In the case of Java EE components such as EJBs and MDBs, which are outside the scope of the servlet context, the SipFactory is available as a resource. You can inject the resource into a Java EE component such as an EJB or MJB using the @Resource annotation. For more information about the SipFactory interface, SIP requests, and their use in converged enterprise applications, see the March 13, 2009 Tech Tip, Converged Enterprise Applications.

  6. Metro supports the WS-Trust specification. Which of the following is not true about the WS-Trust support in Metro:

    a. Supports token refactoring.
    b. Supports token issuance and token validation protocols.
    c. Supports the Security Token Service (STS) framework
    d. Supports issuing SAML 1.0, SAML 1.1 and SAML 2.0 tokens, by default.
    e. Supports the issuing of symmetric proof keys, public proof keys, and no proof keys.

    a. Supports token refactoring. Metro is a high performance, extensible, easy-to-use web services stack. It combines the JAX-WS reference implementation with Project Tango. Project Tango, also called Web Services Interoperability Technology or WSIT, implements numerous WS-\* standards to enable interoperability with other implementations and to provide Quality of Service (QOS) features such as security, reliability, and transaction support. WS-Trust is a WS-\* specification that provides extensions to the WS-Security specification. Metro supports the WS-Trust specification. In supporting WS-Trust, Metro:

    • Supports token issuance and token validation protocols.
    • Supports the STS framework.
    • Supports building an STS as an independent web service.
    • Supports client and service authentication and security with issued tokens from an STS within the general framework of WS-Security and WS-SecurityPolicy.
    • Provides a general framework for building an STS as a web service for issuing security tokens.
    • Supports authentication and secure communication between a client and an STS in the same way as for a regular web service.
    • Supports issuing SAML 1.0, SAML 1.1 and SAML2.0 tokens, by default.
    • Supports the issuing of symmetric proof keys, public proof keys, and no proof keys.
    • Can be extended to support the issuing of other types of tokens.
    • Allows for plugging in additional authorization mechanisms that control the issuing of tokens according to the user's identity and the targeted service.
    • Allows for plugging in user mappings that control the user identity/attributes carried in the SAML token issued by n STS for different services.

    However, it does not support token refactoring. For more information about WS-Trust support in Metro, see the October 14, 2008 Tech Tip Using WS-Trust Support in Metro to Secure Web Services.

  7. Fill in the blank: When SOAP attachments are used in a SOAP message, the SOAP message is accompanied by a MIME header and possibly ________ _________.

    a. Cipher references
    b. STS tokens
    c. Boundary parts
    d. User profiles
    e. Signature values

    c. Boundary parts. When SOAP attachments are used in a SOAP message, the SOAP message is accompanied by a MIME header and possibly multiple boundary parts. This is known as a SOAP message package. The primary SOAP envelope is generally conveyed in the first MIME part. The attachments are carried in other MIME parts and are referenced from the SOAP envelope. Learn more about SOAP message attachments and how they can be secured with Metro in the September 29, 2008 Tech Tip Securing Attachments With Metro 1.3.


2009 JavaOne Conference, June 2-5, San Francisco \*\* Register Now\*\*

Stay on top of everything new and different, both inside and around Java technology. Register by April 22, 2009, and save $200 off a Conference Pass or Conference Plus Pass. Register now at http://java.sun.com/javaone.

Comments:

Post a Comment:
Comments are closed for this entry.
About

edort

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today