Class: Kerberos::Krb5::Principal
- Inherits:
-
Object
- Object
- Kerberos::Krb5::Principal
- Defined in:
- ext/rkerberos/principal.c
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Attributes.
- #aux_attributes ⇒ Object
- #expire_time ⇒ Object
- #fail_auth_count ⇒ Object
- #kvno ⇒ Object
- #last_failed ⇒ Object
- #last_password_change ⇒ Object
- #last_success ⇒ Object
- #max_life ⇒ Object
- #max_renewable_life ⇒ Object
- #mod_date ⇒ Object
- #mod_name ⇒ Object
- #password_expiration ⇒ Object
- #policy ⇒ Object
- #principal ⇒ Object (also: #name) readonly
Instance Method Summary collapse
-
#==(principal2) ⇒ Object
Returns whether or not two principals are the same.
-
#Kerberos::Krb5::Principal.new(name) ⇒ Object
constructor
Creates and returns a new Krb5::Principal object.
-
#inspect ⇒ Object
A custom inspect method for the Principal object.
-
#realm ⇒ Object
Returns the realm for the given principal.
-
#realm=(v_realm) ⇒ Object
Sets the realm for the given principal.
Constructor Details
#Kerberos::Krb5::Principal.new(name) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'ext/rkerberos/principal.c', line 41
static VALUE rkrb5_princ_initialize(VALUE self, VALUE v_name){
RUBY_KRB5_PRINC* ptr;
krb5_error_code kerror;
Data_Get_Struct(self, RUBY_KRB5_PRINC, ptr);
kerror = krb5_init_context(&ptr->ctx);
if(kerror)
rb_raise(cKrb5Exception, "krb5_init_context failed: %s", error_message(kerror));
if(NIL_P(v_name)){
rb_iv_set(self, "@principal", Qnil);
}
else{
char* name;
Check_Type(v_name, T_STRING);
name = StringValuePtr(v_name);
kerror = krb5_parse_name(ptr->ctx, name, &ptr->principal);
if(kerror)
rb_raise(cKrb5Exception, "krb5_parse_name failed: %s", error_message(kerror));
rb_iv_set(self, "@principal", v_name);
}
rb_iv_set(self, "@attributes", Qnil);
rb_iv_set(self, "@aux_attributes", Qnil);
rb_iv_set(self, "@expire_time", Qnil);
rb_iv_set(self, "@fail_auth_count", Qnil);
rb_iv_set(self, "@last_failed", Qnil);
rb_iv_set(self, "@last_password_change", Qnil);
rb_iv_set(self, "@last_success", Qnil);
rb_iv_set(self, "@max_life", Qnil);
rb_iv_set(self, "@max_renewable_life", Qnil);
rb_iv_set(self, "@mod_date", Qnil);
rb_iv_set(self, "@mod_name", Qnil);
rb_iv_set(self, "@password_expiration", Qnil);
rb_iv_set(self, "@policy", Qnil);
rb_iv_set(self, "@kvno", Qnil);
if(rb_block_given_p())
rb_yield(self);
return self;
}
|
Instance Attribute Details
#attributes ⇒ Object
Attributes
#aux_attributes ⇒ Object
#expire_time ⇒ Object
#fail_auth_count ⇒ Object
#kvno ⇒ Object
#last_failed ⇒ Object
#last_password_change ⇒ Object
#last_success ⇒ Object
#max_life ⇒ Object
#max_renewable_life ⇒ Object
#mod_date ⇒ Object
#mod_name ⇒ Object
#password_expiration ⇒ Object
#policy ⇒ Object
#principal ⇒ Object (readonly) Also known as: name
Instance Method Details
#==(principal2) ⇒ Object
Returns whether or not two principals are the same.
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'ext/rkerberos/principal.c', line 128
static VALUE rkrb5_princ_equal(VALUE self, VALUE v_other){
RUBY_KRB5_PRINC* ptr1;
RUBY_KRB5_PRINC* ptr2;
VALUE v_bool = Qfalse;
Data_Get_Struct(self, RUBY_KRB5_PRINC, ptr1);
Data_Get_Struct(v_other, RUBY_KRB5_PRINC, ptr2);
if(krb5_principal_compare(ptr1->ctx, ptr1->principal, ptr2->principal))
v_bool = Qtrue;
return v_bool;
}
|
#inspect ⇒ Object
A custom inspect method for the Principal object.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'ext/rkerberos/principal.c', line 148 static VALUE rkrb5_princ_inspect(VALUE self){ RUBY_KRB5_PRINC* ptr; VALUE v_str; Data_Get_Struct(self, RUBY_KRB5_PRINC, ptr); v_str = rb_str_new2("#<"); rb_str_buf_cat2(v_str, rb_obj_classname(self)); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "attributes="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@attributes"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "aux_attributes="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@aux_attributes"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "expire_time="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@expire_time"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "fail_auth_count="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@fail_auth_count"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "kvno="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@kvno"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "last_failed="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@last_failed"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "last_password_change="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@last_password_change"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "last_success="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@last_success"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "max_life="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@max_life"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "max_renewable_life="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@max_renewable_life"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "mod_date="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@mod_date"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "mod_name="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@mod_name"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "password_expiration="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@password_expiration"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "policy="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@policy"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, "principal="); rb_str_buf_append(v_str, rb_inspect(rb_iv_get(self, "@principal"))); rb_str_buf_cat2(v_str, " "); rb_str_buf_cat2(v_str, ">"); return v_str; } |
#realm ⇒ Object
Returns the realm for the given principal.
94 95 96 97 98 99 |
# File 'ext/rkerberos/principal.c', line 94
static VALUE rkrb5_princ_get_realm(VALUE self){
RUBY_KRB5_PRINC* ptr;
Data_Get_Struct(self, RUBY_KRB5_PRINC, ptr);
return rb_str_new2(krb5_princ_realm(ptr->ctx, ptr->principal)->data);
}
|
#realm=(v_realm) ⇒ Object
Sets the realm for the given principal.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'ext/rkerberos/principal.c', line 107
static VALUE rkrb5_princ_set_realm(VALUE self, VALUE v_realm){
RUBY_KRB5_PRINC* ptr;
krb5_data kdata;
memset(&kdata, 0, sizeof(kdata));
Data_Get_Struct(self, RUBY_KRB5_PRINC, ptr);
Check_Type(v_realm, T_STRING);
kdata.data = StringValuePtr(v_realm);
krb5_princ_set_realm(ptr->ctx, ptr->principal, &kdata);
return v_realm;
}
|