Author: prabath
Date: Sat Jan 5 22:02:52 2008
New Revision: 11865
Log:
Added support to issue OpenID Infocards
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/cards/CardIssuer.java
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/cards/CardIssuer.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/cards/CardIssuer.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/cards/CardIssuer.java
Sat Jan 5 22:02:52 2008
@@ -73,6 +73,10 @@
private static Messages messages = Messages
.getInstance(IdentityProviderConstants.RESOURCES);
+ // track whether an OpenIdInfoCard which is based on OpenIDToken type or
+ // an InfoCard based on SAML token type.
+ private boolean isOpenIdInfoCard = false;
+
private static CardIssuerConfig issuerConfig = null;
public CardIssuer() throws IdentityProviderException {
@@ -96,18 +100,19 @@
RegisteredInfoCardInfoAdmin registerAdmin = new
RegisteredInfoCardInfoAdmin();
String primaryUserName = registerAdmin.extractPrimaryUserName(ppid);
UserCredential cred = new UserCredential(selfCred);
-
- if(primaryUserName == null){
+
+ if (primaryUserName == null) {
cardElement = issueCard(cred, requireAppliesTo, ppid);
- }else{
+ } else {
cardElement = issueCard(cred, requireAppliesTo, primaryUserName);
}
-
+
return cardElement;
}
private Element issueCard(UserCredential credential,
- boolean requireAppliesTo, String primaryUserId) throws
IdentityProviderException {
+ boolean requireAppliesTo, String primaryUserId)
+ throws IdentityProviderException {
ServerConfiguration serverConfig = ServerConfiguration.getInstance();
try {
@@ -142,7 +147,7 @@
Element elem = gen.signCard(infoCard);
String cardId = infoCard.getInformationCardReference().getCardId();
-
+
ReportAdmin.record(primaryUserId,
ActionDO.ACTION_USER_DOWNLOAD_CARD, "CardId=" + cardId);
@@ -214,9 +219,15 @@
}
} else {
if (credential.getCredential() instanceof
UsernamePasswordCredential) {
- stsAddress += IdentityProviderConstants.SERVICE_NAME_STS_UT;
- mexAddress += IdentityProviderConstants.SERVICE_NAME_MEX_UT
- + "/get";
+ if (isOpenIdInfoCard) {
+ stsAddress +=
IdentityProviderConstants.OpenId.SERVICE_NAME_STS_OPENID;
+ mexAddress +=
IdentityProviderConstants.OpenId.SERVICE_NAME_MEX_OPENID
+ + "/get";
+ } else {
+ stsAddress +=
IdentityProviderConstants.SERVICE_NAME_STS_UT;
+ mexAddress += IdentityProviderConstants.SERVICE_NAME_MEX_UT
+ + "/get";
+ }
} else if (credential.getCredential() instanceof
SelfIssuedCredential) {
stsAddress += IdentityProviderConstants.SERVICE_NAME_STS_IC;
mexAddress += IdentityProviderConstants.SERVICE_NAME_MEX_IC
@@ -243,13 +254,32 @@
IPPersistenceManager db = IPPersistenceManager.getPersistanceManager();
ClaimDO[] supportedClaims = db.getAllSupportedClaims();
SupportedClaimTypeList claimTypeList = new SupportedClaimTypeList();
- for (int i = 0; i < supportedClaims.length; i++) {
- if (supportedClaims[i].isSupported()) {
- SupportedClaimType claim = new SupportedClaimType(
- supportedClaims[i].getUri());
- claim.setDisplayTag(supportedClaims[i].getDisplayTag());
- claim.setDescription(supportedClaims[i].getDescription());
- claimTypeList.addSupportedClaimType(claim);
+
+ if (isOpenIdInfoCard) {
+ for (int i = 0; i < supportedClaims.length; i++) {
+ // Right now we do not accept OpenID from the user.
+ // We generate it for him, based on his user id and store it in
+ // the database.
+ // But, this claim needs to be included in the InfoCard.
+ if (supportedClaims[i].isSupported()
+ || supportedClaims[i].getUri().equals(
+ IdentityConstants.CLAIM_OPENID)) {
+ SupportedClaimType claim = new SupportedClaimType(
+ supportedClaims[i].getUri());
+ claim.setDisplayTag(supportedClaims[i].getDisplayTag());
+ claim.setDescription(supportedClaims[i].getDescription());
+ claimTypeList.addSupportedClaimType(claim);
+ }
+ }
+ } else {
+ for (int i = 0; i < supportedClaims.length; i++) {
+ if (supportedClaims[i].isSupported()) {
+ SupportedClaimType claim = new SupportedClaimType(
+ supportedClaims[i].getUri());
+ claim.setDisplayTag(supportedClaims[i].getDisplayTag());
+ claim.setDescription(supportedClaims[i].getDescription());
+ claimTypeList.addSupportedClaimType(claim);
+ }
}
}
@@ -300,5 +330,9 @@
log.info("Information card details stored for card id : "
+ card.getInformationCardReference().getCardId());
}
+
+ public void setIsOpenIdInfoCard(boolean isOpenIdInfoCard) {
+ this.isOpenIdInfoCard = isOpenIdInfoCard;
+ }
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev