001: package com.sun.portal.wsrp.producer;
002:
003: public class ProducerDN {
004:
005: public static final String WSRP_ROLE_PREFIX = "_WSRPRole_";
006: public static final String WSRP_ROLE_CN_PREFIX = "cn="
007: + WSRP_ROLE_PREFIX;
008:
009: /**
010: * Gets the DN for the producers' organizational unit.
011: * For example: ou=WSRPProducers,dc=sun,dc=com
012: *
013: */
014: public static String getProducersDN(String org, String portalId) {
015: ISMultiPortalConstants ismpc = null;
016: if (portalId == null) {
017: ismpc = ISMultiPortalConstants.getInstance();
018: } else {
019: ismpc = ISMultiPortalConstants.getInstance(portalId);
020: }
021:
022: return "ou=" + ismpc.MP_RDN_PRODUCER + "," + org;
023: }
024:
025: /**
026: * Gets the DN for the producer instance organizational unit.
027: * For example: ou=default,ou=WSRPProducers,dc=sun,dc=com
028: */
029: public static String getProducerDN(String org, String instance,
030: String portalId) {
031: return "ou=" + instance + "," + getProducersDN(org, portalId);
032: }
033:
034: /**
035: * Gets the DN for the consumer (registration) organizational unit.
036: * For example: ou=aConsumer,ou=default,ou=WSRPProducers,dc=sun,dc=com
037: */
038: public static String getConsumerDN(String org, String instance,
039: String consumer, String portalId) {
040: return "ou=" + consumer + ","
041: + getProducerDN(org, instance, portalId);
042: }
043:
044: /**
045: * Gets the DN for the consumer (registration) organizational unit.
046: * For example: ou=aConsumer,ou=default,ou=WSRPProducers,dc=sun,dc=com
047: */
048: public static String getConsumerDN(String producerDN,
049: String consumer) {
050: return "ou=" + consumer + "," + producerDN;
051: }
052:
053: /**
054: * Gets the consumer (actually the registration handle) from the
055: * given consumer DN.
056: * For example: return aConsumer given ou=aConsumer,ou=default,ou=WSRPProducers,dc=sun,dc=com
057: */
058: public static String getConsumer(String consumerDN) {
059: // separate the RDN from the producer instance DN
060: int i = consumerDN.indexOf(",");
061: String rdn = (i < 0) ? consumerDN : consumerDN.substring(0, i);
062:
063: // strip out "ou="
064: return rdn.startsWith("ou=") ? rdn.substring(3) : rdn;
065: }
066:
067: /**
068: * Gets the DN for the consumer people container.
069: * For example: ou=People,ou=aConsumer,ou=default,ou=WSRPProducers,dc=sun,dc=com
070: */
071: public static String getConsumerPeopleDN(String org,
072: String instance, String consumer, String portalId) {
073: return "ou=People,"
074: + getConsumerDN(org, instance, consumer, portalId);
075: }
076:
077: /**
078: * Gets the DN for the default people container.
079: * For example: ou=People,ou=default,ou=WSRPProducers,dc=sun,dc=com
080: */
081: public static String getDefaultPeopleDN(String org,
082: String instance, String portalId) {
083: return "ou=People," + getProducerDN(org, instance, portalId);
084: }
085:
086: /**
087: * Gets the DN for a producer user entry.
088: * For example: ou=aUser,ou=People,ou=aConsumer,ou=default,ou=WSRPProducers,dc=sun,dc=com
089: */
090: public static String getUserDN(String org, String instance,
091: String consumer, String user, String portalId) {
092: return "uid="
093: + user
094: + ","
095: + getConsumerPeopleDN(org, instance, consumer, portalId);
096: }
097:
098: /**
099: * Gets the DN for the default producer user entry.
100: * For example: uid=default,ou=People,ou=default,ou=WSRPProducers,dc=sun,dc=com
101: */
102: public static String getDefaultUserDN(String org, String instance,
103: String portalId) {
104: return "uid=default,"
105: + getDefaultPeopleDN(org, instance, portalId);
106: }
107:
108: /**
109: * Gets the DN for the WSRP producers' Role
110: * For example: cn=WSRPRole,dc=sun,dc=com
111: *
112: */
113: public static String getProducersRoleDN(String org,
114: String instance, String regHandle, String portalId) {
115: return "cn="
116: + getProducersRoleName(instance, regHandle, portalId)
117: + "," + org;
118: }
119:
120: public static String getProducersRoleName(String instanceName,
121: String regHandle, String portalId) {
122: if (portalId != null) {
123: return WSRP_ROLE_PREFIX + portalId + "_" + instanceName
124: + "_" + regHandle;
125: } else {
126: ISMultiPortalConstants ismpc = ISMultiPortalConstants
127: .getInstance();
128: portalId = ismpc.getPortalId();
129: if (portalId != null) {
130: return WSRP_ROLE_PREFIX + portalId + "_" + instanceName
131: + "_" + regHandle;
132: }
133: }
134: return WSRP_ROLE_PREFIX + instanceName + "_" + regHandle;
135: }
136: }
|