001: /*
002: * $Id: RequestSecurityTokenResponseCollectionImpl.java,v 1.1 2007/08/23 12:40:56 shyam_rao Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025: */
026:
027: package com.sun.xml.ws.security.trust.impl.wssx.elements;
028:
029: import com.sun.xml.ws.policy.impl.bindings.AppliesTo;
030: import com.sun.xml.ws.security.trust.elements.Entropy;
031: import com.sun.xml.ws.security.trust.elements.Lifetime;
032: import com.sun.xml.ws.security.trust.elements.RequestSecurityTokenResponse;
033: import com.sun.xml.ws.security.trust.elements.RequestSecurityTokenResponseCollection;
034: import com.sun.xml.ws.security.trust.elements.RequestedAttachedReference;
035: import com.sun.xml.ws.security.trust.elements.RequestedProofToken;
036: import com.sun.xml.ws.security.trust.elements.RequestedSecurityToken;
037: import com.sun.xml.ws.security.trust.elements.RequestedUnattachedReference;
038: import com.sun.xml.ws.security.trust.impl.wssx.bindings.RequestSecurityTokenResponseCollectionType;
039: import com.sun.xml.ws.security.trust.impl.wssx.bindings.ObjectFactory;
040: import com.sun.xml.ws.security.trust.impl.wssx.bindings.RequestSecurityTokenResponseType;
041: import java.net.URI;
042: import java.util.ArrayList;
043: import java.util.List;
044: import javax.xml.bind.JAXBElement;
045:
046: /**
047: * @author Manveen Kaur.
048: */
049: public class RequestSecurityTokenResponseCollectionImpl extends
050: RequestSecurityTokenResponseCollectionType implements
051: RequestSecurityTokenResponseCollection {
052:
053: protected List<RequestSecurityTokenResponse> requestSecurityTokenResponse;
054:
055: public RequestSecurityTokenResponseCollectionImpl() {
056: // empty ctor
057: }
058:
059: public RequestSecurityTokenResponseCollectionImpl(
060: RequestSecurityTokenResponse rstr) {
061: addRequestSecurityTokenResponse(rstr);
062: }
063:
064: public RequestSecurityTokenResponseCollectionImpl(URI tokenType,
065: URI context, RequestedSecurityToken token,
066: AppliesTo scopes, RequestedAttachedReference attached,
067: RequestedUnattachedReference unattached,
068: RequestedProofToken proofToken, Entropy entropy, Lifetime lt) {
069: RequestSecurityTokenResponse rstr = new RequestSecurityTokenResponseImpl(
070: tokenType, context, token, scopes, attached,
071: unattached, proofToken, entropy, lt, null);
072: addRequestSecurityTokenResponse(rstr);
073:
074: }
075:
076: public RequestSecurityTokenResponseCollectionImpl(
077: RequestSecurityTokenResponseCollectionType rstrcType)
078: throws Exception {
079: List<Object> list = rstrcType.getRequestSecurityTokenResponse();
080: System.out.println("******* response size *****" + list.size());
081: for (int i = 0; i < list.size(); i++) {
082:
083: RequestSecurityTokenResponseType rst = null;
084: Object object = list.get(i);
085: if (object instanceof JAXBElement) {
086: JAXBElement obj = (JAXBElement) object;
087:
088: String local = obj.getName().getLocalPart();
089: if (local
090: .equalsIgnoreCase("RequestSecurityTokenResponse")) {
091: rst = (RequestSecurityTokenResponseType) obj
092: .getValue();
093: }
094: } else {
095: rst = (RequestSecurityTokenResponseType) object;
096: }
097: addRequestSecurityTokenResponse(new RequestSecurityTokenResponseImpl(
098: rst));
099: }
100: }
101:
102: public List<RequestSecurityTokenResponse> getRequestSecurityTokenResponses() {
103: if (requestSecurityTokenResponse == null) {
104: requestSecurityTokenResponse = new ArrayList<RequestSecurityTokenResponse>();
105: }
106: return this .requestSecurityTokenResponse;
107: }
108:
109: public void addRequestSecurityTokenResponse(
110: RequestSecurityTokenResponse rstr) {
111: System.out.println("******* rstr added in rstrc*****");
112: getRequestSecurityTokenResponses().add(rstr);
113:
114: JAXBElement<RequestSecurityTokenResponseType> rstrEl = (new ObjectFactory())
115: .createRequestSecurityTokenResponse((RequestSecurityTokenResponseType) rstr);
116: getRequestSecurityTokenResponse().add(rstrEl);
117: }
118:
119: }
|