You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by mu...@apache.org on 2004/10/16 10:05:12 UTC
cvs commit: ws-fx/wss4j/src/org/apache/ws/security/trust RSTR_Parser.java TrustConstants.java STSManager.java
muthulee 2004/10/16 01:05:12
Modified: wss4j/src/org/apache/ws/security/trust TrustConstants.java
STSManager.java
Added: wss4j/src/org/apache/ws/security/trust RSTR_Parser.java
Log:
Code for interop.
Revision Changes Path
1.5 +7 -6 ws-fx/wss4j/src/org/apache/ws/security/trust/TrustConstants.java
Index: TrustConstants.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/trust/TrustConstants.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TrustConstants.java 9 Aug 2004 17:53:46 -0000 1.4
+++ TrustConstants.java 16 Oct 2004 08:05:12 -0000 1.5
@@ -46,6 +46,7 @@
public static final String RENEWING_LN = "Renewing";
public static final String ALLOWPOSTDATING_LN = "AllowPostdating";
public static final String APPLIESTO_LN = "AppliesTo";
+ public static final String BINARY_SECRET_LN= "BinarySecret";
public static final String REQUEST_SECURITY_TOKEN_LN = "RequestSecurityToken";
public static final String REQUESTED_SECURITY_TOKEN_LN = "RequestedSecurityToken";
@@ -75,12 +76,12 @@
public static final String WST_PREFIX = "wst";
public static final String WSP_PREFIX = "wsp";
- //For STS there should be an issuer class specified in the server-config.wsdd
- public static final String ISSUER_CLASS = "issuerClass";
- // For STS there should be a renewer class specified in the server-config.wsdd
- public static final String RENEWER_CLASS = "renewerClass";
- // For STS there should be a validator class specified in the server-config.wsdd
- public static final String VALIDATOR_CLASS = "validatorClass";
+ //For STS there should be an issuer class specified in the STS.properties
+ public static final String ISSUER_CLASS = "org.apache.ws.axis.security.trust.service.SecurityTokenService.issuerClass";
+ // For STS there should be a renewer class specified in the STS.properties
+ public static final String RENEWER_CLASS = "org.apache.ws.axis.security.trust.service.SecurityTokenService.renewerClass";
+ // For STS there should be a validator class specified in the STS.properties
+ public static final String VALIDATOR_CLASS = "org.apache.ws.axis.security.trust.service.SecurityTokenService.validatorClass";
//In the request, The token type can be specified in the client-config
public static final String TOKEN_TYPE = "TokenType";
1.4 +2 -1 ws-fx/wss4j/src/org/apache/ws/security/trust/STSManager.java
Index: STSManager.java
===================================================================
RCS file: /home/cvs/ws-fx/wss4j/src/org/apache/ws/security/trust/STSManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- STSManager.java 9 Aug 2004 17:53:46 -0000 1.3
+++ STSManager.java 16 Oct 2004 08:05:12 -0000 1.4
@@ -107,7 +107,6 @@
this.issuerClassName = (String) hashOps.get(TrustConstants.ISSUER_CLASS);
log.debug("Issuer class" + this.issuerClassName);
-
//Create the instance of the issue/renew/validate class
Class wClass = null;
try {
@@ -131,8 +130,10 @@
res = stissuer.issue(req, res);
} catch (java.lang.Exception e) {
+ System.out.println(e.getMessage());
throw new WSTrustException("STSManager: could not issue a token " + stissuer,
e);
+
}
/********************************************************************
1.1 ws-fx/wss4j/src/org/apache/ws/security/trust/RSTR_Parser.java
Index: RSTR_Parser.java
===================================================================
/*
* Copyright 2003-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.ws.security.trust;
import org.apache.ws.security.WSSecurityException;
import org.apache.ws.security.conversation.message.token.RequestSecurityTokenResponse;
import org.apache.ws.security.conversation.message.token.RequestedProofToken;
import org.apache.ws.security.conversation.message.token.RequestedSecurityToken;
import org.apache.ws.security.policy.message.token.AppliesTo;
import org.apache.ws.security.trust.message.token.BinarySecret;
import org.apache.ws.security.trust.message.token.ComputedKey;
import org.apache.ws.security.trust.message.token.Entropy;
import org.apache.ws.security.trust2.Lifetime;
import org.apache.ws.security.util.WSSecurityUtil;
import org.apache.xml.utils.QName;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* @author Dimuthu Leelarathne. (muthulee@yahoo.com)
*
* This parses the RequestSecurityTokenResponse. This will be extremely useful for
* requestor classes.
*
*/
public class RSTR_Parser {
private Element element = null;
private AppliesTo appto = null;
private Lifetime lifeTime = null;
private RequestedSecurityToken reqtedTok = null;
private RequestedProofToken proofTok = null;
private Entropy entropy = null;
private ComputedKey ckey = null;
private BinarySecret binSecret = null;
private static final QName APPLIES_TO =
new QName(TrustConstants.WSP_NS, "AppliesTo");
private static final QName LIFE_TIME =
new QName(TrustConstants.WST_NS, "Lifetime");
private static final QName REQUESTED_ST =
new QName(TrustConstants.WST_NS, "RequestedSecurityToken");
private static final QName PROOF_TOKEN =
new QName(TrustConstants.WST_NS, "RequestedProofToken");
private static final QName ENTROPY =
new QName(TrustConstants.WST_NS, "Entropy");
private static final QName COMPUTED_KEY =
new QName(TrustConstants.WST_NS, "ComputedKey");
private static final QName BIN_SECRET =
new QName(TrustConstants.WST_NS, "BinarySecret");
public void processRSTR(RequestSecurityTokenResponse rstr)
throws WSTrustException, WSSecurityException {
element = rstr.getElement();
NodeList list = element.getChildNodes();
int len = list.getLength();
Node nod;
Element elem;
for (int i = 0; i < len; i++) {
nod = list.item(i);
if (nod.getNodeType() != Node.ELEMENT_NODE)
continue;
elem = (Element) nod;
QName el = new QName(elem.getNamespaceURI(), elem.getLocalName());
if (el.equals(APPLIES_TO)) {
appto = new AppliesTo(elem);
} else if (el.equals(LIFE_TIME)) {
//TODO: Fix the problem
//lifeTime = new Lifetime(elem);
} else if (el.equals(REQUESTED_ST)) {
reqtedTok = new RequestedSecurityToken(elem);
System.out.println("Found reqtedToken....");
} else if (el.equals(PROOF_TOKEN)) {
proofTok = new RequestedProofToken(elem);
this.handleProofToken();
} else if (el.equals(ENTROPY)) {
entropy = new Entropy(elem);
handleEntropy();
} else {
//TODO :: Do something :-0
}
} //end of for loop
}
private void handleProofToken()
throws WSTrustException, WSSecurityException {
NodeList list = this.proofTok.getElement().getChildNodes();
int len = list.getLength();
Node nod;
Element elem;
for (int i = 0; i < len; i++) {
nod = list.item(i);
if (nod.getNodeType() != Node.ELEMENT_NODE)
continue;
elem = (Element) nod;
QName el = new QName(elem.getNamespaceURI(), elem.getLocalName());
if (el.equals(COMPUTED_KEY)) {
ckey = new ComputedKey(elem);
//TODO: proofTok.s
Node val = elem.getChildNodes().item(0);
if (val.getNodeType() == Node.TEXT_NODE) {
ckey.setComputedKeyValue(val.getNodeValue());
} else {
throw new WSTrustException();
}
} else if (el.equals(BinarySecret.TOKEN)) {
this.binSecret = new BinarySecret(elem);
Node val = elem.getChildNodes().item(0);
if (val.getNodeType() == Node.TEXT_NODE) {
binSecret.setBinarySecretValue(val.getNodeValue());
} else {
throw new WSTrustException();
}
}else{
// TODO :: Do something :-0
}
} //for
} //handleProof
private void handleEntropy() throws WSTrustException, WSSecurityException{
NodeList list = this.entropy.getElement().getChildNodes();
int len = list.getLength();
Node nod;
Element elem;
for (int i = 0; i < len; i++) {
nod = list.item(i);
if (nod.getNodeType() != Node.ELEMENT_NODE)
continue;
elem = (Element) nod;
QName el = new QName(elem.getNamespaceURI(), elem.getLocalName());
if (el.equals(BinarySecret.TOKEN)) {
this.binSecret = new BinarySecret(elem);
entropy.setBinarySecret(binSecret);
Node val = elem.getChildNodes().item(0);
if (val.getNodeType() == Node.TEXT_NODE) {
binSecret.setBinarySecretValue(val.getNodeValue());
} else {
throw new WSTrustException();
}
} else {
//TODO :: Do something :-0
}
} //for
} //handleEntropy
/**
* @return
*/
public AppliesTo getAppto() {
return appto;
}
/**
* @return
*/
public BinarySecret getBinSecret() {
return binSecret;
}
/**
* @return
*/
public ComputedKey getCkey() {
return ckey;
}
/**
* @return
*/
public Entropy getEntropy() {
return entropy;
}
/**
* @return
*/
public Lifetime getLifeTime() {
return lifeTime;
}
/**
* @return
*/
public RequestedProofToken getProofTok() {
return proofTok;
}
/**
* @return
*/
public RequestedSecurityToken getReqtedTok() {
return reqtedTok;
}
/**
* @param to
*/
public void setAppto(AppliesTo to) {
appto = to;
}
/**
* @param secret
*/
public void setBinSecret(BinarySecret secret) {
binSecret = secret;
}
/**
* @param key
*/
public void setCkey(ComputedKey key) {
ckey = key;
}
/**
* @param entropy
*/
public void setEntropy(Entropy entropy) {
this.entropy = entropy;
}
/**
* @param lifetime
*/
public void setLifeTime(Lifetime lifetime) {
lifeTime = lifetime;
}
/**
* @param token
*/
public void setProofTok(RequestedProofToken token) {
proofTok = token;
}
/**
* @param token
*/
public void setReqtedTok(RequestedSecurityToken token) {
reqtedTok = token;
}
}