FederationStoreImpl.java from GridBlocks at Krugle
Show FederationStoreImpl.java syntax highlighted
/**
* Copyright (c) 2005
* Helsinki Institute of Physics
* see LICENSE file for details
*
* FederationStoreImpl.java
* Created on Nov 1, 2005
*/
package fi.hip.gb.gridlib.gridsp.adapters;
import fi.hip.gb.gridlib.idff12.database.spfedbase.FederationDatabase;
import fi.hip.gb.gridlib.idff12.config.DatabaseFactory;
import fi.hip.gb.gridlib.gridsp.userbase.PortalUser;
import org.sourceid.idff12.adapter.FederationStoreAdapter;
import org.sourceid.idff12.adapter.FederationInfo;
import org.sourceid.common.Util;
/**
* This class includes the implementation for the
* org.sourceid.idff12.adapter.FederationStoreAdapter interface.
* @author Henri Mikkonen
* @version $Id: $
*/
public class FederationStoreImpl implements FederationStoreAdapter {
/**
* Gets the federation info by the local principal identifier and the
* provider identifier.
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @return The corresponding federation info, null if it does not exist.
*/
public synchronized FederationInfo getFederationInfo(String principalId,
String providerId) {
PortalUser user = new PortalUser();
user = user.getUserByName(principalId);
String uid = "" + user.getUid();
FederationDatabase db = DatabaseFactory.getFederationDatabase();
FederationInfo[] federations = db.getFederationInfosByUid(uid);
FederationInfo result = null;
for (int i = 0; i < federations.length; i++) {
if (federations[i].getProviderId().equals(providerId)) {
result = federations[i];
}
}
return result;
}
/**
* Gets the federation info by the pseudonym identifier at the IDP and the
* provider identifier.
* @param idpNameId The principal's pseudonym identifier at the IDP as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @return The corresponding federation info.
*/
public synchronized FederationInfo
getFederationInfoByIdp(String idpNameId,
String providerId) {
FederationDatabase db = DatabaseFactory.getFederationDatabase();
return db.getFederationInfoByIdp(idpNameId, providerId);
}
/**
* Gets the federation info by the pseudonym identifier at the SP and the
* provider identifier. If it does not exist, the IDP's pseudonym is used
* instead.
* @param spNameId The principal's pseudonym identifier at the SP as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @return The corresponding federation info.
*/
public synchronized FederationInfo
getFederationInfoBySp(String spNameId,
String providerId) {
FederationDatabase db = DatabaseFactory.getFederationDatabase();
FederationInfo result = db.getFederationInfoBySp(spNameId, providerId);
if (result == null) {
result = getFederationInfoByIdp(spNameId, providerId);
}
return result;
}
/**
* Initializes a federation.
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @param idpNameId The principal's pseudonym identifier at the IDP as
* <code>String</code>.
* @return The corresponding federation info.
*/
public synchronized FederationInfo
initializeFederation(String principalId,
String providerId,
String idpNameId) {
PortalUser user = new PortalUser();
user = user.getUserByName(principalId);
String uid = "" + user.getUid();
FederationDatabase db = DatabaseFactory.getFederationDatabase();
return db.addFederation(uid, principalId, providerId, idpNameId);
}
/**
* Terminates a federation.
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
*/
public synchronized void terminateFederation(String principalId,
String providerId) {
FederationDatabase db = DatabaseFactory.getFederationDatabase();
db.removeFederation(principalId, providerId);
}
/**
* Updates the principal's SP pseudonym identifier in a federation.
* @param providerId The provider identifier as <code>String</code>.
* @param idpNameId The principal's pseudonym identifier at the IDP as
* <code>String</code>.
* @param oldSpNameId The principal's current pseudonym identifer at the
* SP as <code>String</code>.
* @param newSpNameId The principal's new pseudonym identifer at the
* SP as <code>String</code>.
*/
public synchronized void updateSpNameId(String providerId,
String idpNameId,
String oldSpNameId,
String newSpNameId) {
FederationDatabase db = DatabaseFactory.getFederationDatabase();
db.updateSpNameId(providerId, idpNameId, oldSpNameId, newSpNameId);
}
/**
* Updates the principal's IDP pseudonym identifier in a federation.
* @param providerId The provider identifier as <code>String</code>.
* @param oldIdpNameId The principal's current pseudonym identifer at the
* IDP as <code>String</code>.
* @param newIdpNameId The principal's new pseudonym identifer at the
* IDP as <code>String</code>.
*/
public synchronized void updateIdpNameId(String providerId,
String oldIdpNameId,
String newIdpNameId) {
FederationDatabase db = DatabaseFactory.getFederationDatabase();
db.updateIdpNameId(providerId, oldIdpNameId, newIdpNameId);
}
/**
* TODO
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
*/
public synchronized boolean shouldDoRNI(String principalId,
String providerId) {
return false; // TODO API
}
/**
* Gets the authorized proxy certificate subject DN in a federation.
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @return The subject DN as <code>String</code>.
*/
public synchronized String
getProxyCertificateSubjectDN(String principalId,
String providerId) {
PortalUser user = new PortalUser();
user = user.getUserByName(principalId);
String uid = "" + user.getUid();
FederationDatabase db = DatabaseFactory.getFederationDatabase();
return db.getProxyCertificateSubjectDN(principalId, providerId);
}
/**
* Sets the authorized proxy certificate subject DN in a federation.
* @param principalId The local principal identifier as
* <code>String</code>.
* @param providerId The provider identifier as <code>String</code>.
* @param subjectDN The subject DN as <code>String</code>.
*/
public synchronized void setProxyCertificateSubjectDN(String principalId,
String providerId,
String subjectDN) {
PortalUser user = new PortalUser();
user = user.getUserByName(principalId);
String uid = "" + user.getUid();
FederationDatabase db = DatabaseFactory.getFederationDatabase();
db.setProxyCertificateSubjectDN(principalId, providerId, subjectDN);
}
}
See more files for this project here