View Javadoc
1 /* 2 * $Header: /cvsroot/ebxmlrr/ebxmlrr/src/share/com/sun/ebxml/registry/interfaces/Request.java,v 1.9 2003/07/28 02:55:47 farrukh_najmi Exp $ 3 * 4 * ==================================================================== 5 * 6 * This code is subject to the freebxml License, Version 1.1 7 * 8 * Copyright (c) 2003 freebxml.org. All rights reserved. 9 * 10 * ==================================================================== 11 */ 12 13 package com.sun.ebxml.registry.interfaces; 14 15 import com.sun.ebxml.registry.lcm.LifeCycleManagerImpl; 16 17 /*** 18 * A Request encapsulates all aspects of an incoming client request to an ebXML registry. 19 * 20 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 21 */ 22 public class Request { 23 private org.apache.xml.security.signature.XMLSignature headerSignature = null; 24 private Object message = null; 25 private java.util.HashMap idToRepositoryItemMap = null; 26 private boolean synchronous = true; 27 28 private org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(this.getClass()); 29 private static org.oasis.ebxml.registry.bindings.rim.User s_guestUser = null; 30 31 public Request(org.apache.xml.security.signature.XMLSignature headerSignature, 32 Object message, java.util.HashMap idToRepositoryItemMap) { 33 this.headerSignature = headerSignature; 34 this.message = message; 35 this.idToRepositoryItemMap = idToRepositoryItemMap; 36 } 37 38 public org.apache.xml.security.signature.XMLSignature getMessageHeaderSignature() { 39 return headerSignature; 40 } 41 42 public Object getMessage() { 43 return message; 44 } 45 46 public boolean isSynchronous() { 47 return synchronous; 48 } 49 50 public java.util.HashMap getIdToRepositoryItemMap() { 51 return idToRepositoryItemMap; 52 } 53 54 /*** 55 * Processes the Request by dispatching it to a service in the registry. 56 */ 57 public Response process() throws com.sun.ebxml.registry.RegistryException { 58 Response response = null; 59 60 org.oasis.ebxml.registry.bindings.rs.RegistryResponse rr = null; 61 62 org.oasis.ebxml.registry.bindings.rim.User user = null; 63 com.sun.ebxml.registry.security.authentication.AuthenticationServiceImpl authc = 64 com.sun.ebxml.registry.security.authentication.AuthenticationServiceImpl.getInstance(); 65 if (headerSignature != null) { 66 try { 67 user = authc.getUserFromXMLSignature(headerSignature); 68 } 69 catch (com.sun.ebxml.registry.security.UserNotFoundException e) { 70 if (message instanceof org.oasis.ebxml.registry.bindings.rs.SubmitObjectsRequest) { 71 user = com.sun.ebxml.registry.security.authentication.UserRegistrar.getInstance().registerUser(headerSignature, (org.oasis.ebxml.registry.bindings.rs.SubmitObjectsRequest)message); 72 } 73 else { 74 user = authc.getUserFromAlias(authc.ALIAS_REGISTRY_GUEST); 75 } 76 } 77 } 78 else { 79 //Cache guest user once so we do not query for it each time. 80 if (s_guestUser == null) { 81 s_guestUser = authc.getUserFromAlias(authc.ALIAS_REGISTRY_GUEST); 82 } 83 user = s_guestUser; 84 } 85 86 87 //Following throws RegistryException if unauthorized request 88 com.sun.ebxml.registry.security.authorization.AuthorizationServiceImpl.getInstance().checkAuthorization(user, message); 89 90 if (message instanceof org.oasis.ebxml.registry.bindings.query.AdhocQueryRequest) { 91 rr = com.sun.ebxml.registry.query.QueryManagerImpl.getInstance().submitAdhocQuery(user, (org.oasis.ebxml.registry.bindings.query.AdhocQueryRequest)message); 92 } 93 else if (message instanceof org.oasis.ebxml.registry.bindings.query.GetContentRequest) { 94 rr = com.sun.ebxml.registry.query.QueryManagerImpl.getInstance().getContent((org.oasis.ebxml.registry.bindings.query.GetContentRequest)message); 95 } 96 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.ApproveObjectsRequest) { 97 rr = LifeCycleManagerImpl.getInstance().approveObjects(user, (org.oasis.ebxml.registry.bindings.rs.ApproveObjectsRequest)message); 98 } 99 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.DeprecateObjectsRequest) { 100 rr = LifeCycleManagerImpl.getInstance().deprecateObjects(user, (org.oasis.ebxml.registry.bindings.rs.DeprecateObjectsRequest)message); 101 } 102 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.RemoveObjectsRequest) { 103 rr = LifeCycleManagerImpl.getInstance().removeObjects(user, (org.oasis.ebxml.registry.bindings.rs.RemoveObjectsRequest)message); 104 } 105 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.SubmitObjectsRequest) { 106 rr = LifeCycleManagerImpl.getInstance().submitObjects(user, (org.oasis.ebxml.registry.bindings.rs.SubmitObjectsRequest)message, idToRepositoryItemMap); 107 } 108 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.UpdateObjectsRequest) { 109 rr = LifeCycleManagerImpl.getInstance().updateObjects(user, (org.oasis.ebxml.registry.bindings.rs.UpdateObjectsRequest)message, idToRepositoryItemMap); 110 } 111 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.AddSlotsRequest) { 112 rr = LifeCycleManagerImpl.getInstance().addSlots((org.oasis.ebxml.registry.bindings.rs.AddSlotsRequest)message); 113 } 114 else if (message instanceof org.oasis.ebxml.registry.bindings.rs.RemoveSlotsRequest) { 115 rr = LifeCycleManagerImpl.getInstance().removeSlots((org.oasis.ebxml.registry.bindings.rs.RemoveSlotsRequest)message); 116 } 117 else { 118 throw new com.sun.ebxml.registry.RegistryException("InvalidRequest: Unknown request " + message.getClass().getName()); 119 } 120 121 response = new Response(null, rr, idToRepositoryItemMap); 122 123 return response; 124 } 125 126 }

This page was automatically generated by Maven