Search in sources :

Example 31 with Any

use of org.omg.CORBA.Any in project wildfly by wildfly.

the class InterfaceDefImpl method describe.

// ContainedImpl implementation ----------------------------------
public Description describe() {
    String defined_in_id = "IR";
    if (defined_in instanceof org.omg.CORBA.ContainedOperations)
        defined_in_id = ((org.omg.CORBA.ContainedOperations) defined_in).id();
    org.omg.CORBA.InterfaceDescription md = new InterfaceDescription(name, id, defined_in_id, version, base_interfaces, false);
    Any any = getORB().create_any();
    InterfaceDescriptionHelper.insert(any, md);
    return new Description(DefinitionKind.dk_Interface, any);
}
Also used : ParameterDescription(org.omg.CORBA.ParameterDescription) Description(org.omg.CORBA.ContainedPackage.Description) AttributeDescription(org.omg.CORBA.AttributeDescription) OperationDescription(org.omg.CORBA.OperationDescription) FullInterfaceDescription(org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription) InterfaceDescription(org.omg.CORBA.InterfaceDescription) FullInterfaceDescription(org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription) InterfaceDescription(org.omg.CORBA.InterfaceDescription) InterfaceDescription(org.omg.CORBA.InterfaceDescription) Any(org.omg.CORBA.Any)

Example 32 with Any

use of org.omg.CORBA.Any in project wildfly by wildfly.

the class SASClientIdentityInterceptor method receive_reply.

@Override
public void receive_reply(ClientRequestInfo ri) {
    try {
        ServiceContext sc = ri.get_reply_service_context(sasContextId);
        Any msg = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(msg);
        // At this point contextBody should contain a CompleteEstablishContext message, which does not require any
        // treatment. ContextError messages should arrive via receive_exception().
        IIOPLogger.ROOT_LOGGER.tracef("receive_reply: got SAS reply, type %d", contextBody.discriminator());
        if (contextBody.discriminator() == MTContextError.value) {
            // should not happen.
            throw IIOPLogger.ROOT_LOGGER.unexpectedContextErrorInSASReply(0, CompletionStatus.COMPLETED_YES);
        }
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing.
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorParsingSASReply(e, 0, CompletionStatus.COMPLETED_YES);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 33 with Any

use of org.omg.CORBA.Any in project wildfly by wildfly.

the class SASClientInterceptor method send_request.

@Override
public void send_request(ClientRequestInfo ri) {
    try {
        CompoundSecMech secMech = CSIv2Util.getMatchingSecurityMech(ri, codec, EstablishTrustInClient.value, /* client supports */
        (short) 0);
        if (secMech == null) {
            return;
        }
        if ((secMech.as_context_mech.target_supports & EstablishTrustInClient.value) != 0) {
            Principal p = SecurityActions.getPrincipal();
            if (p != null) {
                byte[] encodedTargetName = secMech.as_context_mech.target_name;
                // The name scope needs to be externalized.
                String name = p.getName();
                if (name.indexOf('@') < 0) {
                    byte[] decodedTargetName = CSIv2Util.decodeGssExportedName(encodedTargetName);
                    String targetName = new String(decodedTargetName, StandardCharsets.UTF_8);
                    // "@default"
                    name += "@" + targetName;
                }
                byte[] username = name.getBytes(StandardCharsets.UTF_8);
                // I don't know why there is not a better way to go from char[] -> byte[].
                Object credential = SecurityActions.getCredential();
                byte[] password = {};
                if (credential instanceof char[]) {
                    String tmp = new String((char[]) credential);
                    password = tmp.getBytes(StandardCharsets.UTF_8);
                } else if (credential instanceof byte[])
                    password = (byte[]) credential;
                else if (credential != null) {
                    String tmp = credential.toString();
                    password = tmp.getBytes(StandardCharsets.UTF_8);
                }
                // create authentication token.
                InitialContextToken authenticationToken = new InitialContextToken(username, password, encodedTargetName);
                // ASN.1-encode it, as defined in RFC 2743.
                byte[] encodedAuthenticationToken = CSIv2Util.encodeInitialContextToken(authenticationToken, codec);
                // create EstablishContext message with the encoded token.
                EstablishContext message = new // stateless ctx id
                EstablishContext(// stateless ctx id
                0, noAuthorizationToken, absentIdentityToken, encodedAuthenticationToken);
                // create SAS context with the EstablishContext message.
                SASContextBody contextBody = new SASContextBody();
                contextBody.establish_msg(message);
                // stuff the SAS context into the outgoing request.
                Any any = ORB.init().create_any();
                SASContextBodyHelper.insert(any, contextBody);
                ServiceContext sc = new ServiceContext(sasContextId, codec.encode_value(any));
                ri.add_request_service_context(sc, true);
            }
        }
    } catch (Exception e) {
        throw IIOPLogger.ROOT_LOGGER.unexpectedException(e);
    }
}
Also used : CompoundSecMech(org.omg.CSIIOP.CompoundSecMech) ServiceContext(org.omg.IOP.ServiceContext) InitialContextToken(org.omg.GSSUP.InitialContextToken) SASContextBody(org.omg.CSI.SASContextBody) LocalObject(org.omg.CORBA.LocalObject) EstablishContext(org.omg.CSI.EstablishContext) Any(org.omg.CORBA.Any) Principal(java.security.Principal)

Example 34 with Any

use of org.omg.CORBA.Any in project wildfly by wildfly.

the class SASTargetInterceptor method receive_request.

@Override
public void receive_request(ServerRequestInfo ri) {
    IIOPLogger.ROOT_LOGGER.tracef("receive_request: %s", ri.operation());
    CurrentRequestInfo threadLocal = threadLocalData.get();
    threadLocal.sasContextReceived = false;
    threadLocal.authenticationTokenReceived = false;
    threadLocal.incomingUsername = empty;
    threadLocal.incomingPassword = empty;
    threadLocal.incomingTargetName = empty;
    threadLocal.incomingIdentity = absent;
    threadLocal.incomingPrincipalName = empty;
    threadLocal.sasReply = null;
    threadLocal.sasReplyIsAccept = false;
    try {
        ServiceContext sc = ri.get_request_service_context(sasContextId);
        Any any = codec.decode_value(sc.context_data, SASContextBodyHelper.type());
        SASContextBody contextBody = SASContextBodyHelper.extract(any);
        if (contextBody != null) {
            if (contextBody.discriminator() == MTMessageInContext.value) {
                // should not happen, as stateful context requests are always negotiated down to stateless in this implementation.
                long contextId = contextBody.in_context_msg().client_context_id;
                threadLocal.sasReply = createMsgCtxError(contextId, 4);
                throw IIOPLogger.ROOT_LOGGER.missingSASContext();
            } else if (contextBody.discriminator() == MTEstablishContext.value) {
                EstablishContext message = contextBody.establish_msg();
                threadLocal.contextId = message.client_context_id;
                threadLocal.sasContextReceived = true;
                if (message.client_authentication_token != null && message.client_authentication_token.length > 0) {
                    IIOPLogger.ROOT_LOGGER.trace("Received client authentication token");
                    InitialContextToken authToken = CSIv2Util.decodeInitialContextToken(message.client_authentication_token, codec);
                    if (authToken == null) {
                        threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                        throw IIOPLogger.ROOT_LOGGER.errorDecodingInitContextToken();
                    }
                    threadLocal.incomingUsername = authToken.username;
                    threadLocal.incomingPassword = authToken.password;
                    threadLocal.incomingTargetName = CSIv2Util.decodeGssExportedName(authToken.target_name);
                    if (threadLocal.incomingTargetName == null) {
                        threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                        throw IIOPLogger.ROOT_LOGGER.errorDecodingTargetInContextToken();
                    }
                    threadLocal.authenticationTokenReceived = true;
                }
                if (message.identity_token != null) {
                    IIOPLogger.ROOT_LOGGER.trace("Received identity token");
                    threadLocal.incomingIdentity = message.identity_token;
                    if (message.identity_token.discriminator() == ITTPrincipalName.value) {
                        // Extract the RFC2743-encoded name from CDR encapsulation.
                        Any a = codec.decode_value(message.identity_token.principal_name(), GSS_NT_ExportedNameHelper.type());
                        byte[] encodedName = GSS_NT_ExportedNameHelper.extract(a);
                        // Decode the principal name.
                        threadLocal.incomingPrincipalName = CSIv2Util.decodeGssExportedName(encodedName);
                        if (threadLocal.incomingPrincipalName == null) {
                            threadLocal.sasReply = createMsgCtxError(message.client_context_id, 2);
                            throw IIOPLogger.ROOT_LOGGER.errorDecodingPrincipalName();
                        }
                    }
                }
                threadLocal.sasReply = (threadLocal.contextId == 0) ? msgCtx0Accepted : createMsgCtxAccepted(threadLocal.contextId);
                threadLocal.sasReplyIsAccept = true;
            }
        }
    } catch (BAD_PARAM e) {
    // no service context with sasContextId: do nothing.
    } catch (FormatMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    } catch (TypeMismatch e) {
        throw IIOPLogger.ROOT_LOGGER.errorDecodingContextData(this.name(), e);
    }
}
Also used : ServiceContext(org.omg.IOP.ServiceContext) InitialContextToken(org.omg.GSSUP.InitialContextToken) BAD_PARAM(org.omg.CORBA.BAD_PARAM) SASContextBody(org.omg.CSI.SASContextBody) CompleteEstablishContext(org.omg.CSI.CompleteEstablishContext) EstablishContext(org.omg.CSI.EstablishContext) MTEstablishContext(org.omg.CSI.MTEstablishContext) Any(org.omg.CORBA.Any) FormatMismatch(org.omg.IOP.CodecPackage.FormatMismatch) TypeMismatch(org.omg.IOP.CodecPackage.TypeMismatch)

Example 35 with Any

use of org.omg.CORBA.Any in project wildfly by wildfly.

the class OperationDefImpl method describe.

// ContainedImpl implementation ----------------------------------
public Description describe() {
    String defined_in_id = "IR";
    if (defined_in instanceof ContainedOperations)
        defined_in_id = ((ContainedOperations) defined_in).id();
    ExceptionDescription[] exds;
    exds = new ExceptionDescription[exceptions.length];
    for (int i = 0; i < exceptions.length; ++i) {
        Description d = exceptions[i].describe();
        exds[i] = ExceptionDescriptionHelper.extract(d.value);
    }
    OperationDescription od;
    od = new OperationDescription(name, id, defined_in_id, version, typeCode, mode(), contexts(), params(), exds);
    Any any = getORB().create_any();
    OperationDescriptionHelper.insert(any, od);
    return new Description(DefinitionKind.dk_Operation, any);
}
Also used : OperationDescription(org.omg.CORBA.OperationDescription) ExceptionDescription(org.omg.CORBA.ExceptionDescription) ParameterDescription(org.omg.CORBA.ParameterDescription) Description(org.omg.CORBA.ContainedPackage.Description) ExceptionDescription(org.omg.CORBA.ExceptionDescription) ContainedOperations(org.omg.CORBA.ContainedOperations) Any(org.omg.CORBA.Any) OperationDescription(org.omg.CORBA.OperationDescription)

Aggregations

Any (org.omg.CORBA.Any)107 MonitorBlob (alma.TMCDB.MonitorBlob)20 MonitorDataBlock (alma.TMCDB.MonitorDataBlock)20 ComponentData (alma.acs.monitoring.DAO.ComponentData)15 ServiceContext (org.omg.IOP.ServiceContext)13 BAD_PARAM (org.omg.CORBA.BAD_PARAM)10 SASContextBody (org.omg.CSI.SASContextBody)10 AcsJException (alma.acs.exceptions.AcsJException)9 Test (org.junit.Test)9 Description (org.omg.CORBA.ContainedPackage.Description)9 FormatMismatch (org.omg.IOP.CodecPackage.FormatMismatch)8 TypeMismatch (org.omg.IOP.CodecPackage.TypeMismatch)8 ContainedOperations (org.omg.CORBA.ContainedOperations)7 NVList (org.omg.CORBA.NVList)7 InvalidTypeForEncoding (org.omg.IOP.CodecPackage.InvalidTypeForEncoding)7 TMCDB.doubleBlobData (alma.TMCDB.doubleBlobData)6 TMCDB.doubleSeqBlobData (alma.TMCDB.doubleSeqBlobData)6 TMCDB.floatBlobData (alma.TMCDB.floatBlobData)6 MonitorPointTimeSeries (alma.acs.monitoring.MonitorPointTimeSeries)6 MonitorPointValue (alma.acs.monitoring.MonitorPointValue)6