Hi Manoj,
Please use this. Let me know if anything needs to be changed.

On Mon, Dec 9, 2013 at 10:19 AM, Manoj Kumara <ma...@wso2.com> wrote:

> Hi Shani,
>
> The patch you provided is not complete. Please follow the steps on [1].
>
> [1] http://docs.wso2.org/display/Carbon420/Creating+a+Carbon+Kernel+Patch
>
> Thanks,
> Manoj
>
> Best Regards..
>
>
> Manoj Kumara
> Software Engineer
> WSO2, Inc.; http://wso2.com
>
> Twitter:  http://twitter.com/ManKuma
> Mobile: +94713448188
>
>
> On Mon, Dec 9, 2013 at 4:16 AM, Shani Ranasinghe <sh...@wso2.com> wrote:
>
>> Hi Manoj,
>>
>> Please commit this. If you have not committed the above, the ignore the
>> above and use this.
>>
>>
>> On Thu, Dec 5, 2013 at 4:50 PM, Shani Ranasinghe <sh...@wso2.com> wrote:
>>
>>> Hi,
>>> Please commit the attached patch file to Kernel  the next  patch (patch
>>> 4). Since patch 3 is about to be released, and this change has not been
>>> tested by QA yet, please commit the changes to patch 4.
>>>
>>> --
>>> Thanks and Regards
>>> *,Shani Ranasinghe*
>>> Software Engineer
>>> WSO2 Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> mobile: +94 77 2273555
>>> linked in: lk.linkedin.com/pub/shani-ranasinghe/34/111/ab
>>>
>>
>>
>>
>> --
>> Thanks and Regards
>> *,Shani Ranasinghe*
>> Software Engineer
>> WSO2 Inc.; http://wso2.com
>> lean.enterprise.middleware
>>
>> mobile: +94 77 2273555
>> linked in: lk.linkedin.com/pub/shani-ranasinghe/34/111/ab
>>
>
>


-- 
Thanks and Regards
*,Shani Ranasinghe*
Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware

mobile: +94 77 2273555
linked in: lk.linkedin.com/pub/shani-ranasinghe/34/111/ab
Index: README.txt
===================================================================
--- README.txt  (revision 192755)
+++ README.txt  (working copy)
@@ -1,6 +1,6 @@
 Patch ID         :  WSO2-CARBON-PATCH-4.2.0-0004
 Applies To       :  WSO2 CARBON-4.2.0
-Associated JIRA  :
+Associated JIRA  : https://wso2.org/jira/browse/SS-269
 
 
 DESCRIPTION
Index: distribution/bin.xml
===================================================================
--- distribution/bin.xml        (revision 192755)
+++ distribution/bin.xml        (working copy)
@@ -29,9 +29,15 @@
             
<!--<outputDirectory>WSO2-CARBON-PATCH-4.2.0-0004/patch0004</outputDirectory>-->
             <!--<destName>org.wso2.carbon.user.core_4.2.0.jar</destName>-->
             <!--<fileMode>644</fileMode>-->
-        <!--</file>-->
+        <!--</file>--        >
 
-        <file>
+         <file>
+            
<source>../core/org.wso2.carbon.user.core/4.2.0/target/org.wso2.carbon.user.core-4.2.0.jar</source>
+            
<outputDirectory>WSO2-CARBON-PATCH-4.2.0-0004/patch0004</outputDirectory>
+            <destName>org.wso2.carbon.user.core_4.2.0.jar</destName>
+            <fileMode>644</fileMode>
+                </file>
+         <file>
             <source>../wso2carbon-version.txt</source>
             <outputDirectory>WSO2-CARBON-PATCH-4.2.0-0004</outputDirectory>
             <fileMode>644</fileMode>
Index: 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/ldap/ReadWriteLDAPUserStoreManager.java
===================================================================
--- 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/ldap/ReadWriteLDAPUserStoreManager.java
        (working copy)
+++ 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/ldap/ReadWriteLDAPUserStoreManager.java
        (working copy)
@@ -360,7 +360,7 @@
                        if(cc != null) {
                                String tenantDomainName = cc.getTenantDomain();
                                
if(!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomainName)) {
-                                       userName = userName + '/' + 
tenantDomainName;
+                                       userName = userName + 
UserCoreConstants.PRINCIPAL_USERNAME_SEPARATOR + tenantDomainName;
                                }
                        }
                        
Index: 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/tenant/CommonHybridLDAPTenantManager.java
===================================================================
--- 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/tenant/CommonHybridLDAPTenantManager.java
      (working copy)
+++ 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/tenant/CommonHybridLDAPTenantManager.java
      (working copy)
@@ -17,6 +17,7 @@
 */
 package org.wso2.carbon.user.core.tenant;
 
+import java.util.Locale;
 import java.util.Map;
 
 import javax.naming.Name;
@@ -29,6 +30,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.CarbonContext;
 import org.wso2.carbon.user.api.RealmConfiguration;
 import org.wso2.carbon.user.api.TenantMgtConfiguration;
 import org.wso2.carbon.user.core.UserCoreConstants;
@@ -327,8 +329,15 @@
             //create person object class attribute
             Attribute objClass = new 
BasicAttribute(LDAPConstants.OBJECT_CLASS_NAME);
             
objClass.add(realmConfig.getUserStoreProperty(LDAPConstants.USER_ENTRY_OBJECT_CLASS));
+            if (UserCoreUtil.isKdcEnabled(realmConfig)) {
+                       // Add Kerberos specific object classes
+               objClass.add("krb5principal");
+               objClass.add("krb5kdcentry");
+               objClass.add("subschema");
+               }
             userAttributes.put(objClass);
-
+            
+           
             //create user password attribute
             Attribute password = new 
BasicAttribute(USER_PASSWORD_ATTRIBUTE_NAME);
             String passwordToStore = UserCoreUtil.getPasswordToStore(
@@ -343,6 +352,16 @@
             adminEmail.add(tenant.getEmail());
             userAttributes.put(adminEmail);
 
+            String principal = tenant.getAdminName() + 
UserCoreConstants.PRINCIPAL_USERNAME_SEPARATOR + tenant.getDomain() + 
UserCoreConstants.TENANT_DOMAIN_COMBINER + getRealmName();
+            Attribute kerberosPrincipalName = new 
BasicAttribute("krb5PrincipalName");
+            kerberosPrincipalName.add(principal);
+            
+            Attribute keyVersionNumber = new 
BasicAttribute("krb5KeyVersionNumber");
+            keyVersionNumber.add("0");
+            
+            userAttributes.put(kerberosPrincipalName);
+            userAttributes.put(keyVersionNumber);
+                       
             //create compulsory attribute: sn-last name
             Attribute lastName = new BasicAttribute(SN_ATTRIBUTE_NAME);
             lastName.add(tenant.getAdminLastName());
@@ -460,5 +479,41 @@
 
        }
     
+       /**
+        * 
+        * @return
+        */
+       protected String getRealmName() {
+
+               // First check whether realm name is defined in the 
configuration
+               String defaultRealmName = this.realmConfig
+                               
.getUserStoreProperty(UserCoreConstants.RealmConfig.DEFAULT_REALM_NAME);
+
+               if (defaultRealmName != null) {
+                       return defaultRealmName;
+               }
+
+               // If not build the realm name from the search base.
+               // Here the realm name will be a concatenation of dc components 
in the
+               // search base.
+               String searchBase = 
this.realmConfig.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);
+
+               String[] domainComponents = searchBase.split("dc=");
+
+               StringBuilder builder = new StringBuilder();
+
+               for (String dc : domainComponents) {
+                       if (!dc.contains("=")) {
+                               String trimmedDc = dc.trim();
+                               if (trimmedDc.endsWith(",")) {
+                                       builder.append(trimmedDc.replace(',', 
'.'));
+                               } else {
+                                       builder.append(trimmedDc);
+                               }
+                       }
+               }
+
+               return builder.toString().toUpperCase(Locale.ENGLISH);
+       }
     
 }
Index: 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/UserCoreConstants.java
===================================================================
--- 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/UserCoreConstants.java
 (working copy)
+++ 
core/org.wso2.carbon.user.core/4.2.0/src/main/java/org/wso2/carbon/user/core/UserCoreConstants.java
 (working copy)
@@ -64,6 +64,8 @@
 
     public static final String DOMAIN_SEPARATOR = "/";
     
+    public static final String PRINCIPAL_USERNAME_SEPARATOR = "_";
+    
     public static final String SHARED_ROLE_TENANT_SEPERATOR = "@";
 
     public static final String NAME_COMBINER = "|";
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to