本文整理汇总了Java中javax.security.auth.kerberos.KerberosPrincipal.getRealm方法的典型用法代码示例。如果您正苦于以下问题:Java KerberosPrincipal.getRealm方法的具体用法?Java KerberosPrincipal.getRealm怎么用?Java KerberosPrincipal.getRealm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.security.auth.kerberos.KerberosPrincipal
的用法示例。
在下文中一共展示了KerberosPrincipal.getRealm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDomain
import javax.security.auth.kerberos.KerberosPrincipal; //导入方法依赖的package包/类
public String getDomain() {
String realm = "";
if (subject != null) {
Set pr=subject.getPrincipals();
for (Iterator ite = pr.iterator();ite.hasNext();){
try{
KerberosPrincipal entry = (KerberosPrincipal) ite.next();
realm = entry.getRealm();
break;
}catch (Exception e){
continue;
}
}
}
if (realm.isEmpty()){
return getDefaultDomain();
}
return realm;
}
示例2: getUserDomain
import javax.security.auth.kerberos.KerberosPrincipal; //导入方法依赖的package包/类
@Override
public String getUserDomain () {
if ( this.realm == null && this.getSubject() != null ) {
Set<Principal> pr = this.getSubject().getPrincipals();
for ( Iterator<Principal> ite = pr.iterator(); ite.hasNext(); ) {
try {
KerberosPrincipal entry = (KerberosPrincipal) ite.next();
return entry.getRealm();
}
catch ( Exception e ) {
continue;
}
}
}
if ( this.realm != null ) {
return this.realm;
}
return super.getUserDomain();
}
示例3: getKerberosTicket
import javax.security.auth.kerberos.KerberosPrincipal; //导入方法依赖的package包/类
private static KerberosTicket getKerberosTicket ( KerberosPrincipal principal, String password, Long expire ) throws Exception {
PrincipalName principalName = new PrincipalName(principal.getName(), PrincipalName.KRB_NT_PRINCIPAL, principal.getRealm());
KrbAsReqBuilder builder = new KrbAsReqBuilder(principalName, password != null ? password.toCharArray() : new char[0]);
if ( expire != null ) {
System.out.println("Request expires " + expire);
KerberosTime till = new KerberosTime(expire);
Field tillF = builder.getClass().getDeclaredField("till");
tillF.setAccessible(true);
tillF.set(builder, till);
}
Credentials creds = builder.action().getCreds();
builder.destroy();
KerberosTicket ticket = Krb5Util.credsToTicket(creds);
System.out.println("Ends " + ticket.getEndTime().getTime());
return ticket;
}