Author: ruchith
Date: Sun Mar 2 03:58:14 2008
New Revision: 14407
Log:
getting rid of some unused methods and fields
minor refactoring
More fixes from findbugs
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityProviderData.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityTokenIssuer.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML1TokenBuilder.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML2TokenBuilder.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAMLTokenDirector.java
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/Initializer.java
Sun Mar 2 03:58:14 2008
@@ -99,7 +99,6 @@
// Add the globally trusted relying party
RelyingPartyDO rp = new RelyingPartyDO();
- rp = new RelyingPartyDO();
ServerConfiguration serverConfig = ServerConfiguration
.getInstance();
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityProviderData.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityProviderData.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityProviderData.java
Sun Mar 2 03:58:14 2008
@@ -90,8 +90,6 @@
private String userIdentifier = null;
- private String primaryId = null;
-
private String requiredTokenType = null;
/**
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityTokenIssuer.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityTokenIssuer.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/IdentityTokenIssuer.java
Sun Mar 2 03:58:14 2008
@@ -16,23 +16,6 @@
package org.wso2.solutions.identity.sts;
-import java.io.ByteArrayInputStream;
-import java.security.cert.X509Certificate;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.crypto.SecretKey;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNode;
@@ -55,13 +38,8 @@
import org.apache.xml.security.encryption.EncryptedData;
import org.apache.xml.security.encryption.XMLCipher;
import org.apache.xml.security.keys.KeyInfo;
-import org.apache.xml.security.utils.Base64;
import org.joda.time.DateTime;
-import org.opensaml.SAMLAttribute;
-import org.opensaml.SAMLAttributeStatement;
import org.opensaml.SAMLException;
-import org.opensaml.SAMLStatement;
-import org.opensaml.SAMLSubject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -75,8 +53,6 @@
import org.wso2.solutions.identity.persistence.dataobject.ActionDO;
import org.wso2.solutions.identity.persistence.dataobject.InfoCardDO;
import org.wso2.solutions.identity.persistence.dataobject.IssuedTokensDO;
-import org.wso2.solutions.identity.persistence.dataobject.PPIDValueDO;
-import org.wso2.solutions.identity.persistence.dataobject.RelyingPartyDO;
import org.wso2.solutions.identity.sts.IdentityProviderData.RequestedClaimData;
import org.wso2.solutions.identity.sts.saml.SAML1TokenBuilder;
import org.wso2.solutions.identity.sts.saml.SAML2TokenBuilder;
@@ -84,6 +60,20 @@
import org.wso2.solutions.identity.sts.saml.SAMLTokenDirector;
import org.wso2.solutions.identity.util.IdentityUtil;
+import javax.crypto.SecretKey;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import java.io.ByteArrayInputStream;
+import java.security.cert.X509Certificate;
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TimeZone;
+
/**
* This is the main token issuer implementation identity provider. Two types of
* credential mechanisms are supported:
@@ -103,8 +93,6 @@
private final static String WSS_SAML_NS =
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#";
- String confileFilePath;
-
protected IdentityProviderData ipData = null;
public final static String ISSUER_SELF = IdentityConstants.NS
@@ -155,8 +143,7 @@
if (isValidCard == false) {
String msg = "Invalid information card";
log.error(msg);
- ReportAdmin admin = new ReportAdmin();
- admin.record(ipData.getUserIdentifier(),
+ ReportAdmin.record(ipData.getUserIdentifier(),
ActionDO.ACTION_TOKEN_ISSUE_FAILURE, msg);
throw new TrustException(TrustException.REQUEST_FAILED);
@@ -536,145 +523,6 @@
}
/**
- * Create SAML attribute statements for the response token.
- *
- * @param ipData
- * Meta-data for this issuer.
- * @param rahasData
- * WS-Trust common information in the issue request.
- * @return An array of SAML attribute statements
- * @throws SAMLException
- * @throws IdentityProviderException
- */
- private SAMLStatement[] createSAMLStatements(IdentityProviderData ipData,
- RahasData rahasData) throws SAMLException,
- IdentityProviderException {
-
- // The SAMLSubject
- if (log.isDebugEnabled()) {
- log.debug("Begin SAML statement creation.");
- }
- String[] confirmationMethods = new String[] {
SAMLSubject.CONF_HOLDER_KEY };
-
- SAMLSubject subject = new SAMLSubject(null, Arrays
- .asList(confirmationMethods), null, null);
-
- Map mapClaims = ipData.getRequestedClaims();
-
- List assertionList = new ArrayList();
- Iterator ite = mapClaims.values().iterator();
-
- while (ite.hasNext()) {
- RequestedClaimData claim = (RequestedClaimData) ite.next();
- String uri = claim.uri;
- if (uri.equals(IdentityConstants.CLAIM_PPID)) {
- // Get this user's PPID
- String name = ipData.getUserIdentifier();
- claim.value = getPPID(rahasData, name, rahasData
- .getAppliesToEpr());
- }
-
- int index = uri.lastIndexOf("/");
-
- if (claim.value == null) {
- throw new IdentityProviderException(
- "noValueForRequestedAttribute",
- new String[] { claim.uri });
- }
- List list = Arrays.asList(new String[] { claim.value });
- String displayTag = ipData.getDisplayName(uri);
- if ((displayTag == null) && (claim.bOptional == false)) {
- throw new IdentityProviderException("unknownClaimUri",
- new String[] { uri });
- }
-
- SAMLAttribute attr = new SAMLAttribute(uri.substring(index + 1, uri
- .length()), uri.substring(0, index), null, -1, list);
- assertionList.add(attr);
-
- }
- SAMLAttribute[] attrs = (SAMLAttribute[]) assertionList
- .toArray(new SAMLAttribute[assertionList.size()]);
-
- // AttributeStatement
- SAMLAttributeStatement attrStmt = new SAMLAttributeStatement(subject,
- Arrays.asList(attrs));
-
- SAMLStatement[] statements = { attrStmt };
- if (log.isDebugEnabled()) {
- log.debug("SAML statements created");
- }
- return statements;
- }
-
- /**
- * Obtain the ppid for the given user for the given rp.
- *
- * @param rahasData
- * WS-Trust information in the issue request.
- * @param name
- * Name of the user/subject.
- * @param appliesToEpr
- * EPR element in wst:AppliesTo element.
- * @return PPID value. If there's already an issued token then the ppid
- * value will be reused.
- * @throws IdentityProviderException
- */
- private String getPPID(RahasData rahasData, String name,
- OMElement appliesToEpr) throws IdentityProviderException {
-
- String appliesToHostName = IdentityProviderUtil
- .getAppliesToHostName(rahasData);
- IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
- PPIDValueDO[] ppidValueDOs = db.getPPIDValuesForUser(name);
- PPIDValueDO ppidValueDO = null;
- for (int i = 0; i < ppidValueDOs.length; i++) {
- String hostName = null;
- if (ppidValueDOs[i].getRelyingParty() != null) {
- hostName = ppidValueDOs[i].getRelyingParty().getHostName();
- } else if (ppidValueDOs[i].getPersonalRelyingParty() != null) {
- hostName = ppidValueDOs[i].getPersonalRelyingParty()
- .getIdentifier().getHostName();
- }
-
- if (hostName == null) {
- throw new IdentityProviderException("hostNotTrusted",
- new String[] { hostName });
- }
-
- if (appliesToHostName.equals(hostName)) {
- ppidValueDO = ppidValueDOs[i];
- }
- }
-
- if (ppidValueDO != null) {
- // If we have already issued a PPID
- // Then return that value
- return ppidValueDO.getPpid();
- } else {
- // A new request targeted for a new RP
- String newPpid = Base64.encode(UUIDGenerator.getUUID().getBytes());
- ppidValueDO = new PPIDValueDO();
- ppidValueDO.setUserId(name);
- ppidValueDO.setPpid(newPpid);
-
- // If the host is globally trusted
- RelyingPartyDO rp = db.getRelyingParty(appliesToHostName);
- if (rp != null) {
- ppidValueDO.setRelyingParty(rp);
- } else {
- // Else the host MUST be personally trusted
- ppidValueDO.setPersonalRelyingParty(db.getPersonalRelyingParty(
- name, appliesToHostName));
- }
-
- db.create(ppidValueDO);
-
- return newPpid;
- }
- }
-
- /**
* [EMAIL PROTECTED]
*/
public void setConfigurationElement(OMElement configElement) {
@@ -685,7 +533,7 @@
* [EMAIL PROTECTED]
*/
public void setConfigurationFile(String configFile) {
- this.confileFilePath = configFile;
+ //Nothing to do
}
/**
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML1TokenBuilder.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML1TokenBuilder.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML1TokenBuilder.java
Sun Mar 2 03:58:14 2008
@@ -81,7 +81,7 @@
if (uri.equals(IdentityConstants.CLAIM_PPID)) {
// Get this user's PPID
String name = ipData.getUserIdentifier();
- claim.value = SAMLTokenDirector.createPPID(rahasData, name,
+ claim.value = SAMLTokenDirector.getPPID(rahasData, name,
rahasData.getAppliesToEpr());
}
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML2TokenBuilder.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML2TokenBuilder.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAML2TokenBuilder.java
Sun Mar 2 03:58:14 2008
@@ -75,7 +75,7 @@
if (uri.equals(IdentityConstants.CLAIM_PPID)) {
// Get this user's PPID
String name = ipData.getUserIdentifier();
- claim.value = SAMLTokenDirector.createPPID(rahasData, name,
+ claim.value = SAMLTokenDirector.getPPID(rahasData, name,
rahasData.getAppliesToEpr());
}
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAMLTokenDirector.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAMLTokenDirector.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/sts/saml/SAMLTokenDirector.java
Sun Mar 2 03:58:14 2008
@@ -64,6 +64,8 @@
/**
* Obtain the ppid for the given user for the given rp.
+ * If this is the first time user requesting for a token then a new PPID
+ * value will be created.
*
* @param rahasData
* WS-Trust information in the issue request.
@@ -75,7 +77,7 @@
* value will be reused.
* @throws IdentityProviderException
*/
- public static String createPPID(RahasData rahasData, String name,
+ public static String getPPID(RahasData rahasData, String name,
OMElement appliesToEpr) throws IdentityProviderException {
String appliesToHostName = IdentityProviderUtil
@@ -92,11 +94,10 @@
.getIdentifier().getHostName();
}
- if (hostName == null) {
- throw new IdentityProviderException("hostNotTrusted",
- new String[] { hostName });
- }
+ //hostName is not-null on both globally trusted relying parties and
+ //user trusted relying parties
+ //Check whether the host name matches
if (appliesToHostName.equals(hostName)) {
ppidValueDO = ppidValueDOs[i];
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev