Package org.omg.CSI

Examples of org.omg.CSI.IdentityToken


/* 154 */         StringBuffer tmp = new StringBuffer();
/* 155 */         CSIv2Util.toString(secMech, tmp);
/* 156 */         log.trace(tmp);
/*     */       }
/*     */
/* 159 */       IdentityToken identityToken = absentIdentityToken;
/* 160 */       byte[] encodedAuthenticationToken = noAuthenticationToken;
/*     */
/* 162 */       if ((secMech.sas_context_mech.target_supports & 0x400) != 0)
/*     */       {
/* 166 */         Principal p = null;
/* 167 */         RunAsIdentity runAs = SecurityAssociation.peekRunAsIdentity();
/* 168 */         if (runAs != null)
/*     */         {
/* 171 */           p = runAs;
/*     */         }
/*     */         else
/*     */         {
/* 176 */           p = SecurityAssociation.getPrincipal();
/*     */         }
/*     */
/* 179 */         if (p != null)
/*     */         {
/* 182 */           String name = p.getName();
/* 183 */           if (name.indexOf('@') < 0)
/* 184 */             name = name + "@default";
/* 185 */           byte[] principalName = name.getBytes("UTF-8");
/*     */
/* 188 */           byte[] encodedName = CSIv2Util.encodeGssExportedName(principalName);
/*     */
/* 192 */           Any any = ORB.init().create_any();
/* 193 */           byte[] encapsulatedEncodedName = null;
/* 194 */           GSS_NT_ExportedNameHelper.insert(any, encodedName);
/*     */           try
/*     */           {
/* 197 */             encapsulatedEncodedName = this.codec.encode_value(any);
/*     */           }
/*     */           catch (InvalidTypeForEncoding e)
/*     */           {
/* 201 */             throw new RuntimeException("Unexpected exception: " + e);
/*     */           }
/*     */
/* 205 */           identityToken = new IdentityToken();
/* 206 */           identityToken.principal_name(encapsulatedEncodedName);
/*     */         }
/* 208 */         else if ((secMech.sas_context_mech.supported_identity_types & 0x1) != 0)
/*     */         {
/* 213 */           identityToken = new IdentityToken();
/* 214 */           identityToken.anonymous(true);
/*     */         }
/*     */       }
/*     */
/* 218 */       if ((secMech.as_context_mech.target_requires & 0x40) != 0)
/*     */       {
View Full Code Here


*/
public class CSSSASITTAbsent implements CSSSASIdentityToken {

    public IdentityToken encodeIdentityToken() {

        IdentityToken token = new IdentityToken();
        token.absent(true);
        return token;
    }
View Full Code Here

                encoding = Util.getCodec().encode_value(any);
            } catch (InvalidTypeForEncoding itfe) {
                throw new IllegalStateException("Unable to encode principal name '" + name + "' " + itfe, itfe);
            }

            token = new IdentityToken();
            token.principal_name(encoding);
        }
        return token;
    }
View Full Code Here

*/
public class CSSSASITTAnonymous implements CSSSASIdentityToken {

    public IdentityToken encodeIdentityToken() {

        IdentityToken token = new IdentityToken();
        token.anonymous(true);
        return token;
    }
View Full Code Here

     * TODO should also use login domains?
     * @return IdentityToken
     */
    public IdentityToken encodeIdentityToken() {

        IdentityToken token = null;
        Subject subject = ContextManager.getNextCaller();
        String principalName = null;
        if (subject == null) {
//            Set principals = Collections.EMPTY_SET;
        } else if (realm != null) {
            Set principals = subject.getPrincipals(RealmPrincipal.class);
            for (Iterator iter = principals.iterator(); iter.hasNext();) {
                RealmPrincipal p = (RealmPrincipal) iter.next();
                if (p.getRealm().equals(realm) && p.getLoginDomain().equals(domain) && p.getPrincipal().getClass().equals(principalClass)) {
                    principalName = p.getPrincipal().getName();
                    if (p instanceof PrimaryRealmPrincipal) break;
                }
            }
        } else if (domain != null) {
            Set principals = subject.getPrincipals(DomainPrincipal.class);
            for (Iterator iter = principals.iterator(); iter.hasNext();) {
                DomainPrincipal p = (DomainPrincipal) iter.next();
                if (p.getDomain().equals(domain) && p.getPrincipal().getClass().equals(principalClass)) {
                    principalName = p.getPrincipal().getName();
                    if (p instanceof PrimaryDomainPrincipal) break;
                }
            }
        } else {
            Set principals = subject.getPrincipals(principalClass);
            if (!principals.isEmpty()) {
                Principal principal = (Principal) principals.iterator().next();
                principalName = principal.getName();

            }
        }

        if (principalName != null) {

            Any any = Util.getORB().create_any();

            //TODO consider including a domain in this scoped-username
            GSS_NT_ExportedNameHelper.insert(any, Util.encodeGSSExportName(oid, principalName));

            byte[] encoding = null;
            try {
                encoding = Util.getCodec().encode_value(any);
            } catch (InvalidTypeForEncoding itfe) {
                throw new IllegalStateException("Unable to encode principal name '" + principalName + "' " + itfe, itfe);
            }

            token = new IdentityToken();
            token.principal_name(encoding);
        } else {
            token = new IdentityToken();
            token.anonymous(true);
        }

        return token;
    }
View Full Code Here

        try
        {
            Any msg = null;
            if (client_context_id <= 0)
            {
                IdentityToken identityToken = new IdentityToken();
                identityToken.absent(true);
                contextToken = sasContext.createClientContext(orb, codec, csmList);
                msg = makeEstablishContext(orb,
                                           -client_context_id,
                                           authorizationList,
                                           identityToken,
View Full Code Here

                CSIv2Util.toString(secMech, tmp);
                log.trace(tmp);
            }

            // these "null tokens" will be changed if needed.
            IdentityToken identityToken = absentIdentityToken;
            byte[] encodedAuthenticationToken = noAuthenticationToken;

            if ((secMech.sas_context_mech.target_supports & IdentityAssertion.value) != 0) {
                // will create identity token.
                RunAs runAs = SecurityContextAssociation.peekRunAsIdentity();
                Principal p = (runAs != null) ? runAs : SecurityContextAssociation.getPrincipal();

                if (p != null) {
                    // The name scope needs to be externalized.
                    String name = p.getName();
                    if (name.indexOf('@') < 0) {
                        name += "@default"; // hardcoded (REVISIT!)
                    }
                    byte[] principalName = name.getBytes("UTF-8");

                    // encode the principal name as mandated by RFC2743.
                    byte[] encodedName = CSIv2Util.encodeGssExportedName(principalName);

                    // encapsulate the encoded name.
                    Any any = ORB.init().create_any();
                    byte[] encapsulatedEncodedName;
                    GSS_NT_ExportedNameHelper.insert(any, encodedName);
                    try {
                        encapsulatedEncodedName = codec.encode_value(any);
                    } catch (InvalidTypeForEncoding e) {
                        throw new RuntimeException("Unexpected exception: " + e);
                    }

                    // create identity token.
                    identityToken = new IdentityToken();
                    identityToken.principal_name(encapsulatedEncodedName);
                } else if ((secMech.sas_context_mech.supported_identity_types & ITTAnonymous.value) != 0) {
                    // no run-as or caller identity and the target supports ITTAnonymous: use the anonymous identity.
                    identityToken = new IdentityToken();
                    identityToken.anonymous(true);
                }
            }

            if ((secMech.as_context_mech.target_requires & EstablishTrustInClient.value) != 0) {
                // will create authentication token with the configured pair serverUsername/serverPassword.
View Full Code Here

TOP

Related Classes of org.omg.CSI.IdentityToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.